From owner-freebsd-bugs Tue May 7 7:30:21 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 3F77F37B403 for ; Tue, 7 May 2002 07:30:02 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g47EU2q88551; Tue, 7 May 2002 07:30:02 -0700 (PDT) (envelope-from gnats) Received: from mailhub.fokus.gmd.de (mailhub.fokus.gmd.de [193.174.154.14]) by hub.freebsd.org (Postfix) with ESMTP id 024E537B405 for ; Tue, 7 May 2002 07:23:01 -0700 (PDT) Received: from beagle.fokus.gmd.de (beagle [193.175.132.100]) by mailhub.fokus.gmd.de (8.11.6/8.11.6) with ESMTP id g47EMo413900 for ; Tue, 7 May 2002 16:22:56 +0200 (MEST) Received: from beagle.fokus.gmd.de (localhost [127.0.0.1]) by beagle.fokus.gmd.de (8.12.3/8.12.3) with ESMTP id g47EMn7H036183 for ; Tue, 7 May 2002 16:22:50 +0200 (CEST) (envelope-from hbb@beagle.fokus.gmd.de) Received: (from root@localhost) by beagle.fokus.gmd.de (8.12.3/8.12.3/Submit) id g47Dkq8X031220; Tue, 7 May 2002 15:46:52 +0200 (CEST) Message-Id: <200205071346.g47Dkq8X031220@beagle.fokus.gmd.de> Date: Tue, 7 May 2002 15:46:52 +0200 (CEST) From: brandt@fokus.gmd.de Reply-To: brandt@fokus.gmd.de To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/37831: Half of buffer gets filled with silence when recording Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >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