dsound: Allow inactive devices to change the primary format.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
49aacb4784
commit
4fbe6f3e76
|
@ -479,7 +479,6 @@ HRESULT primarybuffer_SetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX passe
|
||||||
RtlAcquireResourceExclusive(&(device->buffer_list_lock), TRUE);
|
RtlAcquireResourceExclusive(&(device->buffer_list_lock), TRUE);
|
||||||
EnterCriticalSection(&(device->mixlock));
|
EnterCriticalSection(&(device->mixlock));
|
||||||
|
|
||||||
if (device->priolevel == DSSCL_WRITEPRIMARY) {
|
|
||||||
old_fmt = device->primary_pwfx;
|
old_fmt = device->primary_pwfx;
|
||||||
device->primary_pwfx = DSOUND_CopyFormat(passed_fmt);
|
device->primary_pwfx = DSOUND_CopyFormat(passed_fmt);
|
||||||
fmtex = (WAVEFORMATEXTENSIBLE *)device->primary_pwfx;
|
fmtex = (WAVEFORMATEXTENSIBLE *)device->primary_pwfx;
|
||||||
|
@ -494,20 +493,16 @@ HRESULT primarybuffer_SetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX passe
|
||||||
fmtex->Samples.wValidBitsPerSample = fmtex->Format.wBitsPerSample;
|
fmtex->Samples.wValidBitsPerSample = fmtex->Format.wBitsPerSample;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(device->priolevel == DSSCL_WRITEPRIMARY || device->nrofbuffers == 0)
|
||||||
err = DSOUND_ReopenDevice(device, TRUE);
|
err = DSOUND_ReopenDevice(device, TRUE);
|
||||||
if (FAILED(err)) {
|
if (FAILED(err) && device->priolevel == DSSCL_WRITEPRIMARY) {
|
||||||
ERR("No formats could be opened\n");
|
ERR("No formats could be opened\n");
|
||||||
HeapFree(GetProcessHeap(), 0, device->primary_pwfx);
|
HeapFree(GetProcessHeap(), 0, device->primary_pwfx);
|
||||||
device->primary_pwfx = old_fmt;
|
device->primary_pwfx = old_fmt;
|
||||||
} else
|
|
||||||
HeapFree(GetProcessHeap(), 0, old_fmt);
|
|
||||||
} else {
|
} else {
|
||||||
WAVEFORMATEX *wfx = DSOUND_CopyFormat(passed_fmt);
|
/* ignore failures */
|
||||||
if (wfx) {
|
err = S_OK;
|
||||||
HeapFree(GetProcessHeap(), 0, device->primary_pwfx);
|
HeapFree(GetProcessHeap(), 0, old_fmt);
|
||||||
device->primary_pwfx = wfx;
|
|
||||||
} else
|
|
||||||
err = DSERR_OUTOFMEMORY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
Loading…
Reference in New Issue