[PATCH 7/7] dsound: Remove dependency on renderer implementation in duplex.c

Maarten Lankhorst (none) mlankhorst at patser.
Sat Nov 14 10:26:08 CST 2009


---
 dlls/dsound/duplex.c |  120 ++++++++++++++++++++++++++-----------------------
 1 files changed, 64 insertions(+), 56 deletions(-)

diff --git a/dlls/dsound/duplex.c b/dlls/dsound/duplex.c
index b228d3c..b792077 100644
--- a/dlls/dsound/duplex.c
+++ b/dlls/dsound/duplex.c
@@ -49,7 +49,7 @@ typedef struct IDirectSoundFullDuplexImpl
     LONG                              ref;
 
     /* IDirectSoundFullDuplexImpl fields */
-    DirectSoundDevice                *renderer_device;
+    IDirectSound8 *renderer_device;
     IDirectSoundCapture *capture_device;
 
     const IUnknownVtbl *lpUnkVtbl;
@@ -142,7 +142,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_CreateSoundBuffer(
 {
     ICOM_THIS_MULTI(IDirectSoundFullDuplexImpl,lpDSVtbl,iface);
     TRACE("(%p,%p,%p,%p)\n",This,dsbd,ppdsb,lpunk);
-    return DirectSoundDevice_CreateSoundBuffer(This->renderer_device,dsbd,ppdsb,lpunk,FALSE);
+    return IDirectSound8_CreateSoundBuffer(This->renderer_device,dsbd,ppdsb,lpunk);
 }
 
 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_GetCaps(
@@ -151,7 +151,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_GetCaps(
 {
     ICOM_THIS_MULTI(IDirectSoundFullDuplexImpl,lpDSVtbl,iface);
     TRACE("(%p,%p)\n",This,lpDSCaps);
-    return DirectSoundDevice_GetCaps(This->renderer_device, lpDSCaps);
+    return IDirectSound8_GetCaps(This->renderer_device, lpDSCaps);
 }
 
 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_DuplicateSoundBuffer(
@@ -161,7 +161,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_DuplicateSoundBuffer(
 {
     ICOM_THIS_MULTI(IDirectSoundFullDuplexImpl,lpDSVtbl,iface);
     TRACE("(%p,%p,%p)\n",This,psb,ppdsb);
-    return DirectSoundDevice_DuplicateSoundBuffer(This->renderer_device,psb,ppdsb);
+    return IDirectSound8_DuplicateSoundBuffer(This->renderer_device,psb,ppdsb);
 }
 
 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_SetCooperativeLevel(
@@ -171,7 +171,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_SetCooperativeLevel(
 {
     ICOM_THIS_MULTI(IDirectSoundFullDuplexImpl,lpDSVtbl,iface);
     TRACE("(%p,%p,%s)\n",This,hwnd,dumpCooperativeLevel(level));
-    return DirectSoundDevice_SetCooperativeLevel(This->renderer_device,hwnd,level);
+    return IDirectSound8_SetCooperativeLevel(This->renderer_device,hwnd,level);
 }
 
 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_Compact(
@@ -179,7 +179,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_Compact(
 {
     ICOM_THIS_MULTI(IDirectSoundFullDuplexImpl,lpDSVtbl,iface);
     TRACE("(%p)\n", This);
-    return DirectSoundDevice_Compact(This->renderer_device);
+    return IDirectSound8_Compact(This->renderer_device);
 }
 
 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_GetSpeakerConfig(
@@ -188,7 +188,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_GetSpeakerConfig(
 {
     ICOM_THIS_MULTI(IDirectSoundFullDuplexImpl,lpDSVtbl,iface);
     TRACE("(%p, %p)\n", This, lpdwSpeakerConfig);
-    return DirectSoundDevice_GetSpeakerConfig(This->renderer_device,lpdwSpeakerConfig);
+    return IDirectSound8_GetSpeakerConfig(This->renderer_device,lpdwSpeakerConfig);
 }
 
 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_SetSpeakerConfig(
@@ -197,7 +197,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_SetSpeakerConfig(
 {
     ICOM_THIS_MULTI(IDirectSoundFullDuplexImpl,lpDSVtbl,iface);
     TRACE("(%p,0x%08x)\n",This,config);
-    return DirectSoundDevice_SetSpeakerConfig(This->renderer_device,config);
+    return IDirectSound8_SetSpeakerConfig(This->renderer_device,config);
 }
 
 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_Initialize(
@@ -206,7 +206,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound_Initialize(
 {
     ICOM_THIS_MULTI(IDirectSoundFullDuplexImpl,lpDSVtbl,iface);
     TRACE("(%p, %s)\n", This, debugstr_guid(lpcGuid));
-    return DirectSoundDevice_Initialize(&This->renderer_device,lpcGuid);
+    return IDirectSound8_Initialize(This->renderer_device,lpcGuid);
 }
 
 static const IDirectSoundVtbl DirectSoundFullDuplex_DirectSound_Vtbl =
@@ -263,7 +263,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_CreateSoundBuffer(
 {
     ICOM_THIS_MULTI(IDirectSoundFullDuplexImpl,lpDS8Vtbl,iface);
     TRACE("(%p,%p,%p,%p)\n",This,dsbd,ppdsb,lpunk);
-    return DirectSoundDevice_CreateSoundBuffer(This->renderer_device,dsbd,ppdsb,lpunk,TRUE);
+    return IDirectSound8_CreateSoundBuffer(This->renderer_device,dsbd,ppdsb,lpunk);
 }
 
 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_GetCaps(
@@ -272,7 +272,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_GetCaps(
 {
     ICOM_THIS_MULTI(IDirectSoundFullDuplexImpl,lpDS8Vtbl,iface);
     TRACE("(%p,%p)\n",This,lpDSCaps);
-    return DirectSoundDevice_GetCaps(This->renderer_device, lpDSCaps);
+    return IDirectSound8_GetCaps(This->renderer_device, lpDSCaps);
 }
 
 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_DuplicateSoundBuffer(
@@ -282,7 +282,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_DuplicateSoundBuffer(
 {
     ICOM_THIS_MULTI(IDirectSoundFullDuplexImpl,lpDS8Vtbl,iface);
     TRACE("(%p,%p,%p)\n",This,psb,ppdsb);
-    return DirectSoundDevice_DuplicateSoundBuffer(This->renderer_device,psb,ppdsb);
+    return IDirectSound8_DuplicateSoundBuffer(This->renderer_device,psb,ppdsb);
 }
 
 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_SetCooperativeLevel(
@@ -292,7 +292,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_SetCooperativeLevel(
 {
     ICOM_THIS_MULTI(IDirectSoundFullDuplexImpl,lpDS8Vtbl,iface);
     TRACE("(%p,%p,%s)\n",This,hwnd,dumpCooperativeLevel(level));
-    return DirectSoundDevice_SetCooperativeLevel(This->renderer_device,hwnd,level);
+    return IDirectSound8_SetCooperativeLevel(This->renderer_device,hwnd,level);
 }
 
 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_Compact(
@@ -300,7 +300,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_Compact(
 {
     ICOM_THIS_MULTI(IDirectSoundFullDuplexImpl,lpDS8Vtbl,iface);
     TRACE("(%p)\n", This);
-    return DirectSoundDevice_Compact(This->renderer_device);
+    return IDirectSound8_Compact(This->renderer_device);
 }
 
 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_GetSpeakerConfig(
@@ -309,7 +309,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_GetSpeakerConfig(
 {
     ICOM_THIS_MULTI(IDirectSoundFullDuplexImpl,lpDS8Vtbl,iface);
     TRACE("(%p, %p)\n", This, lpdwSpeakerConfig);
-    return DirectSoundDevice_GetSpeakerConfig(This->renderer_device,lpdwSpeakerConfig);
+    return IDirectSound8_GetSpeakerConfig(This->renderer_device,lpdwSpeakerConfig);
 }
 
 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_SetSpeakerConfig(
@@ -318,7 +318,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_SetSpeakerConfig(
 {
     ICOM_THIS_MULTI(IDirectSoundFullDuplexImpl,lpDS8Vtbl,iface);
     TRACE("(%p,0x%08x)\n",This,config);
-    return DirectSoundDevice_SetSpeakerConfig(This->renderer_device,config);
+    return IDirectSound8_SetSpeakerConfig(This->renderer_device,config);
 }
 
 static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_Initialize(
@@ -327,7 +327,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_Initialize(
 {
     ICOM_THIS_MULTI(IDirectSoundFullDuplexImpl,lpDS8Vtbl,iface);
     TRACE("(%p, %s)\n", This, debugstr_guid(lpcGuid));
-    return DirectSoundDevice_Initialize(&This->renderer_device,lpcGuid);
+    return IDirectSound8_Initialize(This->renderer_device,lpcGuid);
 }
 
 static const IDirectSound8Vtbl DirectSoundFullDuplex_DirectSound8_Vtbl =
@@ -477,7 +477,7 @@ IDirectSoundFullDuplexImpl_Release( LPDIRECTSOUNDFULLDUPLEX iface )
         if (This->capture_device)
             IDirectSoundCapture_Release(This->capture_device);
         if (This->renderer_device)
-            DirectSoundDevice_Release(This->renderer_device);
+            IDirectSound8_Release(This->renderer_device);
         HeapFree( GetProcessHeap(), 0, This );
 	TRACE("(%p) released\n", This);
     }
@@ -498,68 +498,63 @@ IDirectSoundFullDuplexImpl_Initialize(
 {
     HRESULT hr;
     IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface;
-    IDirectSoundBufferImpl * dsb;
-    IDirectSoundCaptureBuffer *buf;
+    IDirectSoundBuffer *dsb = NULL;
+    IDirectSoundCaptureBuffer *buf = NULL;
+    DSBUFFERDESC desc;
 
     TRACE("(%p,%s,%s,%p,%p,%p,%x,%p,%p)\n", This,
         debugstr_guid(pCaptureGuid), debugstr_guid(pRendererGuid),
         lpDscBufferDesc, lpDsBufferDesc, hWnd, dwLevel,
         lplpDirectSoundCaptureBuffer8, lplpDirectSoundBuffer8);
 
+    *lplpDirectSoundCaptureBuffer8 = NULL;
+    *lplpDirectSoundBuffer8 = NULL;
+
     if (This->renderer_device != NULL || This->capture_device != NULL) {
         WARN("already initialized\n");
-        *lplpDirectSoundCaptureBuffer8 = NULL;
-        *lplpDirectSoundBuffer8 = NULL;
         return DSERR_ALREADYINITIALIZED;
     }
 
-    hr = DirectSoundDevice_Initialize(&This->renderer_device, pRendererGuid);
+    hr = DSOUND_Create8(&IID_IDirectSound8, &This->renderer_device);
+    if (SUCCEEDED(hr))
+        hr = IDirectSound_Initialize(This->renderer_device, pRendererGuid);
     if (hr != DS_OK) {
         WARN("DirectSoundDevice_Initialize() failed\n");
-        *lplpDirectSoundCaptureBuffer8 = NULL;
-        *lplpDirectSoundBuffer8 = NULL;
-        return hr;
+        goto err;
     }
+    IDirectSound8_SetCooperativeLevel(This->renderer_device, hWnd, dwLevel);
 
-    if (dwLevel==DSSCL_PRIORITY || dwLevel==DSSCL_EXCLUSIVE) {
-        WARN("level=%s not fully supported\n",
-             dwLevel==DSSCL_PRIORITY ? "DSSCL_PRIORITY" : "DSSCL_EXCLUSIVE");
+    /* Failing to set primary is not a sin.. */
+    desc = *lpDsBufferDesc;
+    desc.dwFlags = DSBCAPS_PRIMARYBUFFER;
+    desc.lpwfxFormat = NULL;
+    hr = IDirectSound8_CreateSoundBuffer(This->renderer_device, &desc, &dsb, NULL);
+    if (SUCCEEDED(hr))
+    {
+        IDirectSoundBuffer_SetFormat(dsb, lpDsBufferDesc->lpwfxFormat);
+        IDirectSoundBuffer_Release(dsb);
     }
-    This->renderer_device->priolevel = dwLevel;
 
-    hr = DSOUND_PrimarySetFormat(This->renderer_device, lpDsBufferDesc->lpwfxFormat, dwLevel == DSSCL_EXCLUSIVE);
+    hr = IDirectSound8_CreateSoundBuffer(This->renderer_device, lpDsBufferDesc, &dsb, NULL);
     if (hr != DS_OK) {
-        WARN("DSOUND_PrimarySetFormat() failed\n");
-        *lplpDirectSoundCaptureBuffer8 = NULL;
-        *lplpDirectSoundBuffer8 = NULL;
-        return hr;
+        WARN("CreateSoundBuffer() failed\n");
+        goto err;
     }
-    hr = IDirectSoundBufferImpl_Create(This->renderer_device, &dsb, lpDsBufferDesc);
+    hr = IUnknown_QueryInterface(dsb, &IID_IDirectSoundBuffer8, (void **)lplpDirectSoundBuffer8);
     if (hr != DS_OK) {
-        WARN("IDirectSoundBufferImpl_Create() failed\n");
-        *lplpDirectSoundCaptureBuffer8 = NULL;
-        *lplpDirectSoundBuffer8 = NULL;
-        return hr;
+        WARN("IDirectSoundBuffer8_QueryInterface() failed\n");
+        goto err;
     }
-
-    hr = SecondaryBufferImpl_Create(dsb, (SecondaryBufferImpl **)lplpDirectSoundBuffer8);
-    if (hr != DS_OK) {
-        WARN("SecondaryBufferImpl_Create() failed\n");
-        *lplpDirectSoundCaptureBuffer8 = NULL;
-        *lplpDirectSoundBuffer8 = NULL;
-        return hr;
-    }
-    IDirectSoundBuffer8_AddRef(*lplpDirectSoundBuffer8);
+    IUnknown_Release(dsb);
+    dsb = NULL;
 
     hr = DSOUND_CaptureCreate8(&IID_IDirectSoundCapture, &This->capture_device);
 
     if (SUCCEEDED(hr))
         hr = IDirectSoundCapture_Initialize(This->capture_device, pCaptureGuid);
     if (hr != DS_OK) {
-        WARN("DirectSoundCaptureDevice_Initialize() failed\n");
-        *lplpDirectSoundCaptureBuffer8 = NULL;
-        *lplpDirectSoundBuffer8 = NULL;
-        return hr;
+        WARN("IDirectSoundCapture_Initialize() failed\n");
+        goto err;
     }
 
     hr = IDirectSoundCapture_CreateCaptureBuffer(This->capture_device,
@@ -571,12 +566,25 @@ IDirectSoundFullDuplexImpl_Initialize(
     }
     if (hr != DS_OK) {
         WARN("IDirectSoundCaptureBufferImpl_Create() failed\n");
-        *lplpDirectSoundCaptureBuffer8 = NULL;
-        *lplpDirectSoundBuffer8 = NULL;
-        return hr;
+        goto err;
     }
 
     return hr;
+
+err:
+    if (dsb)
+        IUnknown_Release(dsb);
+    if (*lplpDirectSoundCaptureBuffer8)
+        IUnknown_Release(*lplpDirectSoundCaptureBuffer8);
+    if (*lplpDirectSoundBuffer8)
+        IUnknown_Release(*lplpDirectSoundBuffer8);
+    if (This->renderer_device)
+        IUnknown_Release(This->renderer_device);
+    if (This->capture_device)
+        IUnknown_Release(This->capture_device);
+    This->renderer_device = NULL;
+    This->capture_device = NULL;
+    return hr;
 }
 
 static const IDirectSoundFullDuplexVtbl dsfdvt =
-- 
1.6.5.2


--------------040101000905030701060102--



More information about the wine-patches mailing list