[PATCH v2] dsound: IDirectSoundNotify is only available when DSBCAPS_CTRLPOSITIONNOTIFY is specified.

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Tue Feb 12 19:56:16 CST 2019


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45473
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
---
 dlls/dsound/buffer.c       |  9 +++++++--
 dlls/dsound/tests/dsound.c | 13 +++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c
index 5262628528..2a328ed32a 100644
--- a/dlls/dsound/buffer.c
+++ b/dlls/dsound/buffer.c
@@ -923,11 +923,16 @@ static HRESULT WINAPI IDirectSoundBufferImpl_QueryInterface(IDirectSoundBuffer8
                 return S_OK;
 	}
 
-	if ( IsEqualGUID( &IID_IDirectSoundNotify, riid ) ) {
+        if ( IsEqualGUID( &IID_IDirectSoundNotify, riid ) ) {
+            if(This->dsbd.dwFlags & DSBCAPS_CTRLPOSITIONNOTIFY) {
                 IDirectSoundNotify_AddRef(&This->IDirectSoundNotify_iface);
                 *ppobj = &This->IDirectSoundNotify_iface;
                 return S_OK;
-	}
+            }
+
+            TRACE( "App requested IDirectSoundNotify without DSBCAPS_CTRLPOSITIONNOTIFY flag.\n");
+            return E_NOINTERFACE;
+        }
 
 	if ( IsEqualGUID( &IID_IDirectSound3DBuffer, riid ) ) {
             if(This->dsbd.dwFlags & DSBCAPS_CTRL3D){
diff --git a/dlls/dsound/tests/dsound.c b/dlls/dsound/tests/dsound.c
index 89f0aa03ff..41818deb17 100644
--- a/dlls/dsound/tests/dsound.c
+++ b/dlls/dsound/tests/dsound.c
@@ -1561,6 +1561,19 @@ static void test_notifications(LPGUID lpGuid)
     wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
     wfx.cbSize = 0;
 
+    ZeroMemory(&bufdesc, sizeof(bufdesc));
+    bufdesc.dwSize = sizeof(bufdesc);
+    bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2;
+    bufdesc.dwBufferBytes = wfx.nSamplesPerSec * wfx.nBlockAlign / 2; /* 0.5s */
+    bufdesc.lpwfxFormat = &wfx;
+    rc = IDirectSound_CreateSoundBuffer(dso, &bufdesc, &buf, NULL);
+    ok(rc == DS_OK && buf != NULL, "IDirectSound_CreateSoundBuffer() failed "
+           "to create a buffer %08x\n", rc);
+
+    rc = IDirectSoundBuffer_QueryInterface(buf, &IID_IDirectSoundNotify, (void**)&buf_notif);
+    ok(rc == E_NOINTERFACE, "QueryInterface(IID_IDirectSoundNotify): %08x\n", rc);
+    IDirectSoundBuffer_Release(buf);
+
     ZeroMemory(&bufdesc, sizeof(bufdesc));
     bufdesc.dwSize = sizeof(bufdesc);
     bufdesc.dwFlags = DSBCAPS_CTRLPOSITIONNOTIFY;
-- 
2.20.1




More information about the wine-devel mailing list