dsound: Standardize the COM usage in duplex.c.

Michael Stefaniuc mstefani at redhat.de
Wed Dec 8 15:59:45 CST 2010


---
 dlls/dsound/duplex.c |   86 ++++++++++++++++++++++++++++++-------------------
 1 files changed, 53 insertions(+), 33 deletions(-)

diff --git a/dlls/dsound/duplex.c b/dlls/dsound/duplex.c
index 4a1fbd2..2fcf64c 100644
--- a/dlls/dsound/duplex.c
+++ b/dlls/dsound/duplex.c
@@ -44,7 +44,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dsound);
 typedef struct IDirectSoundFullDuplexImpl
 {
     /* IUnknown fields */
-    const IDirectSoundFullDuplexVtbl *lpVtbl;
+    IDirectSoundFullDuplex            IDirectSoundFullDuplex_iface;
     LONG                              ref;
 
     /* IDirectSoundFullDuplexImpl fields */
@@ -57,23 +57,43 @@ typedef struct IDirectSoundFullDuplexImpl
 } IDirectSoundFullDuplexImpl;
 
 typedef struct IDirectSoundFullDuplex_IUnknown {
-    const IUnknownVtbl         *lpVtbl;
+    IUnknown                    IUnknown_iface;
     LONG                        ref;
     IDirectSoundFullDuplexImpl *pdsfd;
 } IDirectSoundFullDuplex_IUnknown;
 
 typedef struct IDirectSoundFullDuplex_IDirectSound8 {
-    const IDirectSound8Vtbl    *lpVtbl;
+    IDirectSound8               IDirectSound8_iface;
     LONG                        ref;
     IDirectSoundFullDuplexImpl *pdsfd;
 } IDirectSoundFullDuplex_IDirectSound8;
 
 typedef struct IDirectSoundFullDuplex_IDirectSoundCapture {
-    const IDirectSoundCaptureVtbl *lpVtbl;
+    IDirectSoundCapture            IDirectSoundCapture_iface;
     LONG                           ref;
     IDirectSoundFullDuplexImpl    *pdsfd;
 } IDirectSoundFullDuplex_IDirectSoundCapture;
 
+static inline IDirectSoundFullDuplexImpl *impl_from_IDirectSoundFullDuplex(IDirectSoundFullDuplex *iface)
+{
+    return CONTAINING_RECORD(iface, IDirectSoundFullDuplexImpl, IDirectSoundFullDuplex_iface);
+}
+
+static inline IDirectSoundFullDuplex_IUnknown *impl_from_IUnknown(IUnknown *iface)
+{
+    return CONTAINING_RECORD(iface, IDirectSoundFullDuplex_IUnknown, IUnknown_iface);
+}
+
+static inline IDirectSoundFullDuplex_IDirectSound8 *impl_from_IDirectSound8(IDirectSound8 *iface)
+{
+    return CONTAINING_RECORD(iface, IDirectSoundFullDuplex_IDirectSound8, IDirectSound8_iface);
+}
+
+static inline IDirectSoundFullDuplex_IDirectSoundCapture *impl_from_IDirectSoundCapture(IDirectSoundCapture *iface)
+{
+    return CONTAINING_RECORD(iface, IDirectSoundFullDuplex_IDirectSoundCapture, IDirectSoundCapture_iface);
+}
+
 /*******************************************************************************
  * IUnknown
  */
@@ -82,7 +102,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IUnknown_QueryInterface(
     REFIID riid,
     LPVOID * ppobj)
 {
-    IDirectSoundFullDuplex_IUnknown *This = (IDirectSoundFullDuplex_IUnknown *)iface;
+    IDirectSoundFullDuplex_IUnknown *This = impl_from_IUnknown(iface);
     TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
     return IDirectSoundFullDuplex_QueryInterface((LPDIRECTSOUNDFULLDUPLEX)This->pdsfd, riid, ppobj);
 }
