Skip to content

Commit

Permalink
Merge pull request #1 from FluidSynth/master
Browse files Browse the repository at this point in the history
Consistently use FLUID_LOG macro (#443)
  • Loading branch information
carlo-bramini authored Oct 20, 2018
2 parents 7517c17 + ebc177f commit dc15ace
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 28 deletions.
18 changes: 9 additions & 9 deletions src/midi/fluid_seq.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ new_fluid_sequencer2(int use_system_timer)

if(seq == NULL)
{
fluid_log(FLUID_PANIC, "sequencer: Out of memory\n");
FLUID_LOG(FLUID_PANIC, "sequencer: Out of memory\n");
return NULL;
}

Expand All @@ -132,7 +132,7 @@ new_fluid_sequencer2(int use_system_timer)
if(-1 == _fluid_seq_queue_init(seq, FLUID_SEQUENCER_EVENTS_MAX))
{
FLUID_FREE(seq);
fluid_log(FLUID_PANIC, "sequencer: Out of memory\n");
FLUID_LOG(FLUID_PANIC, "sequencer: Out of memory\n");
return NULL;
}

Expand All @@ -144,7 +144,7 @@ new_fluid_sequencer2(int use_system_timer)
{
_fluid_seq_queue_end(seq);
FLUID_FREE(seq);
fluid_log(FLUID_PANIC, "sequencer: Out of memory\n");
FLUID_LOG(FLUID_PANIC, "sequencer: Out of memory\n");
return NULL;
}

Expand Down Expand Up @@ -297,15 +297,15 @@ fluid_sequencer_register_client(fluid_sequencer_t *seq, const char *name,

if(client == NULL)
{
fluid_log(FLUID_PANIC, "sequencer: Out of memory\n");
FLUID_LOG(FLUID_PANIC, "sequencer: Out of memory\n");
return FLUID_FAILED;
}

nameCopy = FLUID_STRDUP(name);

if(nameCopy == NULL)
{
fluid_log(FLUID_PANIC, "sequencer: Out of memory\n");
FLUID_LOG(FLUID_PANIC, "sequencer: Out of memory\n");
FLUID_FREE(client);
return FLUID_FAILED;
}
Expand Down Expand Up @@ -575,7 +575,7 @@ fluid_sequencer_set_time_scale(fluid_sequencer_t *seq, double scale)
{
if(scale <= 0)
{
fluid_log(FLUID_WARN, "sequencer: scale <= 0 : %f\n", scale);
FLUID_LOG(FLUID_WARN, "sequencer: scale <= 0 : %f\n", scale);
return;
}

Expand Down Expand Up @@ -722,7 +722,7 @@ _fluid_seq_queue_init(fluid_sequencer_t *seq, int maxEvents)

if(seq->heap == NULL)
{
fluid_log(FLUID_PANIC, "sequencer: Out of memory\n");
FLUID_LOG(FLUID_PANIC, "sequencer: Out of memory\n");
return -1;
}

Expand Down Expand Up @@ -801,7 +801,7 @@ _fluid_seq_queue_pre_insert(fluid_sequencer_t *seq, fluid_event_t *evt)
if(evtentry == NULL)
{
/* should not happen */
fluid_log(FLUID_PANIC, "sequencer: no more free events\n");
FLUID_LOG(FLUID_PANIC, "sequencer: no more free events\n");
return -1;
}

Expand Down Expand Up @@ -839,7 +839,7 @@ _fluid_seq_queue_pre_remove(fluid_sequencer_t *seq, fluid_seq_id_t src, fluid_se
if(evtentry == NULL)
{
/* should not happen */
fluid_log(FLUID_PANIC, "sequencer: no more free events\n");
FLUID_LOG(FLUID_PANIC, "sequencer: no more free events\n");
return;
}

Expand Down
6 changes: 2 additions & 4 deletions src/midi/fluid_seqbind.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ fluid_sequencer_register_fluidsynth(fluid_sequencer_t *seq, fluid_synth_t *synth

if(seqbind == NULL)
{
fluid_log(FLUID_PANIC, "sequencer: Out of memory\n");
FLUID_LOG(FLUID_PANIC, "sequencer: Out of memory\n");
return FLUID_FAILED;
}

Expand All @@ -125,7 +125,7 @@ fluid_sequencer_register_fluidsynth(fluid_sequencer_t *seq, fluid_synth_t *synth

if(seqbind->sample_timer == NULL)
{
fluid_log(FLUID_PANIC, "sequencer: Out of memory\n");
FLUID_LOG(FLUID_PANIC, "sequencer: Out of memory\n");
delete_fluid_seqbind(seqbind);
return FLUID_FAILED;
}
Expand Down Expand Up @@ -359,5 +359,3 @@ fluid_sequencer_add_midi_event_to_buffer(void *data, fluid_midi_event_t *event)
/* Schedule for sending at next call to fluid_sequencer_process */
return fluid_sequencer_send_at(seq, &evt, 0, 0);
}


24 changes: 12 additions & 12 deletions src/rvoice/fluid_chorus.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ new_fluid_chorus(fluid_real_t sample_rate)

if(chorus == NULL)
{
fluid_log(FLUID_PANIC, "chorus: Out of memory");
FLUID_LOG(FLUID_PANIC, "chorus: Out of memory");
return NULL;
}

Expand Down Expand Up @@ -191,7 +191,7 @@ new_fluid_chorus(fluid_real_t sample_rate)

if(chorus->lookup_tab == NULL)
{
fluid_log(FLUID_PANIC, "chorus: Out of memory");
FLUID_LOG(FLUID_PANIC, "chorus: Out of memory");
goto error_recovery;
}

Expand All @@ -201,7 +201,7 @@ new_fluid_chorus(fluid_real_t sample_rate)

if(chorus->chorusbuf == NULL)
{
fluid_log(FLUID_PANIC, "chorus: Out of memory");
FLUID_LOG(FLUID_PANIC, "chorus: Out of memory");
goto error_recovery;
}

Expand Down Expand Up @@ -293,45 +293,45 @@ fluid_chorus_set(fluid_chorus_t *chorus, int set, int nr, fluid_real_t level,

if(chorus->number_blocks < 0)
{
fluid_log(FLUID_WARN, "chorus: number blocks must be >=0! Setting value to 0.");
FLUID_LOG(FLUID_WARN, "chorus: number blocks must be >=0! Setting value to 0.");
chorus->number_blocks = 0;
}
else if(chorus->number_blocks > MAX_CHORUS)
{
fluid_log(FLUID_WARN, "chorus: number blocks larger than max. allowed! Setting value to %d.",
FLUID_LOG(FLUID_WARN, "chorus: number blocks larger than max. allowed! Setting value to %d.",
MAX_CHORUS);
chorus->number_blocks = MAX_CHORUS;
}

if(chorus->speed_Hz < MIN_SPEED_HZ)
{
fluid_log(FLUID_WARN, "chorus: speed is too low (min %f)! Setting value to min.",
FLUID_LOG(FLUID_WARN, "chorus: speed is too low (min %f)! Setting value to min.",
(double) MIN_SPEED_HZ);
chorus->speed_Hz = MIN_SPEED_HZ;
}
else if(chorus->speed_Hz > MAX_SPEED_HZ)
{
fluid_log(FLUID_WARN, "chorus: speed must be below %f Hz! Setting value to max.",
FLUID_LOG(FLUID_WARN, "chorus: speed must be below %f Hz! Setting value to max.",
(double) MAX_SPEED_HZ);
chorus->speed_Hz = MAX_SPEED_HZ;
}

if(chorus->depth_ms < 0.0)
{
fluid_log(FLUID_WARN, "chorus: depth must be positive! Setting value to 0.");
FLUID_LOG(FLUID_WARN, "chorus: depth must be positive! Setting value to 0.");
chorus->depth_ms = 0.0;
}

/* Depth: Check for too high value through modulation_depth_samples. */

if(chorus->level < 0.0)
{
fluid_log(FLUID_WARN, "chorus: level must be positive! Setting value to 0.");
FLUID_LOG(FLUID_WARN, "chorus: level must be positive! Setting value to 0.");
chorus->level = 0.0;
}
else if(chorus->level > 10)
{
fluid_log(FLUID_WARN, "chorus: level must be < 10. A reasonable level is << 1! "
FLUID_LOG(FLUID_WARN, "chorus: level must be < 10. A reasonable level is << 1! "
"Setting it to 0.1.");
chorus->level = 0.1;
}
Expand All @@ -346,7 +346,7 @@ fluid_chorus_set(fluid_chorus_t *chorus, int set, int nr, fluid_real_t level,

if(modulation_depth_samples > MAX_SAMPLES)
{
fluid_log(FLUID_WARN, "chorus: Too high depth. Setting it to max (%d).", MAX_SAMPLES);
FLUID_LOG(FLUID_WARN, "chorus: Too high depth. Setting it to max (%d).", MAX_SAMPLES);
modulation_depth_samples = MAX_SAMPLES;
// set depth to maximum to avoid spamming console with above warning
chorus->depth_ms = (modulation_depth_samples * 1000) / chorus->sample_rate;
Expand All @@ -356,7 +356,7 @@ fluid_chorus_set(fluid_chorus_t *chorus, int set, int nr, fluid_real_t level,
switch(chorus->type)
{
default:
fluid_log(FLUID_WARN, "chorus: Unknown modulation type. Using sinewave.");
FLUID_LOG(FLUID_WARN, "chorus: Unknown modulation type. Using sinewave.");
chorus->type = FLUID_CHORUS_MOD_SINE;
/* fall-through */

Expand Down
6 changes: 3 additions & 3 deletions src/synth/fluid_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ new_fluid_event()

if(evt == NULL)
{
fluid_log(FLUID_PANIC, "event: Out of memory\n");
FLUID_LOG(FLUID_PANIC, "event: Out of memory\n");
return NULL;
}

Expand Down Expand Up @@ -751,7 +751,7 @@ _fluid_evt_heap_init(int nbEvents)

if(heap == NULL)
{
fluid_log(FLUID_PANIC, "sequencer: Out of memory\n");
FLUID_LOG(FLUID_PANIC, "sequencer: Out of memory\n");
return NULL;
}

Expand Down Expand Up @@ -782,7 +782,7 @@ _fluid_evt_heap_init(int nbEvents)

if(heap == NULL)
{
fluid_log(FLUID_PANIC, "sequencer: Out of memory\n");
FLUID_LOG(FLUID_PANIC, "sequencer: Out of memory\n");
return NULL;
}

Expand Down
9 changes: 9 additions & 0 deletions src/utils/fluidsynth_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,16 @@ do { strncpy(_dst,_src,_n); \
#define FLUID_FLUSH() fflush(stdout)
#endif

/* People who want to reduce the size of the may do this by entirely
* removing the logging system. This will cause all log messages to
* be discarded at compile time, allowing to save about 80 KiB for
* the compiled binary.
*/
#if 0
#define FLUID_LOG (void)sizeof
#else
#define FLUID_LOG fluid_log
#endif

#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795
Expand Down

0 comments on commit dc15ace

Please sign in to comment.