From 66a700729bf3590a11807e4df5ef82c5e2c3d336 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 17 Jan 2012 12:38:47 -0800 Subject: Retry opening the DSound device with 16-bit short if 32-bit float output fails --- Alc/backends/dsound.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Alc') diff --git a/Alc/backends/dsound.c b/Alc/backends/dsound.c index f1dd0762..371c1045 100644 --- a/Alc/backends/dsound.c +++ b/Alc/backends/dsound.c @@ -421,6 +421,8 @@ static ALCboolean DSoundResetPlayback(ALCdevice *device) break; } +retry_open: + hr = S_OK; OutputType.Format.wFormatTag = WAVE_FORMAT_PCM; OutputType.Format.nChannels = ChannelsFromDevFmt(device->FmtChans); OutputType.Format.wBitsPerSample = BytesFromDevFmt(device->FmtType) * 8; @@ -439,6 +441,10 @@ static ALCboolean DSoundResetPlayback(ALCdevice *device) OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; else OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; + + if(pData->DSpbuffer) + IDirectSoundBuffer_Release(pData->DSpbuffer); + pData->DSpbuffer = NULL; } else { @@ -469,6 +475,11 @@ static ALCboolean DSoundResetPlayback(ALCdevice *device) OutputType.Format.nBlockAlign; DSBDescription.lpwfxFormat=&OutputType.Format; hr = IDirectSound_CreateSoundBuffer(pData->lpDS, &DSBDescription, &pData->DSsbuffer, NULL); + if(FAILED(hr) && device->FmtType == DevFmtFloat) + { + device->FmtType = DevFmtShort; + goto retry_open; + } } if(SUCCEEDED(hr)) -- cgit v1.2.3