dsound error return patch

Robert Reif reif at earthlink.net
Thu Sep 9 19:50:41 CDT 2004


Return error from low level driver when necessary.

-------------- next part --------------
Index: dlls/dsound/buffer.c
===================================================================
RCS file: /home/wine/wine/dlls/dsound/buffer.c,v
retrieving revision 1.35
diff -u -r1.35 buffer.c
--- dlls/dsound/buffer.c	9 Sep 2004 20:17:08 -0000	1.35
+++ dlls/dsound/buffer.c	10 Sep 2004 00:39:01 -0000
@@ -207,6 +207,7 @@
 ) {
 	IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
 	LONG oldVol;
+	HRESULT hres = DS_OK;
 
 	TRACE("(%p,%ld)\n",This,vol);
 
@@ -235,7 +236,6 @@
 
 	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 @@
 	LeaveCriticalSection(&(This->lock));
 	/* **** */
 
-	return DS_OK;
+	return hres;
 }
 
 static HRESULT WINAPI IDirectSoundBufferImpl_GetVolume(
@@ -795,6 +795,7 @@
 ) {
 	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 @@
 	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(
Index: dlls/dsound/primary.c
===================================================================
RCS file: /home/wine/wine/dlls/dsound/primary.c,v
retrieving revision 1.33
diff -u -r1.33 primary.c
--- dlls/dsound/primary.c	9 Sep 2004 20:17:08 -0000	1.33
+++ dlls/dsound/primary.c	10 Sep 2004 00:39:02 -0000
@@ -775,7 +775,7 @@
 	IDirectSoundImpl* dsound = This->dsound;
 	DWORD ampfactors;
 	DSVOLUMEPAN volpan;
-        HRESULT hres;
+        HRESULT hres = DS_OK;
 
 	TRACE("(%p,%ld)\n",This,pan);
 
@@ -803,8 +803,7 @@
                 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 @@
 	LeaveCriticalSection(&(dsound->mixlock));
 	/* **** */
 
-	return DS_OK;
+	return hres;
 }
 
 static HRESULT WINAPI PrimaryBufferImpl_GetPan(


More information about the wine-patches mailing list