mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-04-22 07:30:50 +00:00
Add functions to get all valid audio/midi driver names (fixes ticket #41)
This commit is contained in:
parent
4880b8e574
commit
76b598313a
5 changed files with 74 additions and 4 deletions
|
@ -65,6 +65,9 @@ FLUIDSYNTH_API fluid_audio_driver_t* new_fluid_audio_driver2(fluid_settings_t* s
|
|||
|
||||
FLUIDSYNTH_API void delete_fluid_audio_driver(fluid_audio_driver_t* driver);
|
||||
|
||||
FLUIDSYNTH_API void fluid_audio_driver_get_names(char* buf, size_t buflen, const char* separator);
|
||||
|
||||
|
||||
FLUIDSYNTH_API fluid_file_renderer_t* new_fluid_file_renderer(fluid_synth_t* synth,
|
||||
char* filename, int period_size);
|
||||
FLUIDSYNTH_API int fluid_file_renderer_process_block(fluid_file_renderer_t* dev);
|
||||
|
|
|
@ -93,6 +93,7 @@ fluid_midi_driver_t* new_fluid_midi_driver(fluid_settings_t* settings,
|
|||
|
||||
FLUIDSYNTH_API void delete_fluid_midi_driver(fluid_midi_driver_t* driver);
|
||||
|
||||
FLUIDSYNTH_API void fluid_midi_driver_get_names(char* buf, size_t buflen, const char* separator);
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -285,6 +285,34 @@ void fluid_audio_driver_settings(fluid_settings_t* settings)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a list of audio driver names into a buffer.
|
||||
* (A buffer length of 256 characters should be more than enough.)
|
||||
* @param buf buffert to write names into
|
||||
* @param buflen maximum amount of characters in buf.
|
||||
* @param separator separator string, written between names.
|
||||
* @since 1.1.0
|
||||
*/
|
||||
void
|
||||
fluid_audio_driver_get_names(char* buf, size_t buflen, const char* separator)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (buflen <= 0) {
|
||||
return;
|
||||
}
|
||||
buf[0] = '\0';
|
||||
buflen--;
|
||||
|
||||
for (i = 0; fluid_audio_drivers[i].name != NULL; i++) {
|
||||
if (i > 0) {
|
||||
strncat(buf, separator, buflen - strlen(buf));
|
||||
}
|
||||
strncat(buf, fluid_audio_drivers[i].name, buflen - strlen(buf));
|
||||
}
|
||||
buf[buflen] = '\0';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new audio driver.
|
||||
|
@ -302,6 +330,7 @@ new_fluid_audio_driver(fluid_settings_t* settings, fluid_synth_t* synth)
|
|||
int i;
|
||||
fluid_audio_driver_t* driver = NULL;
|
||||
char* name;
|
||||
char allnames[256];
|
||||
|
||||
fluid_settings_getstr(settings, "audio.driver", &name);
|
||||
|
||||
|
@ -316,7 +345,8 @@ new_fluid_audio_driver(fluid_settings_t* settings, fluid_synth_t* synth)
|
|||
}
|
||||
}
|
||||
|
||||
FLUID_LOG(FLUID_ERR, "Couldn't find the requested audio driver: %s", name);
|
||||
fluid_audio_driver_get_names(allnames, sizeof(allnames), ", ");
|
||||
FLUID_LOG(FLUID_ERR, "Couldn't find the requested audio driver %s. Valid drivers are: %s.", name, allnames);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -191,6 +191,35 @@ void fluid_midi_driver_settings(fluid_settings_t* settings)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write a list of midi driver names into a buffer.
|
||||
* (A buffer length of 256 characters should be more than enough.)
|
||||
* @param buf buffert to write names into
|
||||
* @param buflen maximum amount of characters in buf.
|
||||
* @param separator separator string, written between names.
|
||||
* @since 1.1.0
|
||||
*/
|
||||
void
|
||||
fluid_midi_driver_get_names(char* buf, size_t buflen, const char* separator)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (buflen <= 0) {
|
||||
return;
|
||||
}
|
||||
buf[0] = '\0';
|
||||
buflen--;
|
||||
|
||||
for (i = 0; fluid_midi_drivers[i].name != NULL; i++) {
|
||||
if (i > 0) {
|
||||
strncat(buf, separator, buflen - strlen(buf));
|
||||
}
|
||||
strncat(buf, fluid_midi_drivers[i].name, buflen - strlen(buf));
|
||||
}
|
||||
buf[buflen] = '\0';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new MIDI driver instance.
|
||||
* @param settings Settings used to configure new MIDI driver.
|
||||
|
@ -202,6 +231,7 @@ void fluid_midi_driver_settings(fluid_settings_t* settings)
|
|||
fluid_midi_driver_t* new_fluid_midi_driver(fluid_settings_t* settings, handle_midi_event_func_t handler, void* event_handler_data)
|
||||
{
|
||||
int i;
|
||||
char allnames[256];
|
||||
fluid_midi_driver_t* driver = NULL;
|
||||
for (i = 0; fluid_midi_drivers[i].name != NULL; i++) {
|
||||
if (fluid_settings_str_equal(settings, "midi.driver", fluid_midi_drivers[i].name)) {
|
||||
|
@ -214,7 +244,8 @@ fluid_midi_driver_t* new_fluid_midi_driver(fluid_settings_t* settings, handle_mi
|
|||
}
|
||||
}
|
||||
|
||||
FLUID_LOG(FLUID_ERR, "Couldn't find the requested midi driver");
|
||||
fluid_midi_driver_get_names(allnames, sizeof(allnames), ", ");
|
||||
FLUID_LOG(FLUID_ERR, "Couldn't find the requested midi driver. Valid drivers are: %s.", allnames);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -702,12 +702,15 @@ print_welcome()
|
|||
void
|
||||
print_help()
|
||||
{
|
||||
char allnames[256];
|
||||
print_welcome ();
|
||||
printf("Usage: \n");
|
||||
printf(" fluidsynth [options] [soundfonts] [midifiles]\n");
|
||||
printf("Possible options:\n");
|
||||
fluid_audio_driver_get_names(allnames, sizeof(allnames), ", ");
|
||||
printf(" -a, --audio-driver=[label]\n"
|
||||
" The audio driver [alsa,jack,oss,dsound,...]\n");
|
||||
" The name of the audio driver to use.\n"
|
||||
" Valid values: %s\n", allnames);
|
||||
printf(" -C, --chorus\n"
|
||||
" Turn the chorus on or off [0|1|yes|no, default = on]\n");
|
||||
printf(" -c, --audio-bufcount=[count]\n"
|
||||
|
@ -736,8 +739,10 @@ print_help()
|
|||
printf(" -l, --disable-lash\n"
|
||||
" Don't connect to LASH server\n");
|
||||
#endif
|
||||
fluid_midi_driver_get_names(allnames, sizeof(allnames), ", ");
|
||||
printf(" -m, --midi-driver=[label]\n"
|
||||
" The name of the midi driver to use [oss,alsa,alsa_seq,...]\n");
|
||||
" The name of the midi driver to use.\n"
|
||||
" Valid values: %s\n", allnames);
|
||||
printf(" -n, --no-midi-in\n"
|
||||
" Don't create a midi driver to read MIDI input events [default = yes]\n");
|
||||
printf(" -p, --portname=[label]\n"
|
||||
|
|
Loading…
Reference in a new issue