mmdevapi: Use proper helpers for iface calls.

This commit is contained in:
Jacek Caban 2012-08-15 11:45:03 +02:00 committed by Alexandre Julliard
parent ee40973b2b
commit 223105b9b3
7 changed files with 51 additions and 51 deletions

View File

@ -1024,7 +1024,7 @@ static HRESULT WINAPI MMDevEnum_GetDevice(IMMDeviceEnumerator *iface, const WCHA
if (str && !lstrcmpW(str, name)) if (str && !lstrcmpW(str, name))
{ {
CoTaskMemFree(str); CoTaskMemFree(str);
IUnknown_AddRef(dev); IMMDevice_AddRef(dev);
*device = dev; *device = dev;
return S_OK; return S_OK;
} }

View File

@ -203,7 +203,7 @@ static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
} }
static HRESULT WINAPI static HRESULT WINAPI
MMCF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj) MMCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
{ {
IClassFactoryImpl *This = impl_from_IClassFactory(iface); IClassFactoryImpl *This = impl_from_IClassFactory(iface);
TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppobj); TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppobj);
@ -213,7 +213,7 @@ MMCF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
IsEqualIID(riid, &IID_IClassFactory)) IsEqualIID(riid, &IID_IClassFactory))
{ {
*ppobj = iface; *ppobj = iface;
IUnknown_AddRef(iface); IClassFactory_AddRef(iface);
return S_OK; return S_OK;
} }
*ppobj = NULL; *ppobj = NULL;
@ -296,7 +296,7 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
for (i = 0; i < sizeof(MMDEVAPI_CF)/sizeof(MMDEVAPI_CF[0]); ++i) for (i = 0; i < sizeof(MMDEVAPI_CF)/sizeof(MMDEVAPI_CF[0]); ++i)
{ {
if (IsEqualGUID(rclsid, MMDEVAPI_CF[i].rclsid)) { if (IsEqualGUID(rclsid, MMDEVAPI_CF[i].rclsid)) {
IUnknown_AddRef(&MMDEVAPI_CF[i].IClassFactory_iface); IClassFactory_AddRef(&MMDEVAPI_CF[i].IClassFactory_iface);
*ppv = &MMDEVAPI_CF[i]; *ppv = &MMDEVAPI_CF[i];
return S_OK; return S_OK;
} }

View File

@ -442,7 +442,7 @@ static void test_capture(IAudioClient *ac, HANDLE handle, WAVEFORMATEX *wfx)
hr = IAudioClient_Start(ac); hr = IAudioClient_Start(ac);
ok(hr == S_OK, "Start failed: %08x\n", hr); ok(hr == S_OK, "Start failed: %08x\n", hr);
IUnknown_Release(acc); IAudioCaptureClient_Release(acc);
} }
static void test_audioclient(void) static void test_audioclient(void)

View File

@ -78,7 +78,7 @@ START_TEST(dependency)
ok(ds8 != NULL, "ds8 pointer is null\n"); ok(ds8 != NULL, "ds8 pointer is null\n");
} }
if (ds8) if (ds8)
IUnknown_Release(ds8); IDirectSound8_Release(ds8);
ok(!GetModuleHandle("quartz.dll"), "quartz.dll was already loaded!\n"); ok(!GetModuleHandle("quartz.dll"), "quartz.dll was already loaded!\n");
hr = IMMDevice_Activate(dev, &IID_IBaseFilter, CLSCTX_INPROC_SERVER, NULL, (void**)&bf); hr = IMMDevice_Activate(dev, &IID_IBaseFilter, CLSCTX_INPROC_SERVER, NULL, (void**)&bf);
@ -99,11 +99,11 @@ START_TEST(dependency)
cleanup: cleanup:
if (bf) if (bf)
IUnknown_Release(bf); IBaseFilter_Release(bf);
if (dev) if (dev)
IUnknown_Release(dev); IMMDevice_Release(dev);
if (mme) if (mme)
IUnknown_Release(mme); IMMDeviceEnumerator_Release(mme);
CoUninitialize(); CoUninitialize();
} }

View File

@ -44,34 +44,34 @@ static void test_collection(IMMDeviceEnumerator *mme, IMMDeviceCollection *col)
IMMDevice *dev; IMMDevice *dev;
/* collection doesn't keep a ref on parent */ /* collection doesn't keep a ref on parent */
IUnknown_AddRef(mme); IMMDeviceEnumerator_AddRef(mme);
ref = IUnknown_Release(mme); ref = IMMDeviceEnumerator_Release(mme);
ok(ref == 2, "Reference count on parent is %u\n", ref); ok(ref == 2, "Reference count on parent is %u\n", ref);
ref = IUnknown_AddRef(col); ref = IMMDeviceCollection_AddRef(col);
IUnknown_Release(col); IMMDeviceCollection_Release(col);
ok(ref == 2, "Invalid reference count %u on collection\n", ref); ok(ref == 2, "Invalid reference count %u on collection\n", ref);
hr = IUnknown_QueryInterface(col, &IID_IUnknown, NULL); hr = IMMDeviceCollection_QueryInterface(col, &IID_IUnknown, NULL);
ok(hr == E_POINTER, "Null ppv returns %08x\n", hr); ok(hr == E_POINTER, "Null ppv returns %08x\n", hr);
hr = IUnknown_QueryInterface(col, &IID_IUnknown, (void**)&unk); hr = IMMDeviceCollection_QueryInterface(col, &IID_IUnknown, (void**)&unk);
ok(hr == S_OK, "Cannot query for IID_IUnknown: 0x%08x\n", hr); ok(hr == S_OK, "Cannot query for IID_IUnknown: 0x%08x\n", hr);
if (hr == S_OK) if (hr == S_OK)
{ {
ok((LONG_PTR)col == (LONG_PTR)unk, "Pointers are not identical %p/%p/%p\n", col, unk, mme); ok((IUnknown*)col == unk, "Pointers are not identical %p/%p/%p\n", col, unk, mme);
IUnknown_Release(unk); IUnknown_Release(unk);
} }
hr = IUnknown_QueryInterface(col, &IID_IMMDeviceCollection, (void**)&col2); hr = IMMDeviceCollection_QueryInterface(col, &IID_IMMDeviceCollection, (void**)&col2);
ok(hr == S_OK, "Cannot query for IID_IMMDeviceCollection: 0x%08x\n", hr); ok(hr == S_OK, "Cannot query for IID_IMMDeviceCollection: 0x%08x\n", hr);
if (hr == S_OK) if (hr == S_OK)
IUnknown_Release(col2); IMMDeviceCollection_Release(col2);
hr = IUnknown_QueryInterface(col, &IID_IMMDeviceEnumerator, (void**)&mme2); hr = IMMDeviceCollection_QueryInterface(col, &IID_IMMDeviceEnumerator, (void**)&mme2);
ok(hr == E_NOINTERFACE, "Query for IID_IMMDeviceEnumerator returned: 0x%08x\n", hr); ok(hr == E_NOINTERFACE, "Query for IID_IMMDeviceEnumerator returned: 0x%08x\n", hr);
if (hr == S_OK) if (hr == S_OK)
IUnknown_Release(mme2); IMMDeviceEnumerator_Release(mme2);
hr = IMMDeviceCollection_GetCount(col, NULL); hr = IMMDeviceCollection_GetCount(col, NULL);
ok(hr == E_POINTER, "GetCount returned 0x%08x\n", hr); ok(hr == E_POINTER, "GetCount returned 0x%08x\n", hr);
@ -113,9 +113,9 @@ static void test_collection(IMMDeviceEnumerator *mme, IMMDeviceCollection *col)
} }
} }
if (dev) if (dev)
IUnknown_Release(dev); IMMDevice_Release(dev);
} }
IUnknown_Release(col); IMMDeviceCollection_Release(col);
} }
/* Only do parameter tests here, the actual MMDevice testing should be a separate test */ /* Only do parameter tests here, the actual MMDevice testing should be a separate test */
@ -139,11 +139,11 @@ START_TEST(mmdevenum)
} }
/* Odd behavior.. bug? */ /* Odd behavior.. bug? */
ref = IUnknown_AddRef(mme); ref = IMMDeviceEnumerator_AddRef(mme);
ok(ref == 3, "Invalid reference count after incrementing: %u\n", ref); ok(ref == 3, "Invalid reference count after incrementing: %u\n", ref);
IUnknown_Release(mme); IMMDeviceEnumerator_Release(mme);
hr = IUnknown_QueryInterface(mme, &IID_IUnknown, (void**)&unk); hr = IMMDeviceEnumerator_QueryInterface(mme, &IID_IUnknown, (void**)&unk);
ok(hr == S_OK, "returned 0x%08x\n", hr); ok(hr == S_OK, "returned 0x%08x\n", hr);
if (hr != S_OK) return; if (hr != S_OK) return;
@ -153,13 +153,13 @@ START_TEST(mmdevenum)
/* Proving that it is static.. */ /* Proving that it is static.. */
hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)&mme2); hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)&mme2);
ok(hr == S_OK, "CoCreateInstance failed: 0x%08x\n", hr); ok(hr == S_OK, "CoCreateInstance failed: 0x%08x\n", hr);
IUnknown_Release(mme2); IMMDeviceEnumerator_Release(mme2);
ok(mme == mme2, "Pointers are not equal!\n"); ok(mme == mme2, "Pointers are not equal!\n");
hr = IUnknown_QueryInterface(mme, &IID_IUnknown, NULL); hr = IMMDeviceEnumerator_QueryInterface(mme, &IID_IUnknown, NULL);
ok(hr == E_POINTER, "Null pointer on QueryInterface returned %08x\n", hr); ok(hr == E_POINTER, "Null pointer on QueryInterface returned %08x\n", hr);
hr = IUnknown_QueryInterface(mme, &GUID_NULL, (void**)&unk); hr = IMMDeviceEnumerator_QueryInterface(mme, &GUID_NULL, (void**)&unk);
ok(!unk, "Unk not reset to null after invalid QI\n"); ok(!unk, "Unk not reset to null after invalid QI\n");
ok(hr == E_NOINTERFACE, "Invalid hr %08x returned on IID_NULL\n", hr); ok(hr == E_NOINTERFACE, "Invalid hr %08x returned on IID_NULL\n", hr);
@ -192,5 +192,5 @@ START_TEST(mmdevenum)
test_collection(mme, col); test_collection(mme, col);
} }
IUnknown_Release(mme); IMMDeviceEnumerator_Release(mme);
} }

