Module: wine Branch: master Commit: b25e1aefc7b868266042f842955a001618ef3b1d URL: http://source.winehq.org/git/wine.git/?a=commit;h=b25e1aefc7b868266042f84295...
Author: Andrew Eikum aeikum@codeweavers.com Date: Mon Aug 15 09:02:36 2016 -0500
Revert "dsound: Allow inactive devices to change the primary format.".
This reverts commit 4fbe6f3e7601f7b39f7f672ffe43553eee92ab1b.
Signed-off-by: Andrew Eikum aeikum@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/dsound/primary.c | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-)
diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c index 830764a..f9720f8 100644 --- a/dlls/dsound/primary.c +++ b/dlls/dsound/primary.c @@ -478,30 +478,35 @@ HRESULT primarybuffer_SetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX passe RtlAcquireResourceExclusive(&(device->buffer_list_lock), TRUE); EnterCriticalSection(&(device->mixlock));
- old_fmt = device->primary_pwfx; - device->primary_pwfx = DSOUND_CopyFormat(passed_fmt); - fmtex = (WAVEFORMATEXTENSIBLE *)device->primary_pwfx; - if (device->primary_pwfx == NULL) { - err = DSERR_OUTOFMEMORY; - goto out; - } + if (device->priolevel == DSSCL_WRITEPRIMARY) { + old_fmt = device->primary_pwfx; + device->primary_pwfx = DSOUND_CopyFormat(passed_fmt); + fmtex = (WAVEFORMATEXTENSIBLE *)device->primary_pwfx; + if (device->primary_pwfx == NULL) { + err = DSERR_OUTOFMEMORY; + goto out; + }
- if (fmtex->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE && - fmtex->Samples.wValidBitsPerSample == 0) { - TRACE("Correcting 0 valid bits per sample\n"); - fmtex->Samples.wValidBitsPerSample = fmtex->Format.wBitsPerSample; - } + if (fmtex->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE && + fmtex->Samples.wValidBitsPerSample == 0) { + TRACE("Correcting 0 valid bits per sample\n"); + fmtex->Samples.wValidBitsPerSample = fmtex->Format.wBitsPerSample; + }
- if(device->priolevel == DSSCL_WRITEPRIMARY || device->nrofbuffers == 0) err = DSOUND_ReopenDevice(device, TRUE); - if (FAILED(err) && device->priolevel == DSSCL_WRITEPRIMARY) { - ERR("No formats could be opened\n"); - HeapFree(GetProcessHeap(), 0, device->primary_pwfx); - device->primary_pwfx = old_fmt; + if (FAILED(err)) { + ERR("No formats could be opened\n"); + HeapFree(GetProcessHeap(), 0, device->primary_pwfx); + device->primary_pwfx = old_fmt; + } else + HeapFree(GetProcessHeap(), 0, old_fmt); } else { - /* ignore failures */ - err = S_OK; - HeapFree(GetProcessHeap(), 0, old_fmt); + WAVEFORMATEX *wfx = DSOUND_CopyFormat(passed_fmt); + if (wfx) { + HeapFree(GetProcessHeap(), 0, device->primary_pwfx); + device->primary_pwfx = wfx; + } else + err = DSERR_OUTOFMEMORY; }
out: