mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-03-02 07:21:58 +00:00
Revision of the overhauled PortAudio driver.
* Use the name "PortAudio" everywhere * Default device name: "PortAudio Default" solves the clash with the ALSA "default" device. * enumerate only devices with 2 or more output channels available (ignore input only devices) * use Pa_GetDefaultOutputDevice() instead of 0 for the default device index * assign the device index for the requested device name when it matches one.
This commit is contained in:
parent
f0a5100f2c
commit
ecd0da8ba9
1 changed files with 17 additions and 11 deletions
|
@ -27,7 +27,7 @@
|
||||||
* 12/20/01 Adapdation for new audio drivers
|
* 12/20/01 Adapdation for new audio drivers
|
||||||
*
|
*
|
||||||
* Josh Green <jgreen@users.sourceforge.net>
|
* Josh Green <jgreen@users.sourceforge.net>
|
||||||
* 2009-01-28 Overhauled for Portaudio 19 API and current FluidSynth API (was broken)
|
* 2009-01-28 Overhauled for PortAudio 19 API and current FluidSynth API (was broken)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "fluid_synth.h"
|
#include "fluid_synth.h"
|
||||||
|
@ -62,6 +62,7 @@ fluid_portaudio_run (const void *input, void *output, unsigned long frameCount,
|
||||||
PaStreamCallbackFlags statusFlags, void *userData);
|
PaStreamCallbackFlags statusFlags, void *userData);
|
||||||
int delete_fluid_portaudio_driver (fluid_audio_driver_t *p);
|
int delete_fluid_portaudio_driver (fluid_audio_driver_t *p);
|
||||||
|
|
||||||
|
#define PORTAUDIO_DEFAULT_DEVICE "PortAudio Default"
|
||||||
|
|
||||||
void
|
void
|
||||||
fluid_portaudio_driver_settings (fluid_settings_t *settings)
|
fluid_portaudio_driver_settings (fluid_settings_t *settings)
|
||||||
|
@ -71,14 +72,14 @@ fluid_portaudio_driver_settings (fluid_settings_t *settings)
|
||||||
PaError err;
|
PaError err;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
fluid_settings_register_str (settings, "audio.portaudio.device", "default", 0, NULL, NULL);
|
fluid_settings_register_str (settings, "audio.portaudio.device", PORTAUDIO_DEFAULT_DEVICE, 0, NULL, NULL);
|
||||||
fluid_settings_add_option (settings, "audio.portaudio.device", "default");
|
fluid_settings_add_option (settings, "audio.portaudio.device", PORTAUDIO_DEFAULT_DEVICE);
|
||||||
|
|
||||||
err = Pa_Initialize();
|
err = Pa_Initialize();
|
||||||
|
|
||||||
if (err != paNoError)
|
if (err != paNoError)
|
||||||
{
|
{
|
||||||
FLUID_LOG (FLUID_ERR, "Error initializing Portaudio driver: %s",
|
FLUID_LOG (FLUID_ERR, "Error initializing PortAudio driver: %s",
|
||||||
Pa_GetErrorText (err));
|
Pa_GetErrorText (err));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -94,8 +95,9 @@ fluid_portaudio_driver_settings (fluid_settings_t *settings)
|
||||||
for (i = 0; i < numDevices; i++)
|
for (i = 0; i < numDevices; i++)
|
||||||
{
|
{
|
||||||
deviceInfo = Pa_GetDeviceInfo (i);
|
deviceInfo = Pa_GetDeviceInfo (i);
|
||||||
fluid_settings_add_option (settings, "audio.portaudio.device",
|
if ( deviceInfo->maxOutputChannels >= 2 )
|
||||||
(char *)(deviceInfo->name));
|
fluid_settings_add_option (settings, "audio.portaudio.device",
|
||||||
|
(char *)(deviceInfo->name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +132,7 @@ new_fluid_portaudio_driver (fluid_settings_t *settings, fluid_synth_t *synth)
|
||||||
outputParams.suggestedLatency = (PaTime)period_size / sample_rate;
|
outputParams.suggestedLatency = (PaTime)period_size / sample_rate;
|
||||||
|
|
||||||
/* Locate the device if specified */
|
/* Locate the device if specified */
|
||||||
if (strcmp (device, "default") != 0)
|
if (strcmp (device, PORTAUDIO_DEFAULT_DEVICE) != 0)
|
||||||
{
|
{
|
||||||
const PaDeviceInfo *deviceInfo;
|
const PaDeviceInfo *deviceInfo;
|
||||||
int numDevices;
|
int numDevices;
|
||||||
|
@ -148,7 +150,11 @@ new_fluid_portaudio_driver (fluid_settings_t *settings, fluid_synth_t *synth)
|
||||||
{
|
{
|
||||||
deviceInfo = Pa_GetDeviceInfo (i);
|
deviceInfo = Pa_GetDeviceInfo (i);
|
||||||
|
|
||||||
if (strcmp (device, deviceInfo->name) == 0) break;
|
if (strcmp (device, deviceInfo->name) == 0)
|
||||||
|
{
|
||||||
|
outputParams.device = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == numDevices)
|
if (i == numDevices)
|
||||||
|
@ -157,7 +163,7 @@ new_fluid_portaudio_driver (fluid_settings_t *settings, fluid_synth_t *synth)
|
||||||
goto error_recovery;
|
goto error_recovery;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else outputParams.device = 0;
|
else outputParams.device = Pa_GetDefaultOutputDevice();
|
||||||
|
|
||||||
if (fluid_settings_str_equal (settings, "audio.sample-format", "16bits"))
|
if (fluid_settings_str_equal (settings, "audio.sample-format", "16bits"))
|
||||||
{
|
{
|
||||||
|
@ -189,7 +195,7 @@ new_fluid_portaudio_driver (fluid_settings_t *settings, fluid_synth_t *synth)
|
||||||
|
|
||||||
if (err != paNoError)
|
if (err != paNoError)
|
||||||
{
|
{
|
||||||
FLUID_LOG (FLUID_ERR, "Error opening Portaudio stream: %s",
|
FLUID_LOG (FLUID_ERR, "Error opening PortAudio stream: %s",
|
||||||
Pa_GetErrorText (err));
|
Pa_GetErrorText (err));
|
||||||
goto error_recovery;
|
goto error_recovery;
|
||||||
}
|
}
|
||||||
|
@ -198,7 +204,7 @@ new_fluid_portaudio_driver (fluid_settings_t *settings, fluid_synth_t *synth)
|
||||||
|
|
||||||
if (err != paNoError)
|
if (err != paNoError)
|
||||||
{
|
{
|
||||||
FLUID_LOG (FLUID_ERR, "Error starting Portaudio stream: %s",
|
FLUID_LOG (FLUID_ERR, "Error starting PortAudio stream: %s",
|
||||||
Pa_GetErrorText (err));
|
Pa_GetErrorText (err));
|
||||||
goto error_recovery;
|
goto error_recovery;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue