Skip to content

Commit

Permalink
initialize logging at compile time
Browse files Browse the repository at this point in the history
  • Loading branch information
derselbst committed Oct 9, 2018
1 parent d25cdae commit 2b56307
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 61 deletions.
2 changes: 0 additions & 2 deletions src/synth/fluid_synth.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,6 @@ fluid_synth_init(void)

fluid_rvoice_dsp_config();

fluid_sys_config();

init_dither();

/* custom_breath2att_mod is not a default modulator specified in SF2.01.
Expand Down
62 changes: 9 additions & 53 deletions src/utils/fluid_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,17 @@ static int fluid_istream_gets(fluid_istream_t in, char *buf, int len);

static char fluid_errbuf[512]; /* buffer for error message */

static fluid_log_function_t fluid_log_function[LAST_LOG_LEVEL];
static void *fluid_log_user_data[LAST_LOG_LEVEL];
static int fluid_log_initialized = 0;

static const char fluid_libname[] = "fluidsynth";


void fluid_sys_config()
static fluid_log_function_t fluid_log_function[LAST_LOG_LEVEL] =
{
fluid_log_config();
}
fluid_default_log_function,
fluid_default_log_function,
fluid_default_log_function,
fluid_default_log_function,
fluid_default_log_function
};
static void *fluid_log_user_data[LAST_LOG_LEVEL] = { NULL };

static const char fluid_libname[] = "fluidsynth";

/**
* Installs a new log function for a specified log level.
Expand Down Expand Up @@ -128,11 +127,6 @@ fluid_default_log_function(int level, const char *message, void *data)
out = stderr;
#endif

if(fluid_log_initialized == 0)
{
fluid_log_config();
}

switch(level)
{
case FLUID_PANIC:
Expand Down Expand Up @@ -165,44 +159,6 @@ fluid_default_log_function(int level, const char *message, void *data)
fflush(out);
}

/*
* fluid_init_log
*/
void
fluid_log_config(void)
{
if(fluid_log_initialized == 0)
{

fluid_log_initialized = 1;

if(fluid_log_function[FLUID_PANIC] == NULL)
{
fluid_set_log_function(FLUID_PANIC, fluid_default_log_function, NULL);
}

if(fluid_log_function[FLUID_ERR] == NULL)
{
fluid_set_log_function(FLUID_ERR, fluid_default_log_function, NULL);
}

if(fluid_log_function[FLUID_WARN] == NULL)
{
fluid_set_log_function(FLUID_WARN, fluid_default_log_function, NULL);
}

if(fluid_log_function[FLUID_INFO] == NULL)
{
fluid_set_log_function(FLUID_INFO, fluid_default_log_function, NULL);
}

if(fluid_log_function[FLUID_DBG] == NULL)
{
fluid_set_log_function(FLUID_DBG, fluid_default_log_function, NULL);
}
}
}

/**
* Print a message to the log.
* @param level Log level (#fluid_log_level).
Expand Down
6 changes: 0 additions & 6 deletions src/utils/fluid_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@
*/
#define fluid_gerror_message(err) ((err) ? err->message : "No error details")


void fluid_sys_config(void);
void fluid_log_config(void);
void fluid_time_config(void);


/* Misc */
#if defined(__INTEL_COMPILER)
#define FLUID_RESTRICT restrict
Expand Down

2 comments on commit 2b56307

@carlo-bramini
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps, you could also delete fluid_error() and fluid_errbuf[] from fluid_sys.c (they are actually useless after your change), and just return a constant "DEPRECATED" string inside fluid_synth_error(). What do you think?

@derselbst
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thx for the hint. Seems I mistakenly committed d25cdae to master. I was intending to first deprecate it, then entirely break and remove it.

Please sign in to comment.