From bf263a347d904b01673ab19cd35927881255544d Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Thu, 14 Jun 2012 09:25:48 -0500 Subject: [PATCH] dsound: Fail if app requests 3D buffer interface on a non-3D buffer. --- dlls/dsound/buffer.c | 4 ++++ dlls/dsound/tests/ds3d.c | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c index 08f4ba7fb9b..caf1f864fae 100644 --- a/dlls/dsound/buffer.c +++ b/dlls/dsound/buffer.c @@ -764,9 +764,13 @@ static HRESULT WINAPI IDirectSoundBufferImpl_QueryInterface(IDirectSoundBuffer8 } if ( IsEqualGUID( &IID_IDirectSound3DBuffer, riid ) ) { + if(This->dsbd.dwFlags & DSBCAPS_CTRL3D){ IDirectSound3DBuffer_AddRef(&This->IDirectSound3DBuffer_iface); *ppobj = &This->IDirectSound3DBuffer_iface; return S_OK; + } + TRACE("app requested IDirectSound3DBuffer on non-3D secondary buffer\n"); + return E_NOINTERFACE; } if ( IsEqualGUID( &IID_IDirectSound3DListener, riid ) ) { diff --git a/dlls/dsound/tests/ds3d.c b/dlls/dsound/tests/ds3d.c index 0fbbfe87ce0..86099bfa571 100644 --- a/dlls/dsound/tests/ds3d.c +++ b/dlls/dsound/tests/ds3d.c @@ -801,7 +801,7 @@ static HRESULT test_secondary(LPGUID lpGuid, int play, ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2; - if (has_3d) + if (has_3dbuffer) bufdesc.dwFlags|=DSBCAPS_CTRL3D; else bufdesc.dwFlags|= @@ -833,6 +833,14 @@ static HRESULT test_secondary(LPGUID lpGuid, int play, wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels, getDSBCAPS(bufdesc.dwFlags),rc); if (rc==DS_OK && secondary!=NULL) { + IDirectSound3DBuffer *ds3d; + + rc=IDirectSoundBuffer_QueryInterface(secondary, &IID_IDirectSound3DBuffer, (void**)&ds3d); + ok((has_3dbuffer && rc==DS_OK) || (!has_3dbuffer && rc==E_NOINTERFACE), + "Wrong return trying to get 3D buffer on %s3D secondary interface: %08x\n", has_3dbuffer ? "" : "non-", rc); + if(rc==DS_OK) + IDirectSound3DBuffer_Release(ds3d); + if (!has_3d) { LONG refvol,vol,refpan,pan;