dsound fix in wineoss

eric pouech eric.pouech at wanadoo.fr
Sat Aug 18 10:34:35 CDT 2001


for some (unexplained yet reasons), my libc implementation for memset
reads the content of the buffer it's supposed to fill
since the buffer passed in dsound init has only write access (it's
needed
for OSS in order to know it's a buffer for recording or playing), some
seg fault occurs

I wrote it the easiest way (I don't think it's worth adding a configure
test for that)

so I replaced the memset by a hand made equivalent

(btw: libc 2.1.3 as shipped by Mandrake 7.2 ; bug has been submitted to
Mdk QA site, still waiting for some acknowledgement)

A+
-- 
---------------
Eric Pouech (http://perso.wanadoo.fr/eric.pouech/)
"The future will be better tomorrow", Vice President Dan Quayle
-------------- next part --------------
Name: ds_ms
ChangeLog: replaced memset by hand made equivalent to work around some buggy memset implementations
GenDate: 2001/08/18 15:24:00 UTC
ModifiedFiles: dlls/winmm/wineoss/audio.c
AddedFiles: 
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/dlls/winmm/wineoss/audio.c,v
retrieving revision 1.43
diff -u -u -r1.43 audio.c
--- dlls/winmm/wineoss/audio.c	2001/07/25 00:43:32	1.43
+++ dlls/winmm/wineoss/audio.c	2001/08/15 11:21:34
@@ -1322,8 +1335,32 @@
 	}
 	TRACE("(%p): sound device has been mapped for direct access at %p, size=%ld\n", dsdb, wwo->mapping, wwo->maplen);
 
-	/* for some reason, es1371 and sblive! sometimes have junk in here. */
-	memset(wwo->mapping,0,wwo->maplen); /* clear it, or we get junk noise */
+	/* for some reason, es1371 and sblive! sometimes have junk in here.
+	 * clear it, or we get junk noise */
+	/* some libc implementations are buggy: their memset reads from the buffer...
+	 * to work around it, we have the 0 the block by hand and do not call:
+	 * memset(wwo->mapping,0,wwo->maplen); 
+	 */
+	{
+	    char*	p1 = wwo->mapping;
+	    unsigned	len = wwo->maplen;
+
+	    if (len >= 16) /* so we can have at least a 4 longs to store... */
+	    {
+		/* the mmap:ed value is (at least) dword aligned
+		 * so, start filling the complete unsigned long:s 
+		 */
+		int		b = len >> 2;
+		unsigned long*	p4 = (unsigned long*)p1;
+
+		while (b--) *p4++ = 0;
+		/* prepare for filling the rest */
+		len &= 3;
+		p1 = (unsigned char*)p4;
+	    }
+	    /* in all cases, fill the remaining bytes */
+	    while (len-- != 0) *p1++ = 0;
+	}
     }
     return DS_OK;
 }


More information about the wine-patches mailing list