dsound: Pretend we have hardware buffers.

When running in Windows XP mode, XAudio2 will refuse to output surround sound
unless it can open a buffer with DSBCAPS_LOCHARDWARE.
This commit is contained in:
Mark Harmstone 2015-01-11 21:42:44 +00:00 committed by Alexandre Julliard
parent b5aec2e40f
commit d4d14cdef0
2 changed files with 26 additions and 9 deletions

View File

@ -994,6 +994,9 @@ void secondarybuffer_destroy(IDirectSoundBufferImpl *This)
if (ref > 1) if (ref > 1)
WARN("Destroying buffer with %u in use interfaces\n", ref - 1); WARN("Destroying buffer with %u in use interfaces\n", ref - 1);
if (This->dsbd.dwFlags & DSBCAPS_LOCHARDWARE)
This->device->drvcaps.dwFreeHwMixingAllBuffers++;
DirectSoundDevice_RemoveBuffer(This->device, This); DirectSoundDevice_RemoveBuffer(This->device, This);
RtlDeleteResource(&This->lock); RtlDeleteResource(&This->lock);

View File

@ -271,8 +271,15 @@ static HRESULT WINAPI IDirectSound8Impl_GetCaps(IDirectSound8 *iface, DSCAPS *ds
dscaps->dwMaxHwMixingStaticBuffers = This->device->drvcaps.dwMaxHwMixingStaticBuffers; dscaps->dwMaxHwMixingStaticBuffers = This->device->drvcaps.dwMaxHwMixingStaticBuffers;
dscaps->dwMaxHwMixingStreamingBuffers = This->device->drvcaps.dwMaxHwMixingStreamingBuffers; dscaps->dwMaxHwMixingStreamingBuffers = This->device->drvcaps.dwMaxHwMixingStreamingBuffers;
dscaps->dwFreeHwMixingAllBuffers = This->device->drvcaps.dwFreeHwMixingAllBuffers; dscaps->dwFreeHwMixingAllBuffers = This->device->drvcaps.dwFreeHwMixingAllBuffers;
dscaps->dwFreeHwMixingStaticBuffers = This->device->drvcaps.dwFreeHwMixingStaticBuffers;
dscaps->dwFreeHwMixingStreamingBuffers = This->device->drvcaps.dwFreeHwMixingStreamingBuffers; if (This->device->drvcaps.dwFreeHwMixingAllBuffers > 0) {
dscaps->dwFreeHwMixingStaticBuffers = This->device->drvcaps.dwFreeHwMixingStaticBuffers;
dscaps->dwFreeHwMixingStreamingBuffers = This->device->drvcaps.dwFreeHwMixingStreamingBuffers;
} else {
dscaps->dwFreeHwMixingStaticBuffers = 0;
dscaps->dwFreeHwMixingStreamingBuffers = 0;
}
dscaps->dwMaxHw3DAllBuffers = This->device->drvcaps.dwMaxHw3DAllBuffers; dscaps->dwMaxHw3DAllBuffers = This->device->drvcaps.dwMaxHw3DAllBuffers;
dscaps->dwMaxHw3DStaticBuffers = This->device->drvcaps.dwMaxHw3DStaticBuffers; dscaps->dwMaxHw3DStaticBuffers = This->device->drvcaps.dwMaxHw3DStaticBuffers;
dscaps->dwMaxHw3DStreamingBuffers = This->device->drvcaps.dwMaxHw3DStreamingBuffers; dscaps->dwMaxHw3DStreamingBuffers = This->device->drvcaps.dwMaxHw3DStreamingBuffers;
@ -913,9 +920,12 @@ HRESULT DirectSoundDevice_Initialize(DirectSoundDevice ** ppDevice, LPCGUID lpcG
device->drvcaps.dwPrimaryBuffers = 1; device->drvcaps.dwPrimaryBuffers = 1;
device->drvcaps.dwMinSecondarySampleRate = DSBFREQUENCY_MIN; device->drvcaps.dwMinSecondarySampleRate = DSBFREQUENCY_MIN;
device->drvcaps.dwMaxSecondarySampleRate = DSBFREQUENCY_MAX; device->drvcaps.dwMaxSecondarySampleRate = DSBFREQUENCY_MAX;
device->drvcaps.dwMaxHwMixingAllBuffers = 1; device->drvcaps.dwMaxHwMixingAllBuffers = 16;
device->drvcaps.dwMaxHwMixingStaticBuffers = 1; device->drvcaps.dwMaxHwMixingStaticBuffers = 1;
device->drvcaps.dwMaxHwMixingStreamingBuffers = 1; device->drvcaps.dwMaxHwMixingStreamingBuffers = 1;
device->drvcaps.dwFreeHwMixingAllBuffers = device->drvcaps.dwMaxHwMixingAllBuffers;
device->drvcaps.dwFreeHwMixingStaticBuffers = device->drvcaps.dwMaxHwMixingStaticBuffers;
device->drvcaps.dwFreeHwMixingStreamingBuffers = device->drvcaps.dwMaxHwMixingStreamingBuffers;
ZeroMemory(&device->volpan, sizeof(device->volpan)); ZeroMemory(&device->volpan, sizeof(device->volpan));
@ -975,10 +985,12 @@ HRESULT DirectSoundDevice_CreateSoundBuffer(
TRACE("(lpwfxFormat=%p)\n",dsbd->lpwfxFormat); TRACE("(lpwfxFormat=%p)\n",dsbd->lpwfxFormat);
} }
if (dsbd->dwFlags & DSBCAPS_LOCHARDWARE && if (!(dsbd->dwFlags & DSBCAPS_PRIMARYBUFFER) &&
!(dsbd->dwFlags & DSBCAPS_PRIMARYBUFFER)) { dsbd->dwFlags & DSBCAPS_LOCHARDWARE &&
TRACE("LOCHARDWARE is not supported, returning E_NOTIMPL\n"); device->drvcaps.dwFreeHwMixingAllBuffers == 0)
return E_NOTIMPL; {
WARN("ran out of emulated hardware buffers\n");
return DSERR_ALLOCATED;
} }
if (dsbd->dwFlags & DSBCAPS_PRIMARYBUFFER) { if (dsbd->dwFlags & DSBCAPS_PRIMARYBUFFER) {
@ -1062,9 +1074,11 @@ HRESULT DirectSoundDevice_CreateSoundBuffer(
} }
hres = IDirectSoundBufferImpl_Create(device, &dsb, dsbd); hres = IDirectSoundBufferImpl_Create(device, &dsb, dsbd);
if (dsb) if (dsb) {
*ppdsb = (IDirectSoundBuffer*)&dsb->IDirectSoundBuffer8_iface; *ppdsb = (IDirectSoundBuffer*)&dsb->IDirectSoundBuffer8_iface;
else if (dsbd->dwFlags & DSBCAPS_LOCHARDWARE)
device->drvcaps.dwFreeHwMixingAllBuffers--;
} else
WARN("IDirectSoundBufferImpl_Create failed\n"); WARN("IDirectSoundBufferImpl_Create failed\n");
} }