Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 May 2002 15:46:52 +0200 (CEST)
From:      brandt@fokus.gmd.de
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   kern/37831: Half of buffer gets filled with silence when recording
Message-ID:  <200205071346.g47Dkq8X031220@beagle.fokus.gmd.de>

next in thread | raw e-mail | index | archive | help

>Number:         37831
>Category:       kern
>Synopsis:       Half of buffer gets filled with silence when recording
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 07 07:30:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Hartmut Brandt
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
FhI Fokus
>Environment:
System: FreeBSD beagle.fokus.gmd.de 5.0-CURRENT FreeBSD 5.0-CURRENT #38: Tue May 7 11:25:29 CEST 2002 hbb@beagle.fokus.gmd.de:/opt/obj/usr/src/sys/BEAGLE i386


	
>Description:

When recording from a soundcard that supports only 16 bit formats (Emu10k in
this case) with an 8-bit format, half of the buffer gets filled with silence.

This is caused by the feeder mechanism interpreting the count parameter
as the number of bytes to fill in the destination buffer. In the record
case this parameter is the number of bytes that came from the soundcard.
If we are converting from a 16 bit to an 8 bit format, the 16to8 feeder
is called with the number of bytes in the input buffer. It requests from
the root feeder twice that number and the root feeder finding only half
that number of bytes, fills the other half with silence.

	
>How-To-Repeat:

Try to record from a emu10k with AFMT_U8. Observe the output to contain
1kbyte of audio data, 1kbyte of 0200 bytes, 1kbyte of audio data, ...

	
>Fix:

Apply the following patch to /sys/dev/sound/feeder.c. This causes to check
the root feeder, whether the current channel is a recording channel. If it
is not, don't append silence if the buffer contains lesser bytes than requested.

Index: feeder.c
===================================================================
RCS file: /usr/ncvs/src/sys/dev/sound/pcm/feeder.c,v
retrieving revision 1.21
diff -u -r1.21 feeder.c
--- feeder.c	26 Jan 2002 22:13:24 -0000	1.21
+++ feeder.c	7 May 2002 13:35:50 -0000
@@ -393,11 +393,13 @@
 		printf("appending %d bytes\n", count - l);
 */
 
-	x = (sndbuf_getfmt(src) & AFMT_SIGNED)? 0 : 0x80;
-	while (l < count)
-		buffer[l++] = x;
-
-	return count;
+	if (ch->direction != PCMDIR_REC) {
+		x = (sndbuf_getfmt(src) & AFMT_SIGNED)? 0 : 0x80;
+		while (l < count)
+			buffer[l++] = x;
+		return count;
+	} else
+		return (l);
 }
 
 static kobj_method_t feeder_root_methods[] = {
	

>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200205071346.g47Dkq8X031220>