View File

@ -132,6 +132,6 @@ START_TEST(propstore)
IMMDevice_Release(dev); IMMDevice_Release(dev);
cleanup: cleanup:
if (mme) if (mme)
IUnknown_Release(mme); IMMDeviceEnumerator_Release(mme);
CoUninitialize(); CoUninitialize();
} }

View File

@ -1378,25 +1378,25 @@ static void test_session(void)
hr = IAudioClient_GetService(ses1_ac1, &IID_IAudioSessionControl, (void**)&ses1_ctl2); hr = IAudioClient_GetService(ses1_ac1, &IID_IAudioSessionControl, (void**)&ses1_ctl2);
ok(hr == S_OK, "GetService failed: %08x\n", hr); ok(hr == S_OK, "GetService failed: %08x\n", hr);
ok(ses1_ctl == ses1_ctl2, "Got different controls: %p %p\n", ses1_ctl, ses1_ctl2); ok(ses1_ctl == ses1_ctl2, "Got different controls: %p %p\n", ses1_ctl, ses1_ctl2);
ref = IAudioSessionControl_Release(ses1_ctl2); ref = IAudioSessionControl2_Release(ses1_ctl2);
ok(ref != 0, "AudioSessionControl was destroyed\n"); ok(ref != 0, "AudioSessionControl was destroyed\n");
hr = IAudioClient_GetService(ses1_ac2, &IID_IAudioSessionControl, (void**)&ses1_ctl2); hr = IAudioClient_GetService(ses1_ac2, &IID_IAudioSessionControl, (void**)&ses1_ctl2);
ok(hr == S_OK, "GetService failed: %08x\n", hr); ok(hr == S_OK, "GetService failed: %08x\n", hr);
hr = IAudioSessionControl_GetState(ses1_ctl, NULL); hr = IAudioSessionControl2_GetState(ses1_ctl, NULL);
ok(hr == NULL_PTR_ERR, "GetState gave wrong error: %08x\n", hr); ok(hr == NULL_PTR_ERR, "GetState gave wrong error: %08x\n", hr);
hr = IAudioSessionControl_GetState(ses1_ctl, &state); hr = IAudioSessionControl2_GetState(ses1_ctl, &state);
ok(hr == S_OK, "GetState failed: %08x\n", hr); ok(hr == S_OK, "GetState failed: %08x\n", hr);
ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state); ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state);
hr = IAudioSessionControl_GetState(ses1_ctl2, &state); hr = IAudioSessionControl2_GetState(ses1_ctl2, &state);
ok(hr == S_OK, "GetState failed: %08x\n", hr); ok(hr == S_OK, "GetState failed: %08x\n", hr);
ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state); ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state);
if(cap_ctl){ if(cap_ctl){
hr = IAudioSessionControl_GetState(cap_ctl, &state); hr = IAudioSessionControl2_GetState(cap_ctl, &state);
ok(hr == S_OK, "GetState failed: %08x\n", hr); ok(hr == S_OK, "GetState failed: %08x\n", hr);
ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state); ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state);
} }
@ -1404,16 +1404,16 @@ static void test_session(void)
hr = IAudioClient_Start(ses1_ac1); hr = IAudioClient_Start(ses1_ac1);
ok(hr == S_OK, "Start failed: %08x\n", hr); ok(hr == S_OK, "Start failed: %08x\n", hr);
hr = IAudioSessionControl_GetState(ses1_ctl, &state); hr = IAudioSessionControl2_GetState(ses1_ctl, &state);
ok(hr == S_OK, "GetState failed: %08x\n", hr); ok(hr == S_OK, "GetState failed: %08x\n", hr);
ok(state == AudioSessionStateActive, "Got wrong state: %d\n", state); ok(state == AudioSessionStateActive, "Got wrong state: %d\n", state);
hr = IAudioSessionControl_GetState(ses1_ctl2, &state); hr = IAudioSessionControl2_GetState(ses1_ctl2, &state);
ok(hr == S_OK, "GetState failed: %08x\n", hr); ok(hr == S_OK, "GetState failed: %08x\n", hr);
ok(state == AudioSessionStateActive, "Got wrong state: %d\n", state); ok(state == AudioSessionStateActive, "Got wrong state: %d\n", state);
if(cap_ctl){ if(cap_ctl){
hr = IAudioSessionControl_GetState(cap_ctl, &state); hr = IAudioSessionControl2_GetState(cap_ctl, &state);
ok(hr == S_OK, "GetState failed: %08x\n", hr); ok(hr == S_OK, "GetState failed: %08x\n", hr);
ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state); ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state);
} }
@ -1421,57 +1421,57 @@ static void test_session(void)
hr = IAudioClient_Stop(ses1_ac1); hr = IAudioClient_Stop(ses1_ac1);
ok(hr == S_OK, "Start failed: %08x\n", hr); ok(hr == S_OK, "Start failed: %08x\n", hr);
hr = IAudioSessionControl_GetState(ses1_ctl, &state); hr = IAudioSessionControl2_GetState(ses1_ctl, &state);
ok(hr == S_OK, "GetState failed: %08x\n", hr); ok(hr == S_OK, "GetState failed: %08x\n", hr);
ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state); ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state);
hr = IAudioSessionControl_GetState(ses1_ctl2, &state); hr = IAudioSessionControl2_GetState(ses1_ctl2, &state);
ok(hr == S_OK, "GetState failed: %08x\n", hr); ok(hr == S_OK, "GetState failed: %08x\n", hr);
ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state); ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state);
if(cap_ctl){ if(cap_ctl){
hr = IAudioSessionControl_GetState(cap_ctl, &state); hr = IAudioSessionControl2_GetState(cap_ctl, &state);
ok(hr == S_OK, "GetState failed: %08x\n", hr); ok(hr == S_OK, "GetState failed: %08x\n", hr);
ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state); ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state);
hr = IAudioClient_Start(cap_ac); hr = IAudioClient_Start(cap_ac);
ok(hr == S_OK, "Start failed: %08x\n", hr); ok(hr == S_OK, "Start failed: %08x\n", hr);
hr = IAudioSessionControl_GetState(ses1_ctl, &state); hr = IAudioSessionControl2_GetState(ses1_ctl, &state);
ok(hr == S_OK, "GetState failed: %08x\n", hr); ok(hr == S_OK, "GetState failed: %08x\n", hr);
ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state); ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state);
hr = IAudioSessionControl_GetState(ses1_ctl2, &state); hr = IAudioSessionControl2_GetState(ses1_ctl2, &state);
ok(hr == S_OK, "GetState failed: %08x\n", hr); ok(hr == S_OK, "GetState failed: %08x\n", hr);
ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state); ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state);
hr = IAudioSessionControl_GetState(cap_ctl, &state); hr = IAudioSessionControl2_GetState(cap_ctl, &state);
ok(hr == S_OK, "GetState failed: %08x\n", hr); ok(hr == S_OK, "GetState failed: %08x\n", hr);
ok(state == AudioSessionStateActive, "Got wrong state: %d\n", state); ok(state == AudioSessionStateActive, "Got wrong state: %d\n", state);
hr = IAudioClient_Stop(cap_ac); hr = IAudioClient_Stop(cap_ac);
ok(hr == S_OK, "Stop failed: %08x\n", hr); ok(hr == S_OK, "Stop failed: %08x\n", hr);
hr = IAudioSessionControl_GetState(ses1_ctl, &state); hr = IAudioSessionControl2_GetState(ses1_ctl, &state);
ok(hr == S_OK, "GetState failed: %08x\n", hr); ok(hr == S_OK, "GetState failed: %08x\n", hr);
ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state); ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state);
hr = IAudioSessionControl_GetState(ses1_ctl2, &state); hr = IAudioSessionControl2_GetState(ses1_ctl2, &state);
ok(hr == S_OK, "GetState failed: %08x\n", hr); ok(hr == S_OK, "GetState failed: %08x\n", hr);
ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state); ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state);
hr = IAudioSessionControl_GetState(cap_ctl, &state); hr = IAudioSessionControl2_GetState(cap_ctl, &state);
ok(hr == S_OK, "GetState failed: %08x\n", hr); ok(hr == S_OK, "GetState failed: %08x\n", hr);
ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state); ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state);
ref = IAudioSessionControl_Release(cap_ctl); ref = IAudioSessionControl2_Release(cap_ctl);
ok(ref == 0, "AudioSessionControl wasn't released: %u\n", ref); ok(ref == 0, "AudioSessionControl wasn't released: %u\n", ref);
ref = IAudioClient_Release(cap_ac); ref = IAudioClient_Release(cap_ac);
ok(ref == 0, "AudioClient wasn't released: %u\n", ref); ok(ref == 0, "AudioClient wasn't released: %u\n", ref);
} }
ref = IAudioSessionControl_Release(ses1_ctl); ref = IAudioSessionControl2_Release(ses1_ctl);
ok(ref == 0, "AudioSessionControl wasn't released: %u\n", ref); ok(ref == 0, "AudioSessionControl wasn't released: %u\n", ref);
ref = IAudioClient_Release(ses1_ac1); ref = IAudioClient_Release(ses1_ac1);
@ -1481,11 +1481,11 @@ static void test_session(void)
ok(ref == 1, "AudioClient had wrong refcount: %u\n", ref); ok(ref == 1, "AudioClient had wrong refcount: %u\n", ref);
/* we've released all of our IAudioClient references, so check GetState */ /* we've released all of our IAudioClient references, so check GetState */
hr = IAudioSessionControl_GetState(ses1_ctl2, &state); hr = IAudioSessionControl2_GetState(ses1_ctl2, &state);
ok(hr == S_OK, "GetState failed: %08x\n", hr); ok(hr == S_OK, "GetState failed: %08x\n", hr);
ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state); ok(state == AudioSessionStateInactive, "Got wrong state: %d\n", state);
ref = IAudioSessionControl_Release(ses1_ctl2); ref = IAudioSessionControl2_Release(ses1_ctl2);
ok(ref == 0, "AudioSessionControl wasn't released: %u\n", ref); ok(ref == 0, "AudioSessionControl wasn't released: %u\n", ref);
CoTaskMemFree(pwfx); CoTaskMemFree(pwfx);