From nobody@FreeBSD.ORG  Tue Aug  1 04:55:29 2000
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id AC9CB37BCE1; Tue,  1 Aug 2000 04:55:29 -0700 (PDT)
Message-Id: <20000801115529.AC9CB37BCE1@hub.freebsd.org>
Date: Tue,  1 Aug 2000 04:55:29 -0700 (PDT)
From: shirai@nintendo.co.jp
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@FreeBSD.org
Subject: SNDCTL_DSP_GETODELAY on pcm device is incorrectly implemented.
X-Send-Pr-Version: www-1.0

>Number:         20340
>Category:       kern
>Synopsis:       SNDCTL_DSP_GETODELAY on pcm device is incorrectly implemented.
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    cg
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 01 05:00:01 PDT 2000
>Closed-Date:    Mon Mar 26 22:11:08 PST 2001
>Last-Modified:  Mon Mar 26 22:11:45 PST 2001
>Originator:     Takashi SHIRAI
>Release:        4-STABLE
>Organization:
Nintendo, Co., Ltd.
>Environment:
FreeBSD 4-STABLE
>Description:
According to OSS Programmer's Guide (http://www.opensound.com/pguide/),
SNDCTL_DSP_GETODELAY returns the number of unplayed bytes in the
kernel buffer. It means the length of ready areas (rl). But, in
the latest implement, this call returns the total bytes played
already. It is certainly mis-implement.
>How-To-Repeat:
Use any audio applications which use SNDCTL_DSP_GETODELAY.
e.g. TiMidity++ (>= 3.5.1)
>Fix:
The following patch will be effective:
diff -u dsp.c.old dsp.c
--- dsp.c.old   Tue Aug  1 04:36:13 2000
+++ dsp.c       Tue Aug  1 20:18:08 2000
@@ -587,12 +587,13 @@
        case SNDCTL_DSP_GETODELAY:
                if (wrch) {
                        snd_dbuf *b = &wrch->buffer;
+                       snd_dbuf *bs = &wrch->buffer2nd;
                        if (b->dl) {
                                chn_checkunderflow(wrch);
                                if (!(wrch->flags & CHN_F_MAPPED))
                                        while (chn_wrfeed(wrch) > 0);
                        }
-                       *arg = b->total;
+                       *((int *)arg) = bs->rl;
                } else
                        ret = EINVAL;
                break;

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->cg 
Responsible-Changed-By: sheldonh 
Responsible-Changed-When: Tue Aug 1 05:09:02 PDT 2000 
Responsible-Changed-Why:  
Over to the pcm maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=20340 
State-Changed-From-To: open->closed 
State-Changed-By: cg 
State-Changed-When: Mon Mar 26 22:11:08 PST 2001 
State-Changed-Why:  
fixed 

http://www.freebsd.org/cgi/query-pr.cgi?pr=20340 
>Unformatted:
