Skip to content

Commit 2509ebb

Browse files
committed
a bit more const-ness
Added const to a few more static tables. Removed redundant printMessage pointers in Timidity++ and GUS players. add pragma for better code generation with MSVC and pointers-to-member-functions.
1 parent 96cdb30 commit 2509ebb

File tree

8 files changed

+20
-19
lines changed

8 files changed

+20
-19
lines changed

thirdparty/timidity/instrum_sf2.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,20 +169,20 @@ static void ParseGen(SFFile *sf2, timidity_file *f, uint32_t chunkid, uint32_t c
169169
static void ParseInst(SFFile *sf2, timidity_file *f, uint32_t chunkid, uint32_t chunklen);
170170
static void ParseShdr(SFFile *sf2, timidity_file *f, uint32_t chunkid, uint32_t chunklen);
171171

172-
ListHandler INFOHandlers[] =
172+
static const ListHandler INFOHandlers[] =
173173
{
174174
{ ID_ifil, ParseIfil },
175175
{ 0, 0 }
176176
};
177177

178-
ListHandler SdtaHandlers[] =
178+
static const ListHandler SdtaHandlers[] =
179179
{
180180
{ ID_smpl, ParseSmpl },
181181
{ ID_sm24, ParseSm24 },
182182
{ 0, 0 }
183183
};
184184

185-
ListHandler PdtaHandlers[] =
185+
static const ListHandler PdtaHandlers[] =
186186
{
187187
{ ID_phdr, ParsePhdr },
188188
{ ID_pbag, ParseBag },
@@ -338,9 +338,9 @@ static void ParseIfil(SFFile *sf2, timidity_file *f, uint32_t chunkid, uint32_t
338338
sf2->MinorVersion = minor;
339339
}
340340

341-
static void ParseLIST(SFFile *sf2, timidity_file *f, uint32_t chunklen, ListHandler *handlers)
341+
static void ParseLIST(SFFile *sf2, timidity_file *f, uint32_t chunklen, const ListHandler *handlers)
342342
{
343-
ListHandler *handler;
343+
const ListHandler *handler;
344344
uint32_t id;
345345
uint32_t len;
346346

thirdparty/timidity/timidity.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ void Renderer::MarkInstrument(int banknum, int percussion, int instr)
822822
}
823823

824824

825-
static void default_cmsg(int type, int verbosity_level, const char* fmt, ...)
825+
void printMessage(int type, int verbosity_level, const char* fmt, ...)
826826
{
827827
if (verbosity_level >= VERB_NOISY) return; // Don't waste time on diagnostics.
828828

@@ -832,8 +832,5 @@ static void default_cmsg(int type, int verbosity_level, const char* fmt, ...)
832832
va_end(args);
833833
}
834834

835-
// Allow hosting applications to capture the messages and deal with them themselves.
836-
void (*printMessage)(int type, int verbosity_level, const char* fmt, ...) = default_cmsg;
837-
838835

839836
}

thirdparty/timidity/timidity/timidity.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ enum
4848
VERB_DEBUG
4949
};
5050

51-
extern void (*printMessage)(int type, int verbosity_level, const char *fmt, ...);
51+
extern void printMessage(int type, int verbosity_level, const char *fmt, ...);
5252

5353

5454
/*

thirdparty/timidityplus/common.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ int tf_getc(timidity_file *tf)
155155
return read == 0 ? EOF : c;
156156
}
157157

158-
void default_ctl_cmsg(int type, int verbosity_level, const char* fmt, ...)
158+
void printMessage(int type, int verbosity_level, const char* fmt, ...)
159159
{
160160
if (verbosity_level >= VERB_DEBUG) return; // Don't waste time on diagnostics.
161161

@@ -165,7 +165,4 @@ void default_ctl_cmsg(int type, int verbosity_level, const char* fmt, ...)
165165
va_end(args);
166166
}
167167

168-
// Allow hosting applications to capture the messages and deal with them themselves.
169-
void (*printMessage)(int type, int verbosity_level, const char* fmt, ...) = default_ctl_cmsg;
170-
171168
}

thirdparty/timidityplus/timiditypp/controls.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ inline bool RC_IS_SKIP_FILE(int rc)
5252
}
5353

5454

55-
extern void (*printMessage)(int type, int verbosity_level, const char* fmt, ...);
55+
extern void printMessage(int type, int verbosity_level, const char* fmt, ...);
5656

5757

5858
}

thirdparty/timidityplus/timiditypp/reverb.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,14 @@ typedef struct _EffectList {
234234
struct _EffectList *next_ef;
235235
} EffectList;
236236

237+
238+
#ifdef _MSC_VER
239+
// needed on MSVC to make Reverb::effects_engine truly const.
240+
// Due to Reverb being forward declared the default cannot be statically set up.
241+
#pragma pointers_to_members( full_generality, single_inheritance )
242+
#endif
243+
244+
237245
struct _EffectEngine {
238246
int type;
239247
const char *name;
@@ -548,8 +556,7 @@ struct multi_eq_xg_t
548556
};
549557

550558

551-
552-
class Reverb
559+
class Reverb final
553560
{
554561
double REV_INP_LEV;
555562

thirdparty/wildmidi/gus_pat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace WildMidi
3737

3838
/* Guspat Envelope Rate Timings */
3939

40-
float env_time_table[] = {
40+
extern const float env_time_table[] = {
4141
/* Row 1 = (4095.0 / (x * ( 1.0 / (1.6 * 14.0) ))) / 1000000.0 */
4242
0.0f, 0.091728000f, 0.045864000f, 0.030576000f, 0.022932000f, 0.018345600f, 0.015288000f, 0.013104000f,
4343
0.011466000f, 0.010192000f, 0.009172800f, 0.008338909f, 0.007644000f, 0.007056000f, 0.006552000f, 0.006115200f,

thirdparty/wildmidi/wildmidi/gus_pat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace WildMidi
3232

3333
class SoundFontReaderInterface;
3434
/* Guspat Envelope Rate Timings */
35-
extern float env_time_table[];
35+
extern float const env_time_table[];
3636

3737
}
3838

0 commit comments

Comments
 (0)