@@ -90,7 +110,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IUnknown_QueryInterface(
 static ULONG WINAPI IDirectSoundFullDuplex_IUnknown_AddRef(
     LPUNKNOWN iface)
 {
-    IDirectSoundFullDuplex_IUnknown *This = (IDirectSoundFullDuplex_IUnknown *)iface;
+    IDirectSoundFullDuplex_IUnknown *This = impl_from_IUnknown(iface);
     ULONG ref = InterlockedIncrement(&(This->ref));
     TRACE("(%p) ref was %d\n", This, ref - 1);
     return ref;
@@ -99,7 +119,7 @@ static ULONG WINAPI IDirectSoundFullDuplex_IUnknown_AddRef(
 static ULONG WINAPI IDirectSoundFullDuplex_IUnknown_Release(
     LPUNKNOWN iface)
 {
-    IDirectSoundFullDuplex_IUnknown *This = (IDirectSoundFullDuplex_IUnknown *)iface;
+    IDirectSoundFullDuplex_IUnknown *This = impl_from_IUnknown(iface);
     ULONG ref = InterlockedDecrement(&(This->ref));
     TRACE("(%p) ref was %d\n", This, ref + 1);
     if (!ref) {
@@ -141,7 +161,7 @@ static HRESULT IDirectSoundFullDuplex_IUnknown_Create(
         return DSERR_OUTOFMEMORY;
     }
 
-    pdsfdunk->lpVtbl = &DirectSoundFullDuplex_Unknown_Vtbl;
+    pdsfdunk->IUnknown_iface.lpVtbl = &DirectSoundFullDuplex_Unknown_Vtbl;
     pdsfdunk->ref = 0;
     pdsfdunk->pdsfd = (IDirectSoundFullDuplexImpl *)pdsfd;
 
@@ -158,7 +178,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_QueryInterface(
     REFIID riid,
     LPVOID * ppobj)
 {
-    IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
+    IDirectSoundFullDuplex_IDirectSound8 *This = impl_from_IDirectSound8(iface);
     TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
     return IDirectSoundFullDuplex_QueryInterface((LPDIRECTSOUNDFULLDUPLEX)This->pdsfd, riid, ppobj);
 }
@@ -166,7 +186,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_QueryInterface(
 static ULONG WINAPI IDirectSoundFullDuplex_IDirectSound8_AddRef(
     LPDIRECTSOUND8 iface)
 {
-    IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
+    IDirectSoundFullDuplex_IDirectSound8 *This = impl_from_IDirectSound8(iface);
     ULONG ref = InterlockedIncrement(&(This->ref));
     TRACE("(%p) ref was %d\n", This, ref - 1);
     return ref;
@@ -175,7 +195,7 @@ static ULONG WINAPI IDirectSoundFullDuplex_IDirectSound8_AddRef(
 static ULONG WINAPI IDirectSoundFullDuplex_IDirectSound8_Release(
     LPDIRECTSOUND8 iface)
 {
-    IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
+    IDirectSoundFullDuplex_IDirectSound8 *This = impl_from_IDirectSound8(iface);
     ULONG ref = InterlockedDecrement(&(This->ref));
     TRACE("(%p) ref was %d\n", This, ref + 1);
     if (!ref) {
@@ -192,7 +212,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_CreateSoundBuffer(
     LPLPDIRECTSOUNDBUFFER ppdsb,
     LPUNKNOWN lpunk)
 {
-    IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
+    IDirectSoundFullDuplex_IDirectSound8 *This = impl_from_IDirectSound8(iface);
     TRACE("(%p,%p,%p,%p)\n",This,dsbd,ppdsb,lpunk);
     return IDirectSound8_CreateSoundBuffer(This->pdsfd->renderer_device,dsbd,ppdsb,lpunk);
 }
@@ -201,7 +221,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_GetCaps(
     LPDIRECTSOUND8 iface,
     LPDSCAPS lpDSCaps)
 {
-    IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
+    IDirectSoundFullDuplex_IDirectSound8 *This = impl_from_IDirectSound8(iface);
     TRACE("(%p,%p)\n",This,lpDSCaps);
     return IDirectSound8_GetCaps(This->pdsfd->renderer_device, lpDSCaps);
 }
@@ -211,7 +231,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_DuplicateSoundBuffer(
     LPDIRECTSOUNDBUFFER psb,
     LPLPDIRECTSOUNDBUFFER ppdsb)
 {
-    IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
+    IDirectSoundFullDuplex_IDirectSound8 *This = impl_from_IDirectSound8(iface);
     TRACE("(%p,%p,%p)\n",This,psb,ppdsb);
     return IDirectSound8_DuplicateSoundBuffer(This->pdsfd->renderer_device,psb,ppdsb);
 }
@@ -221,7 +241,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_SetCooperativeLevel(
     HWND hwnd,
     DWORD level)
 {
-    IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
+    IDirectSoundFullDuplex_IDirectSound8 *This = impl_from_IDirectSound8(iface);
     TRACE("(%p,%p,%s)\n",This,hwnd,dumpCooperativeLevel(level));
     return IDirectSound8_SetCooperativeLevel(This->pdsfd->renderer_device,hwnd,level);
 }
@@ -229,7 +249,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_SetCooperativeLevel(
 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_Compact(
     LPDIRECTSOUND8 iface)
 {
-    IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
+    IDirectSoundFullDuplex_IDirectSound8 *This = impl_from_IDirectSound8(iface);
     TRACE("(%p)\n", This);
     return IDirectSound8_Compact(This->pdsfd->renderer_device);
 }
@@ -238,7 +258,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_GetSpeakerConfig(
     LPDIRECTSOUND8 iface,
     LPDWORD lpdwSpeakerConfig)
 {
-    IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
+    IDirectSoundFullDuplex_IDirectSound8 *This = impl_from_IDirectSound8(iface);
     TRACE("(%p, %p)\n", This, lpdwSpeakerConfig);
     return IDirectSound8_GetSpeakerConfig(This->pdsfd->renderer_device,lpdwSpeakerConfig);
 }
@@ -247,7 +267,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_SetSpeakerConfig(
     LPDIRECTSOUND8 iface,
     DWORD config)
 {
-    IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
+    IDirectSoundFullDuplex_IDirectSound8 *This = impl_from_IDirectSound8(iface);
     TRACE("(%p,0x%08x)\n",This,config);
     return IDirectSound8_SetSpeakerConfig(This->pdsfd->renderer_device,config);
 }
@@ -256,7 +276,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_Initialize(
     LPDIRECTSOUND8 iface,
     LPCGUID lpcGuid)
 {
-    IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
+    IDirectSoundFullDuplex_IDirectSound8 *This = impl_from_IDirectSound8(iface);
     TRACE("(%p, %s)\n", This, debugstr_guid(lpcGuid));
     return IDirectSound8_Initialize(This->pdsfd->renderer_device,lpcGuid);
 }
@@ -265,7 +285,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_VerifyCertification(
     LPDIRECTSOUND8 iface,
     DWORD *cert)
 {
-    IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
+    IDirectSoundFullDuplex_IDirectSound8 *This = impl_from_IDirectSound8(iface);
     TRACE("(%p, %p)\n", This, cert);
     return IDirectSound8_VerifyCertification(This->pdsfd->renderer_device,cert);
 }
@@ -316,7 +336,7 @@ static HRESULT IDirectSoundFullDuplex_IDirectSound8_Create(
         return DSERR_OUTOFMEMORY;
     }
 
-    pdsfdds8->lpVtbl = &DirectSoundFullDuplex_DirectSound8_Vtbl;
+    pdsfdds8->IDirectSound8_iface.lpVtbl = &DirectSoundFullDuplex_DirectSound8_Vtbl;
     pdsfdds8->ref = 0;
     pdsfdds8->pdsfd = (IDirectSoundFullDuplexImpl *)pdsfd;
 
@@ -333,7 +353,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_QueryInterface(
     REFIID riid,
     LPVOID * ppobj)
 {
-    IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface;
+    IDirectSoundFullDuplex_IDirectSoundCapture *This = impl_from_IDirectSoundCapture(iface);
     TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
     return IDirectSoundFullDuplex_QueryInterface((LPDIRECTSOUNDFULLDUPLEX)This->pdsfd, riid, ppobj);
 }
@@ -341,7 +361,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_QueryInterface(
 static ULONG WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_AddRef(
     LPDIRECTSOUNDCAPTURE iface)
 {
-    IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface;
+    IDirectSoundFullDuplex_IDirectSoundCapture *This = impl_from_IDirectSoundCapture(iface);
     ULONG ref = InterlockedIncrement(&(This->ref));
     TRACE("(%p) ref was %d\n", This, ref - 1);
     return ref;
@@ -350,7 +370,7 @@ static ULONG WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_AddRef(
 static ULONG WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_Release(
     LPDIRECTSOUNDCAPTURE iface)
 {
-    IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface;
+    IDirectSoundFullDuplex_IDirectSoundCapture *This = impl_from_IDirectSoundCapture(iface);
     ULONG ref = InterlockedDecrement(&(This->ref));
     TRACE("(%p) ref was %d\n", This, ref + 1);
     if (!ref) {
@@ -367,7 +387,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_CreateCaptureBu
     LPDIRECTSOUNDCAPTUREBUFFER* lplpDSCaptureBuffer,
     LPUNKNOWN pUnk)
 {
-    IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface;
+    IDirectSoundFullDuplex_IDirectSoundCapture *This = impl_from_IDirectSoundCapture(iface);
     TRACE("(%p,%p,%p,%p)\n",This,lpcDSCBufferDesc,lplpDSCaptureBuffer,pUnk);
     return IDirectSoundCapture_CreateCaptureBuffer(This->pdsfd->capture_device,lpcDSCBufferDesc,lplpDSCaptureBuffer,pUnk);
 }
@@ -376,7 +396,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_GetCaps(
     LPDIRECTSOUNDCAPTURE iface,
     LPDSCCAPS lpDSCCaps)
 {
-    IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface;
+    IDirectSoundFullDuplex_IDirectSoundCapture *This = impl_from_IDirectSoundCapture(iface);
     TRACE("(%p,%p)\n",This,lpDSCCaps);
     return IDirectSoundCapture_GetCaps(This->pdsfd->capture_device, lpDSCCaps);
 }
@@ -385,7 +405,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_Initialize(
     LPDIRECTSOUNDCAPTURE iface,
     LPCGUID lpcGUID)
 {
-    IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface;
+    IDirectSoundFullDuplex_IDirectSoundCapture *This = impl_from_IDirectSoundCapture(iface);
     TRACE("(%p, %s)\n", This, debugstr_guid(lpcGUID));
     return IDirectSoundCapture_Initialize(This->pdsfd->capture_device,lpcGUID);
 }
@@ -430,7 +450,7 @@ static HRESULT IDirectSoundFullDuplex_IDirectSoundCapture_Create(
         return DSERR_OUTOFMEMORY;
     }
 
-    pdsfddsc->lpVtbl = &DirectSoundFullDuplex_DirectSoundCapture_Vtbl;
+    pdsfddsc->IDirectSoundCapture_iface.lpVtbl = &DirectSoundFullDuplex_DirectSoundCapture_Vtbl;
     pdsfddsc->ref = 0;
     pdsfddsc->pdsfd = (IDirectSoundFullDuplexImpl *)pdsfd;
 
@@ -445,7 +465,7 @@ static HRESULT IDirectSoundFullDuplex_IDirectSoundCapture_Create(
 static ULONG WINAPI
 IDirectSoundFullDuplexImpl_AddRef( LPDIRECTSOUNDFULLDUPLEX iface )
 {
-    IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface;
+    IDirectSoundFullDuplexImpl *This = impl_from_IDirectSoundFullDuplex(iface);
     ULONG ref = InterlockedIncrement(&(This->ref));
     TRACE("(%p) ref was %d\n", This, ref - 1);
     return ref;
@@ -457,7 +477,7 @@ IDirectSoundFullDuplexImpl_QueryInterface(
     REFIID riid,
     LPVOID* ppobj )
 {
-    IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface;
+    IDirectSoundFullDuplexImpl *This = impl_from_IDirectSoundFullDuplex(iface);
     TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj );
 
     if (ppobj == NULL) {
@@ -516,7 +536,7 @@ IDirectSoundFullDuplexImpl_QueryInterface(
 static ULONG WINAPI
 IDirectSoundFullDuplexImpl_Release( LPDIRECTSOUNDFULLDUPLEX iface )
 {
-    IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface;
+    IDirectSoundFullDuplexImpl *This = impl_from_IDirectSoundFullDuplex(iface);
     ULONG ref = InterlockedDecrement(&(This->ref));
     TRACE("(%p) ref was %d\n", This, ref - 1);
 
@@ -544,7 +564,7 @@ IDirectSoundFullDuplexImpl_Initialize(
     LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer8 )
 {
     HRESULT hr;
-    IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface;
+    IDirectSoundFullDuplexImpl *This = impl_from_IDirectSoundFullDuplex(iface);
 
     TRACE("(%p,%s,%s,%p,%p,%p,%x,%p,%p)\n", This,
         debugstr_guid(pCaptureGuid), debugstr_guid(pRendererGuid),
@@ -644,7 +664,7 @@ HRESULT DSOUND_FullDuplexCreate(
         return DSERR_OUTOFMEMORY;
     }
 
-    This->lpVtbl = &dsfdvt;
+    This->IDirectSoundFullDuplex_iface.lpVtbl = &dsfdvt;
     This->ref = 1;
     This->capture_device = NULL;
     This->renderer_device = NULL;
-- 
1.7.3.2



More information about the wine-patches mailing list