Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45473 Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/dsound/buffer.c | 16 +++++++++++----- dlls/dsound/tests/dsound.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 5 deletions(-)
diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c index 5262628..e54ba57 100644 --- a/dlls/dsound/buffer.c +++ b/dlls/dsound/buffer.c @@ -923,11 +923,17 @@ static HRESULT WINAPI IDirectSoundBufferImpl_QueryInterface(IDirectSoundBuffer8 return S_OK; }
- if ( IsEqualGUID( &IID_IDirectSoundNotify, riid ) ) { - IDirectSoundNotify_AddRef(&This->IDirectSoundNotify_iface); - *ppobj = &This->IDirectSoundNotify_iface; - return S_OK; - } + 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 89f0aa0..5818ca1 100644 --- a/dlls/dsound/tests/dsound.c +++ b/dlls/dsound/tests/dsound.c @@ -1607,6 +1607,52 @@ static void test_notifications(LPGUID lpGuid) IDirectSound_Release(dso); }
+static void test_notifications_interface(LPGUID lpGuid) +{ + HRESULT rc; + IDirectSound *dso; + IDirectSoundBuffer *buf; + IDirectSoundNotify *notify; + DSBUFFERDESC bufdesc; + WAVEFORMATEX wfx; + + rc = pDirectSoundCreate(lpGuid, &dso, NULL); + ok(rc == DS_OK || rc == DSERR_NODRIVER || rc == DSERR_ALLOCATED, + "DirectSoundCreate() failed: %08x\n", rc); + if(rc != DS_OK) + return; + + rc = IDirectSound_SetCooperativeLevel(dso, get_hwnd(), DSSCL_PRIORITY); + ok(rc == DS_OK, "IDirectSound_SetCooperativeLevel() failed: %08x\n", rc); + if(rc != DS_OK){ + IDirectSound_Release(dso); + return; + } + + wfx.wFormatTag = WAVE_FORMAT_PCM; + wfx.nChannels = 1; + wfx.nSamplesPerSec = 44100; + wfx.wBitsPerSample = 16; + wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8; + 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**)¬ify); + ok(rc == E_NOINTERFACE, "QueryInterface(IID_IDirectSoundNotify): %08x\n", rc); + + IDirectSoundBuffer_Release(buf); + IDirectSound_Release(dso); +} + static unsigned int number;
static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, @@ -1638,6 +1684,7 @@ static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, test_duplicate(lpGuid); test_invalid_fmts(lpGuid); test_notifications(lpGuid); + test_notifications_interface(lpGuid); }
return TRUE;
On Mon, Feb 11, 2019 at 09:38:27PM +0000, Alistair Leslie-Hughes wrote:
diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c index 5262628..e54ba57 100644 --- a/dlls/dsound/buffer.c +++ b/dlls/dsound/buffer.c @@ -923,11 +923,17 @@ static HRESULT WINAPI IDirectSoundBufferImpl_QueryInterface(IDirectSoundBuffer8 return S_OK; }
- if ( IsEqualGUID( &IID_IDirectSoundNotify, riid ) ) {
IDirectSoundNotify_AddRef(&This->IDirectSoundNotify_iface);
*ppobj = &This->IDirectSoundNotify_iface;
return S_OK;
- }
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){
I know it's already a mess, but please try to match the existing formatting a little closer (initial indent is 8 characters wide, braces on same line as if-statement).
static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, @@ -1638,6 +1684,7 @@ static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, test_duplicate(lpGuid); test_invalid_fmts(lpGuid); test_notifications(lpGuid);
test_notifications_interface(lpGuid);
Instead of making a new function, I think this could be moved to the beginning of test_notifications().
Otherwise it all looks fine to me.
Thanks, Andrew