mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-04-18 21:51:22 +00:00
Simplify audio driver installation
In my opionion, it should be possible to simplify the code by installing the drivers with a for() cycle instead of doing tons of #ifdef...#endif. The size of the binary code is basically the same as before, but the source lines are much less. I think that it could be done also for MIDI input drivers.
This commit is contained in:
parent
670cdf1e8f
commit
70f4551e90
1 changed files with 33 additions and 77 deletions
|
@ -59,16 +59,6 @@ static const fluid_audriver_definition_t fluid_audio_drivers[] =
|
|||
},
|
||||
#endif
|
||||
|
||||
#if OSS_SUPPORT
|
||||
{
|
||||
"oss",
|
||||
new_fluid_oss_audio_driver,
|
||||
new_fluid_oss_audio_driver2,
|
||||
delete_fluid_oss_audio_driver,
|
||||
fluid_oss_audio_driver_settings
|
||||
},
|
||||
#endif
|
||||
|
||||
#if PULSE_SUPPORT
|
||||
{
|
||||
"pulseaudio",
|
||||
|
@ -79,6 +69,16 @@ static const fluid_audriver_definition_t fluid_audio_drivers[] =
|
|||
},
|
||||
#endif
|
||||
|
||||
#if OSS_SUPPORT
|
||||
{
|
||||
"oss",
|
||||
new_fluid_oss_audio_driver,
|
||||
new_fluid_oss_audio_driver2,
|
||||
delete_fluid_oss_audio_driver,
|
||||
fluid_oss_audio_driver_settings
|
||||
},
|
||||
#endif
|
||||
|
||||
#if COREAUDIO_SUPPORT
|
||||
{
|
||||
"coreaudio",
|
||||
|
@ -99,16 +99,6 @@ static const fluid_audriver_definition_t fluid_audio_drivers[] =
|
|||
},
|
||||
#endif
|
||||
|
||||
#if PORTAUDIO_SUPPORT
|
||||
{
|
||||
"portaudio",
|
||||
new_fluid_portaudio_driver,
|
||||
NULL,
|
||||
delete_fluid_portaudio_driver,
|
||||
fluid_portaudio_driver_settings
|
||||
},
|
||||
#endif
|
||||
|
||||
#if SNDMAN_SUPPORT
|
||||
{
|
||||
"sndman",
|
||||
|
@ -119,6 +109,16 @@ static const fluid_audriver_definition_t fluid_audio_drivers[] =
|
|||
},
|
||||
#endif
|
||||
|
||||
#if PORTAUDIO_SUPPORT
|
||||
{
|
||||
"portaudio",
|
||||
new_fluid_portaudio_driver,
|
||||
NULL,
|
||||
delete_fluid_portaudio_driver,
|
||||
fluid_portaudio_driver_settings
|
||||
},
|
||||
#endif
|
||||
|
||||
#if DART_SUPPORT
|
||||
{
|
||||
"dart",
|
||||
|
@ -153,6 +153,7 @@ static uint8_t fluid_adriver_disable_mask[(FLUID_N_ELEMENTS(fluid_audio_drivers)
|
|||
void fluid_audio_driver_settings(fluid_settings_t *settings)
|
||||
{
|
||||
unsigned int i;
|
||||
const char *def_name = NULL;
|
||||
|
||||
fluid_settings_register_str(settings, "audio.sample-format", "16bits", 0);
|
||||
fluid_settings_add_option(settings, "audio.sample-format", "16bits");
|
||||
|
@ -172,71 +173,26 @@ void fluid_audio_driver_settings(fluid_settings_t *settings)
|
|||
fluid_settings_register_int(settings, "audio.realtime-prio",
|
||||
FLUID_DEFAULT_AUDIO_RT_PRIO, 0, 99, 0);
|
||||
|
||||
/* Set the default driver */
|
||||
#if JACK_SUPPORT
|
||||
fluid_settings_register_str(settings, "audio.driver", "jack", 0);
|
||||
#elif ALSA_SUPPORT
|
||||
fluid_settings_register_str(settings, "audio.driver", "alsa", 0);
|
||||
#elif PULSE_SUPPORT
|
||||
fluid_settings_register_str(settings, "audio.driver", "pulseaudio", 0);
|
||||
#elif OSS_SUPPORT
|
||||
fluid_settings_register_str(settings, "audio.driver", "oss", 0);
|
||||
#elif COREAUDIO_SUPPORT
|
||||
fluid_settings_register_str(settings, "audio.driver", "coreaudio", 0);
|
||||
#elif DSOUND_SUPPORT
|
||||
fluid_settings_register_str(settings, "audio.driver", "dsound", 0);
|
||||
#elif SNDMAN_SUPPORT
|
||||
fluid_settings_register_str(settings, "audio.driver", "sndman", 0);
|
||||
#elif PORTAUDIO_SUPPORT
|
||||
fluid_settings_register_str(settings, "audio.driver", "portaudio", 0);
|
||||
#elif DART_SUPPORT
|
||||
fluid_settings_register_str(settings, "audio.driver", "dart", 0);
|
||||
#elif AUFILE_SUPPORT
|
||||
fluid_settings_register_str(settings, "audio.driver", "file", 0);
|
||||
#else
|
||||
fluid_settings_register_str(settings, "audio.driver", "", 0);
|
||||
#endif
|
||||
|
||||
/* Add all drivers to the list of options */
|
||||
#if PULSE_SUPPORT
|
||||
fluid_settings_add_option(settings, "audio.driver", "pulseaudio");
|
||||
#endif
|
||||
#if ALSA_SUPPORT
|
||||
fluid_settings_add_option(settings, "audio.driver", "alsa");
|
||||
#endif
|
||||
#if OSS_SUPPORT
|
||||
fluid_settings_add_option(settings, "audio.driver", "oss");
|
||||
#endif
|
||||
#if COREAUDIO_SUPPORT
|
||||
fluid_settings_add_option(settings, "audio.driver", "coreaudio");
|
||||
#endif
|
||||
#if DSOUND_SUPPORT
|
||||
fluid_settings_add_option(settings, "audio.driver", "dsound");
|
||||
#endif
|
||||
#if SNDMAN_SUPPORT
|
||||
fluid_settings_add_option(settings, "audio.driver", "sndman");
|
||||
#endif
|
||||
#if PORTAUDIO_SUPPORT
|
||||
fluid_settings_add_option(settings, "audio.driver", "portaudio");
|
||||
#endif
|
||||
#if JACK_SUPPORT
|
||||
fluid_settings_add_option(settings, "audio.driver", "jack");
|
||||
#endif
|
||||
#if DART_SUPPORT
|
||||
fluid_settings_add_option(settings, "audio.driver", "dart");
|
||||
#endif
|
||||
#if AUFILE_SUPPORT
|
||||
fluid_settings_add_option(settings, "audio.driver", "file");
|
||||
#endif
|
||||
|
||||
for(i = 0; i < FLUID_N_ELEMENTS(fluid_audio_drivers) - 1; i++)
|
||||
{
|
||||
/* Select the default driver */
|
||||
if (def_name == NULL)
|
||||
{
|
||||
def_name = fluid_audio_drivers[i].name;
|
||||
}
|
||||
|
||||
/* Add the driver to the list of options */
|
||||
fluid_settings_add_option(settings, "audio.driver", fluid_audio_drivers[i].name);
|
||||
|
||||
if(fluid_audio_drivers[i].settings != NULL &&
|
||||
IS_AUDIO_DRIVER_ENABLED(fluid_adriver_disable_mask, i))
|
||||
{
|
||||
fluid_audio_drivers[i].settings(settings);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the default driver */
|
||||
fluid_settings_register_str(settings, "audio.driver", def_name ? def_name : "", 0);
|
||||
}
|
||||
|
||||
static const fluid_audriver_definition_t *
|
||||
|
|
Loading…
Reference in a new issue