Module: wine Branch: master Commit: 6a7c2f66e0569d2419eb9619e78716a9a5f94966 URL: http://source.winehq.org/git/wine.git/?a=commit;h=6a7c2f66e0569d2419eb9619e7...
Author: Andrew Eikum aeikum@codeweavers.com Date: Mon Oct 17 14:52:23 2011 -0500
dsound: Don't make the capture buffer object address public until it is prepared.
---
dlls/dsound/capture.c | 23 ++++++++--------------- 1 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/dlls/dsound/capture.c b/dlls/dsound/capture.c index 92dc24f..9e289f3 100644 --- a/dlls/dsound/capture.c +++ b/dlls/dsound/capture.c @@ -680,6 +680,7 @@ static HRESULT IDirectSoundCaptureBufferImpl_Create( LPCDSCBUFFERDESC lpcDSCBufferDesc) { LPWAVEFORMATEX wfex; + IDirectSoundCaptureBufferImpl *This; TRACE( "(%p,%p,%p)\n", device, ppobj, lpcDSCBufferDesc);
if (ppobj == NULL) { @@ -687,15 +688,15 @@ static HRESULT IDirectSoundCaptureBufferImpl_Create( return DSERR_INVALIDPARAM; }
+ *ppobj = NULL; + if (!device) { WARN("not initialized\n"); - *ppobj = NULL; return DSERR_UNINITIALIZED; }
if (lpcDSCBufferDesc == NULL) { WARN("invalid parameter: lpcDSCBufferDesc == NULL\n"); - *ppobj = NULL; return DSERR_INVALIDPARAM; }
@@ -704,7 +705,6 @@ static HRESULT IDirectSoundCaptureBufferImpl_Create( (lpcDSCBufferDesc->dwBufferBytes == 0) || (lpcDSCBufferDesc->lpwfxFormat == NULL) ) { /* FIXME: DSERR_BADFORMAT ? */ WARN("invalid lpcDSCBufferDesc\n"); - *ppobj = NULL; return DSERR_INVALIDPARAM; }
@@ -717,23 +717,19 @@ static HRESULT IDirectSoundCaptureBufferImpl_Create( wfex->wBitsPerSample, wfex->cbSize);
device->pwfx = DSOUND_CopyFormat(wfex); - if ( device->pwfx == NULL ) { - *ppobj = NULL; + if ( device->pwfx == NULL ) return DSERR_OUTOFMEMORY; - }
- *ppobj = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, + This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, sizeof(IDirectSoundCaptureBufferImpl));
- if ( *ppobj == NULL ) { + if ( This == NULL ) { WARN("out of memory\n"); - *ppobj = NULL; return DSERR_OUTOFMEMORY; } else { HRESULT err = DS_OK; LPBYTE newbuf; DWORD buflen; - IDirectSoundCaptureBufferImpl *This = *ppobj;
This->ref = 1; This->device = device; @@ -749,7 +745,6 @@ static HRESULT IDirectSoundCaptureBufferImpl_Create( WARN("no memory\n"); This->device->capture_buffer = 0; HeapFree( GetProcessHeap(), 0, This ); - *ppobj = NULL; return DSERR_OUTOFMEMORY; }
@@ -762,7 +757,6 @@ static HRESULT IDirectSoundCaptureBufferImpl_Create( HeapFree(GetProcessHeap(), 0, This->pdscbd); This->device->capture_buffer = 0; HeapFree( GetProcessHeap(), 0, This ); - *ppobj = NULL; return err; }
@@ -776,7 +770,6 @@ static HRESULT IDirectSoundCaptureBufferImpl_Create( HeapFree(GetProcessHeap(), 0, This->pdscbd); This->device->capture_buffer = 0; HeapFree( GetProcessHeap(), 0, This ); - *ppobj = NULL; return err; }
@@ -789,7 +782,6 @@ static HRESULT IDirectSoundCaptureBufferImpl_Create( HeapFree(GetProcessHeap(), 0, This->pdscbd); This->device->capture_buffer = 0; HeapFree( GetProcessHeap(), 0, This ); - *ppobj = NULL; return err; }
@@ -807,13 +799,14 @@ static HRESULT IDirectSoundCaptureBufferImpl_Create( HeapFree(GetProcessHeap(), 0, This->pdscbd); This->device->capture_buffer = 0; HeapFree( GetProcessHeap(), 0, This ); - *ppobj = NULL; return DSERR_OUTOFMEMORY; } device->buffer = newbuf; device->buflen = buflen; }
+ *ppobj = This; + TRACE("returning DS_OK\n"); return DS_OK; }