From e0966d99a199ec1b4673609e2f91c5ebc7b776af Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 17 Jan 2012 15:26:22 -0800 Subject: Retry opening the PortAudio device with 16-bit short if 32-bit float output fails --- Alc/backends/portaudio.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'Alc/backends/portaudio.c') diff --git a/Alc/backends/portaudio.c b/Alc/backends/portaudio.c index 4275ad80..a24e2aaf 100644 --- a/Alc/backends/portaudio.c +++ b/Alc/backends/portaudio.c @@ -175,6 +175,9 @@ static ALCenum pa_open_playback(ALCdevice *device, const ALCchar *deviceName) (float)device->Frequency; outParams.hostApiSpecificStreamInfo = NULL; + outParams.channelCount = ((device->FmtChans == DevFmtMono) ? 1 : 2); + +retry_open: switch(device->FmtType) { case DevFmtByte: @@ -193,14 +196,16 @@ static ALCenum pa_open_playback(ALCdevice *device, const ALCchar *deviceName) outParams.sampleFormat = paFloat32; break; } - outParams.channelCount = ((device->FmtChans == DevFmtMono) ? 1 : 2); - - SetDefaultChannelOrder(device); err = Pa_OpenStream(&data->stream, NULL, &outParams, device->Frequency, device->UpdateSize, paNoFlag, pa_callback, device); if(err != paNoError) { + if(device->FmtType == DevFmtFloat) + { + device->FmtType = DevFmtShort; + goto retry_open; + } ERR("Pa_OpenStream() returned an error: %s\n", Pa_GetErrorText(err)); device->ExtraData = NULL; free(data); @@ -224,6 +229,7 @@ static ALCenum pa_open_playback(ALCdevice *device, const ALCchar *deviceName) device->Flags &= ~DEVICE_CHANNELS_REQUEST; device->FmtChans = ((outParams.channelCount==1) ? DevFmtMono : DevFmtStereo); } + SetDefaultChannelOrder(device); return ALC_NO_ERROR; } -- cgit v1.2.3