From 6f9d41673fdfc9c7e0efb6667b354f7aae991064 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Fri, 10 Sep 2004 19:34:01 +0000 Subject: [PATCH] Return error from low level driver when necessary. --- dlls/dsound/buffer.c | 33 ++++++++++++++++----------------- dlls/dsound/primary.c | 7 +++---- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c index b965ba29f05..85fdde5b36f 100644 --- a/dlls/dsound/buffer.c +++ b/dlls/dsound/buffer.c @@ -207,6 +207,7 @@ static HRESULT WINAPI IDirectSoundBufferImpl_SetVolume( ) { IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface; LONG oldVol; + HRESULT hres = DS_OK; TRACE("(%p,%ld)\n",This,vol); @@ -235,7 +236,6 @@ static HRESULT WINAPI IDirectSoundBufferImpl_SetVolume( if (vol != oldVol) { if (This->hwbuf) { - HRESULT hres; hres = IDsDriverBuffer_SetVolumePan(This->hwbuf, &(This->volpan)); if (hres != DS_OK) WARN("IDsDriverBuffer_SetVolumePan failed\n"); @@ -246,7 +246,7 @@ static HRESULT WINAPI IDirectSoundBufferImpl_SetVolume( LeaveCriticalSection(&(This->lock)); /* **** */ - return DS_OK; + return hres; } static HRESULT WINAPI IDirectSoundBufferImpl_GetVolume( @@ -795,6 +795,7 @@ static HRESULT WINAPI IDirectSoundBufferImpl_Unlock( ) { IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface; DWORD probably_valid_to; + HRESULT hres = DS_OK; TRACE("(%p,%p,%ld,%p,%ld)\n", This,p1,x1,p2,x2); @@ -802,30 +803,28 @@ static HRESULT WINAPI IDirectSoundBufferImpl_Unlock( EnterCriticalSection(&(This->lock)); if (!(This->dsound->drvdesc.dwFlags & DSDDESC_DONTNEEDSECONDARYLOCK) && This->hwbuf) { - HRESULT hres; hres = IDsDriverBuffer_Unlock(This->hwbuf, p1, x1, p2, x2); - if (hres != DS_OK) { - LeaveCriticalSection(&(This->lock)); + if (hres != DS_OK) WARN("IDsDriverBuffer_Unlock failed\n"); - return hres; - } } - if (p2) probably_valid_to = (((LPBYTE)p2)-This->buffer->memory) + x2; - else probably_valid_to = (((LPBYTE)p1)-This->buffer->memory) + x1; - probably_valid_to %= This->buflen; - if ((probably_valid_to == 0) && ((x1+x2) == This->buflen) && - ((This->state == STATE_STARTING) || - (This->state == STATE_PLAYING))) - /* see IDirectSoundBufferImpl_Lock */ - probably_valid_to = (DWORD)-1; - This->probably_valid_to = probably_valid_to; + if (hres == DS_OK) { + if (p2) probably_valid_to = (((LPBYTE)p2)-This->buffer->memory) + x2; + else probably_valid_to = (((LPBYTE)p1)-This->buffer->memory) + x1; + probably_valid_to %= This->buflen; + if ((probably_valid_to == 0) && ((x1+x2) == This->buflen) && + ((This->state == STATE_STARTING) || + (This->state == STATE_PLAYING))) + /* see IDirectSoundBufferImpl_Lock */ + probably_valid_to = (DWORD)-1; + This->probably_valid_to = probably_valid_to; + } LeaveCriticalSection(&(This->lock)); /* **** */ TRACE("probably_valid_to=%ld\n", This->probably_valid_to); - return DS_OK; + return hres; } static HRESULT WINAPI IDirectSoundBufferImpl_Restore( diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c index 4471ace38c4..a28a6bcef7a 100644 --- a/dlls/dsound/primary.c +++ b/dlls/dsound/primary.c @@ -775,7 +775,7 @@ static HRESULT WINAPI PrimaryBufferImpl_SetPan( IDirectSoundImpl* dsound = This->dsound; DWORD ampfactors; DSVOLUMEPAN volpan; - HRESULT hres; + HRESULT hres = DS_OK; TRACE("(%p,%ld)\n",This,pan); @@ -803,8 +803,7 @@ static HRESULT WINAPI PrimaryBufferImpl_SetPan( hres = IDsDriverBuffer_SetVolumePan(dsound->hwbuf, &volpan); if (hres != DS_OK) WARN("IDsDriverBuffer_SetVolumePan failed\n"); - } - else { + } else { ampfactors = (volpan.dwTotalLeftAmpFactor & 0xffff) | (volpan.dwTotalRightAmpFactor << 16); waveOutSetVolume(dsound->hwo, ampfactors); } @@ -813,7 +812,7 @@ static HRESULT WINAPI PrimaryBufferImpl_SetPan( LeaveCriticalSection(&(dsound->mixlock)); /* **** */ - return DS_OK; + return hres; } static HRESULT WINAPI PrimaryBufferImpl_GetPan( -- 2.11.4.GIT