Instead of selecting the nth effect overall and checking whether it matches.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/dsound/buffer.c | 32 +++++++++++++++----------------- dlls/dsound/tests/dsound8.c | 24 ++++++++++-------------- 2 files changed, 25 insertions(+), 31 deletions(-)
diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c index ea428c08166..bc30a8a5448 100644 --- a/dlls/dsound/buffer.c +++ b/dlls/dsound/buffer.c @@ -845,27 +845,25 @@ static HRESULT WINAPI IDirectSoundBufferImpl_AcquireResources(IDirectSoundBuffer }
static HRESULT WINAPI IDirectSoundBufferImpl_GetObjectInPath(IDirectSoundBuffer8 *iface, - REFGUID rguidObject, DWORD dwIndex, REFGUID rguidInterface, void **ppObject) + REFGUID clsid, DWORD index, REFGUID iid, void **out) { - IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer8(iface); + IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer8(iface); + DWORD i, count = 0;
- TRACE("(%p,%s,%u,%s,%p)\n",This,debugstr_guid(rguidObject),dwIndex,debugstr_guid(rguidInterface),ppObject); + TRACE("(%p,%s,%u,%s,%p)\n", This, debugstr_guid(clsid), index, debugstr_guid(iid), out);
- if (dwIndex >= This->num_filters) - return DSERR_CONTROLUNAVAIL; - - if (!ppObject) - return E_INVALIDARG; + if (!out) + return E_INVALIDARG;
- if (IsEqualGUID(rguidObject, &This->filters[dwIndex].guid) || IsEqualGUID(rguidObject, &GUID_All_Objects)) { - if (SUCCEEDED(IMediaObject_QueryInterface(This->filters[dwIndex].obj, rguidInterface, ppObject))) - return DS_OK; - else - return E_NOINTERFACE; - } else { - WARN("control unavailable\n"); - return DSERR_OBJECTNOTFOUND; - } + for (i = 0; i < This->num_filters; i++) + { + if (IsEqualGUID(clsid, &This->filters[i].guid) || IsEqualGUID(clsid, &GUID_All_Objects)) + { + if (count++ == index) + return IMediaObject_QueryInterface(This->filters[i].obj, iid, out); + } + } + return DSERR_OBJECTNOTFOUND; }
static HRESULT WINAPI IDirectSoundBufferImpl_Initialize(IDirectSoundBuffer8 *iface, diff --git a/dlls/dsound/tests/dsound8.c b/dlls/dsound/tests/dsound8.c index fcac31ba637..81c5710dbaf 100644 --- a/dlls/dsound/tests/dsound8.c +++ b/dlls/dsound/tests/dsound8.c @@ -1678,7 +1678,7 @@ static void test_effects(void)
dmo = (IMediaObject *)0xdeadbeef; hr = IDirectSoundBuffer8_GetObjectInPath(buffer8, &GUID_All_Objects, 1, &IID_IMediaObject, (void **)&dmo); - todo_wine ok(hr == DSERR_OBJECTNOTFOUND, "Got hr %#x.\n", hr); + ok(hr == DSERR_OBJECTNOTFOUND, "Got hr %#x.\n", hr); ok(dmo == (IMediaObject *)0xdeadbeef, "Got object %p.\n", dmo);
effects[0].guidDSFXClass = GUID_DSFX_STANDARD_PARAMEQ; @@ -1705,9 +1705,8 @@ static void test_effects(void) echo = dmo; hr = IDirectSoundBuffer8_GetObjectInPath(buffer8, &GUID_DSFX_STANDARD_I3DL2REVERB, 0, &IID_IMediaObject, (void **)&dmo); - todo_wine ok(hr == DS_OK, "Got hr %#x.\n", hr); - if (hr == DS_OK) - reverb = dmo; + ok(hr == DS_OK, "Got hr %#x.\n", hr); + reverb = dmo;
hr = IDirectSoundBuffer8_GetObjectInPath(buffer8, &GUID_All_Objects, 0, &IID_IMediaObject, (void **)&dmo); ok(hr == DS_OK, "Got hr %#x.\n", hr); @@ -1716,12 +1715,12 @@ static void test_effects(void)
hr = IDirectSoundBuffer8_GetObjectInPath(buffer8, &GUID_All_Objects, 1, &IID_IMediaObject, (void **)&dmo); ok(hr == DS_OK, "Got hr %#x.\n", hr); - todo_wine ok(dmo == reverb, "Expected %p, got %p.\n", reverb, dmo); + ok(dmo == reverb, "Expected %p, got %p.\n", reverb, dmo); IMediaObject_Release(dmo);
hr = IDirectSoundBuffer8_GetObjectInPath(buffer8, &GUID_DSFX_STANDARD_I3DL2REVERB, 1, &IID_IMediaObject, (void **)&dmo); - todo_wine ok(hr == DSERR_OBJECTNOTFOUND, "Got hr %#x.\n", hr); + ok(hr == DSERR_OBJECTNOTFOUND, "Got hr %#x.\n", hr);
hr = IDirectSoundBuffer8_GetObjectInPath(buffer8, &GUID_All_Objects, 0, &IID_IDirectSoundFXParamEq, (void **)&unk); ok(hr == DS_OK, "Got hr %#x.\n", hr); @@ -1743,14 +1742,11 @@ static void test_effects(void)
hr = IDirectSoundBuffer8_GetObjectInPath(buffer8, &GUID_DSFX_STANDARD_I3DL2REVERB, 0, &IID_IDirectSoundFXI3DL2Reverb, (void **)&unk); - todo_wine ok(hr == DS_OK, "Got hr %#x.\n", hr); - if (hr == DS_OK) - IUnknown_Release(unk); + ok(hr == DS_OK, "Got hr %#x.\n", hr); + IUnknown_Release(unk);
- if (echo) - IMediaObject_Release(echo); - if (reverb) - IMediaObject_Release(reverb); + IMediaObject_Release(echo); + IMediaObject_Release(reverb);
got_Process = CreateEventA(NULL, TRUE, FALSE, NULL);
@@ -1786,7 +1782,7 @@ static void test_effects(void) ok(hr == DS_OK, "Got hr %#x.\n", hr);
hr = IDirectSoundBuffer8_GetObjectInPath(buffer8, &GUID_All_Objects, 0, &IID_IMediaObject, (void **)&dmo); - todo_wine ok(hr == DSERR_OBJECTNOTFOUND, "Got hr %#x.\n", hr); + ok(hr == DSERR_OBJECTNOTFOUND, "Got hr %#x.\n", hr);
CloseHandle(got_Process); IDirectSoundBuffer8_Release(buffer8);