Commit ef039627 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

mmdevapi: Use an iface instead of a vtbl pointer in IClassFactoryImpl.

parent 23906816
...@@ -342,15 +342,20 @@ HRESULT WINAPI DllCanUnloadNow(void) ...@@ -342,15 +342,20 @@ HRESULT WINAPI DllCanUnloadNow(void)
typedef HRESULT (*FnCreateInstance)(REFIID riid, LPVOID *ppobj); typedef HRESULT (*FnCreateInstance)(REFIID riid, LPVOID *ppobj);
typedef struct { typedef struct {
const IClassFactoryVtbl *lpVtbl; IClassFactory IClassFactory_iface;
REFCLSID rclsid; REFCLSID rclsid;
FnCreateInstance pfnCreateInstance; FnCreateInstance pfnCreateInstance;
} IClassFactoryImpl; } IClassFactoryImpl;
static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
{
return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
}
static HRESULT WINAPI static HRESULT WINAPI
MMCF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj) MMCF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
{ {
IClassFactoryImpl *This = (IClassFactoryImpl *)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);
if (ppobj == NULL) if (ppobj == NULL)
return E_POINTER; return E_POINTER;
...@@ -382,7 +387,7 @@ static HRESULT WINAPI MMCF_CreateInstance( ...@@ -382,7 +387,7 @@ static HRESULT WINAPI MMCF_CreateInstance(
REFIID riid, REFIID riid,
LPVOID *ppobj) LPVOID *ppobj)
{ {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; IClassFactoryImpl *This = impl_from_IClassFactory(iface);
TRACE("(%p, %p, %s, %p)\n", This, pOuter, debugstr_guid(riid), ppobj); TRACE("(%p, %p, %s, %p)\n", This, pOuter, debugstr_guid(riid), ppobj);
if (pOuter) if (pOuter)
...@@ -398,7 +403,7 @@ static HRESULT WINAPI MMCF_CreateInstance( ...@@ -398,7 +403,7 @@ static HRESULT WINAPI MMCF_CreateInstance(
static HRESULT WINAPI MMCF_LockServer(LPCLASSFACTORY iface, BOOL dolock) static HRESULT WINAPI MMCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
{ {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; IClassFactoryImpl *This = impl_from_IClassFactory(iface);
FIXME("(%p, %d) stub!\n", This, dolock); FIXME("(%p, %d) stub!\n", This, dolock);
return S_OK; return S_OK;
} }
...@@ -412,7 +417,7 @@ static const IClassFactoryVtbl MMCF_Vtbl = { ...@@ -412,7 +417,7 @@ static const IClassFactoryVtbl MMCF_Vtbl = {
}; };
static IClassFactoryImpl MMDEVAPI_CF[] = { static IClassFactoryImpl MMDEVAPI_CF[] = {
{ &MMCF_Vtbl, &CLSID_MMDeviceEnumerator, (FnCreateInstance)MMDevEnum_Create } { { &MMCF_Vtbl }, &CLSID_MMDeviceEnumerator, (FnCreateInstance)MMDevEnum_Create }
}; };
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
...@@ -436,7 +441,7 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) ...@@ -436,7 +441,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((IClassFactory*) &MMDEVAPI_CF[i]); IUnknown_AddRef(&MMDEVAPI_CF[i].IClassFactory_iface);
*ppv = &MMDEVAPI_CF[i]; *ppv = &MMDEVAPI_CF[i];
return S_OK; return S_OK;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment