[DSOUND] always allocate an empty buffer

Robert Reif reif at earthlink.net
Wed Feb 9 19:01:07 CST 2005


Always allocate an empty buffer.
-------------- next part --------------
Index: dlls/dsound/buffer.c
===================================================================
RCS file: /home/wine/wine/dlls/dsound/buffer.c,v
retrieving revision 1.44
diff -u -p -r1.44 buffer.c
--- dlls/dsound/buffer.c	9 Feb 2005 14:05:00 -0000	1.44
+++ dlls/dsound/buffer.c	10 Feb 2005 00:52:56 -0000
@@ -1084,17 +1084,18 @@ HRESULT WINAPI IDirectSoundBufferImpl_Cr
 	/* FIXME: check whether any hardware buffers are left */
 	/* FIXME: handle DSDHEAP_CREATEHEAP for hardware buffers */
 
-	/* Allocate system memory if applicable */
-	if ((ds->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY) || !use_hw) {
-		dsb->buffer = HeapAlloc(GetProcessHeap(),0,sizeof(*(dsb->buffer)));
-		if (dsb->buffer == NULL) {
-			WARN("out of memory\n");
-			HeapFree(GetProcessHeap(),0,dsb->pwfx);
-			HeapFree(GetProcessHeap(),0,dsb);
-			*pdsb = NULL;
-			return DSERR_OUTOFMEMORY;
-		}
+	/* Allocate an empty buffer */
+	dsb->buffer = HeapAlloc(GetProcessHeap(),0,sizeof(*(dsb->buffer)));
+	if (dsb->buffer == NULL) {
+		WARN("out of memory\n");
+		HeapFree(GetProcessHeap(),0,dsb->pwfx);
+		HeapFree(GetProcessHeap(),0,dsb);
+		*pdsb = NULL;
+		return DSERR_OUTOFMEMORY;
+	}
 
+	/* Allocate system memory for buffer if applicable */
+	if ((ds->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY) || !use_hw) {
 		dsb->buffer->memory = HeapAlloc(GetProcessHeap(),0,dsb->buflen);
 		if (dsb->buffer->memory == NULL) {
 			WARN("out of memory\n");
@@ -1118,15 +1119,6 @@ HRESULT WINAPI IDirectSoundBufferImpl_Cr
 			TRACE("IDsDriver_CreateSoundBuffer failed, falling back to software buffer\n");
 			use_hw = 0;
 			if (ds->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY) {
-				dsb->buffer = HeapAlloc(GetProcessHeap(),0,sizeof(*(dsb->buffer)));
-				if (dsb->buffer == NULL) {
-					WARN("out of memory\n");
-					HeapFree(GetProcessHeap(),0,dsb->pwfx);
-					HeapFree(GetProcessHeap(),0,dsb);
-					*pdsb = NULL;
-					return DSERR_OUTOFMEMORY;
-				}
-
 				dsb->buffer->memory = HeapAlloc(GetProcessHeap(),0,dsb->buflen);
 				if (dsb->buffer->memory == NULL) {
 					WARN("out of memory\n");


More information about the wine-patches mailing list