mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-11-10 23:11:41 +00:00
refactor return value checking of fluid_settings_*()
This commit is contained in:
parent
5f3cafbcfd
commit
9e9eacbc20
9 changed files with 22 additions and 23 deletions
|
@ -68,14 +68,14 @@ void fluid_LADSPA_CreateSystemNodes(fluid_LADSPA_FxUnit_t* FxUnit){
|
|||
int i;
|
||||
|
||||
/* Retrieve the number of synth / audio out / Fx send nodes */
|
||||
assert(fluid_settings_getint(FxUnit->synth->settings, "synth.audio-groups", &temp));
|
||||
assert(fluid_settings_getint(FxUnit->synth->settings, "synth.audio-groups", &temp) == FLUID_OK);
|
||||
nr_input_nodes=(int) temp;
|
||||
printf("%i audio groups\n", nr_input_nodes);
|
||||
|
||||
assert(fluid_settings_getint(FxUnit->synth->settings, "synth.audio-channels", &temp));
|
||||
assert(fluid_settings_getint(FxUnit->synth->settings, "synth.audio-channels", &temp) == FLUID_OK);
|
||||
nr_output_nodes=temp;
|
||||
|
||||
assert(fluid_settings_getint(FxUnit->synth->settings, "synth.effects-channels", &temp));
|
||||
assert(fluid_settings_getint(FxUnit->synth->settings, "synth.effects-channels", &temp) == FLUID_OK);
|
||||
nr_fx_input_nodes=temp;
|
||||
|
||||
/* Create regular input nodes (associated with audio groups) */
|
||||
|
@ -709,13 +709,13 @@ fluid_LADSPA_run(fluid_LADSPA_FxUnit_t* FxUnit, fluid_real_t* left_buf[], fluid_
|
|||
int temp;
|
||||
|
||||
/* Retrieve the number of synth / audio out / Fx send nodes */
|
||||
assert(fluid_settings_getint(FxUnit->synth->settings, "synth.audio-groups", &temp));
|
||||
assert(fluid_settings_getint(FxUnit->synth->settings, "synth.audio-groups", &temp) == FLUID_OK);
|
||||
nr_groups=(int) temp;
|
||||
|
||||
assert(fluid_settings_getint(FxUnit->synth->settings, "synth.audio-channels", &temp));
|
||||
assert(fluid_settings_getint(FxUnit->synth->settings, "synth.audio-channels", &temp) == FLUID_OK);
|
||||
nr_audio_channels=temp;
|
||||
|
||||
assert(fluid_settings_getint(FxUnit->synth->settings, "synth.effects-channels", &temp));
|
||||
assert(fluid_settings_getint(FxUnit->synth->settings, "synth.effects-channels", &temp) == FLUID_OK);
|
||||
nr_fx_sends=temp;
|
||||
|
||||
/* Fixme: Retrieving nodes via names is inefficient
|
||||
|
|
|
@ -791,10 +791,10 @@ new_fluid_alsa_seq_driver(fluid_settings_t* settings,
|
|||
fluid_settings_getint (settings, "midi.realtime-prio", &realtime_prio);
|
||||
|
||||
/* get the device name. if none is specified, use the default device. */
|
||||
if (fluid_settings_dupstr(settings, "midi.alsa_seq.device", &device) == 0) /* ++ alloc device name */
|
||||
if (fluid_settings_dupstr(settings, "midi.alsa_seq.device", &device) != FLUID_OK) /* ++ alloc device name */
|
||||
goto error_recovery;
|
||||
|
||||
if (fluid_settings_dupstr(settings, "midi.alsa_seq.id", &id) == 0) /* ++ alloc id string */
|
||||
if (fluid_settings_dupstr(settings, "midi.alsa_seq.id", &id) != FLUID_OK) /* ++ alloc id string */
|
||||
goto error_recovery;
|
||||
|
||||
if (id == NULL) {
|
||||
|
|
|
@ -206,7 +206,7 @@ new_fluid_core_audio_driver2(fluid_settings_t* settings, fluid_audio_func_t func
|
|||
fluid_settings_getint(settings, "audio.period-size", &period_size);
|
||||
|
||||
/* get the selected device name. if none is specified, use NULL for the default device. */
|
||||
if (fluid_settings_dupstr(settings, "audio.coreaudio.device", &devname) /* alloc device name */
|
||||
if (fluid_settings_dupstr(settings, "audio.coreaudio.device", &devname) == FLUID_OK /* alloc device name */
|
||||
&& devname && strlen (devname) > 0) {
|
||||
AudioObjectPropertyAddress pa;
|
||||
pa.mSelector = kAudioHardwarePropertyDevices;
|
||||
|
|
|
@ -168,7 +168,7 @@ new_fluid_dsound_audio_driver(fluid_settings_t* settings, fluid_synth_t* synth)
|
|||
|
||||
devsel.devGUID = NULL;
|
||||
/* get the selected device name. if none is specified, use NULL for the default device. */
|
||||
if(fluid_settings_dupstr(settings, "audio.dsound.device", &devsel.devname) /* ++ alloc device name */
|
||||
if(fluid_settings_dupstr(settings, "audio.dsound.device", &devsel.devname) == FLUID_OK /* ++ alloc device name */
|
||||
&& devsel.devname && strlen (devsel.devname) > 0) {
|
||||
/* look for the GUID of the selected device */
|
||||
DirectSoundEnumerate((LPDSENUMCALLBACK) fluid_dsound_enum_callback2, (void *)&devsel);
|
||||
|
|
|
@ -163,7 +163,7 @@ new_fluid_oss_audio_driver(fluid_settings_t* settings, fluid_synth_t* synth)
|
|||
goto error_recovery;
|
||||
}
|
||||
|
||||
if (!fluid_settings_dupstr(settings, "audio.oss.device", &devname) || !devname) { /* ++ alloc device name */
|
||||
if (fluid_settings_dupstr(settings, "audio.oss.device", &devname) != FLUID_OK || !devname) { /* ++ alloc device name */
|
||||
devname = FLUID_STRDUP ("/dev/dsp");
|
||||
|
||||
if (devname == NULL) {
|
||||
|
@ -277,7 +277,7 @@ new_fluid_oss_audio_driver2(fluid_settings_t* settings, fluid_audio_func_t func,
|
|||
dev->buffer_byte_size = dev->buffer_size * 2 * 2; /* 2 channels * 16 bits audio */
|
||||
|
||||
|
||||
if (!fluid_settings_dupstr(settings, "audio.oss.device", &devname) || !devname) {
|
||||
if (fluid_settings_dupstr(settings, "audio.oss.device", &devname) != FLUID_OK || !devname) {
|
||||
devname = FLUID_STRDUP ("/dev/dsp");
|
||||
|
||||
if (!devname)
|
||||
|
|
|
@ -99,7 +99,6 @@ new_fluid_pulse_audio_driver2(fluid_settings_t* settings,
|
|||
|
||||
FLUID_MEMSET(dev, 0, sizeof(fluid_pulse_audio_driver_t));
|
||||
|
||||
// fluid_settings_getint(settings, "audio.periods", &periods);
|
||||
fluid_settings_getint(settings, "audio.period-size", &period_size);
|
||||
fluid_settings_getnum(settings, "synth.sample-rate", &sample_rate);
|
||||
fluid_settings_dupstr(settings, "audio.pulseaudio.server", &server); /* ++ alloc server string */
|
||||
|
|
|
@ -132,7 +132,7 @@ new_fluid_winmidi_driver(fluid_settings_t* settings,
|
|||
dev->closing = FALSE;
|
||||
|
||||
/* get the device name. if none is specified, use the default device. */
|
||||
if(!fluid_settings_dupstr(settings, "midi.winmidi.device", &devname) || !devname) {
|
||||
if(fluid_settings_dupstr(settings, "midi.winmidi.device", &devname) != FLUID_OK || !devname) {
|
||||
devname = FLUID_STRDUP ("default");
|
||||
|
||||
if (!devname)
|
||||
|
|
|
@ -104,7 +104,7 @@ void process_o_cmd_line_option(fluid_settings_t* settings, char* optarg)
|
|||
|
||||
switch(fluid_settings_get_type(settings, optarg)){
|
||||
case FLUID_NUM_TYPE:
|
||||
if (!fluid_settings_setnum (settings, optarg, atof (val)))
|
||||
if (fluid_settings_setnum (settings, optarg, atof (val)) != FLUID_OK)
|
||||
{
|
||||
fprintf (stderr, "Failed to set floating point parameter '%s'\n", optarg);
|
||||
exit (1);
|
||||
|
@ -122,14 +122,14 @@ void process_o_cmd_line_option(fluid_settings_t* settings, char* optarg)
|
|||
}
|
||||
else ival = atoi (val);
|
||||
|
||||
if (!fluid_settings_setint (settings, optarg, ival))
|
||||
if (fluid_settings_setint (settings, optarg, ival) != FLUID_OK)
|
||||
{
|
||||
fprintf (stderr, "Failed to set integer parameter '%s'\n", optarg);
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
case FLUID_STR_TYPE:
|
||||
if (!fluid_settings_setstr (settings, optarg, val))
|
||||
if (fluid_settings_setstr (settings, optarg, val) != FLUID_OK)
|
||||
{
|
||||
fprintf (stderr, "Failed to set string parameter '%s'\n", optarg);
|
||||
exit (1);
|
||||
|
@ -712,7 +712,7 @@ int main(int argc, char** argv)
|
|||
if (fluid_synth_get_sfont(synth, 0) == NULL) {
|
||||
/* Try to load the default soundfont if no soundfont specified */
|
||||
char *s;
|
||||
if (fluid_settings_dupstr(settings, "synth.default-soundfont", &s) <= 0)
|
||||
if (fluid_settings_dupstr(settings, "synth.default-soundfont", &s) != FLUID_OK)
|
||||
s = NULL;
|
||||
if ((s != NULL) && (s[0] != '\0'))
|
||||
fluid_synth_sfload(synth, s, 1);
|
||||
|
@ -789,7 +789,7 @@ int main(int argc, char** argv)
|
|||
if (interactive) {
|
||||
fluid_player_stop(player);
|
||||
}
|
||||
if (adriver != NULL || !fluid_settings_str_equal(settings, "player.timing-source", "sample")) {
|
||||
if (adriver != NULL || fluid_settings_str_equal(settings, "player.timing-source", "sample") != FLUID_OK) {
|
||||
/* if no audio driver and sample timers are used, nothing makes the player advance */
|
||||
fluid_player_join(player);
|
||||
}
|
||||
|
|
|
@ -743,13 +743,13 @@ new_fluid_synth(fluid_settings_t *settings)
|
|||
}
|
||||
|
||||
synth->bank_select = FLUID_BANK_STYLE_GS;
|
||||
if (fluid_settings_str_equal (settings, "synth.midi-bank-select", "gm") == 1)
|
||||
if (fluid_settings_str_equal (settings, "synth.midi-bank-select", "gm"))
|
||||
synth->bank_select = FLUID_BANK_STYLE_GM;
|
||||
else if (fluid_settings_str_equal (settings, "synth.midi-bank-select", "gs") == 1)
|
||||
else if (fluid_settings_str_equal (settings, "synth.midi-bank-select", "gs"))
|
||||
synth->bank_select = FLUID_BANK_STYLE_GS;
|
||||
else if (fluid_settings_str_equal (settings, "synth.midi-bank-select", "xg") == 1)
|
||||
else if (fluid_settings_str_equal (settings, "synth.midi-bank-select", "xg"))
|
||||
synth->bank_select = FLUID_BANK_STYLE_XG;
|
||||
else if (fluid_settings_str_equal (settings, "synth.midi-bank-select", "mma") == 1)
|
||||
else if (fluid_settings_str_equal (settings, "synth.midi-bank-select", "mma"))
|
||||
synth->bank_select = FLUID_BANK_STYLE_MMA;
|
||||
|
||||
fluid_synth_process_event_queue(synth);
|
||||
|
|
Loading…
Reference in a new issue