NetBSD Problem Report #52459

From www@NetBSD.org  Thu Aug  3 04:00:43 2017
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id F20397A182
	for <gnats-bugs@gnats.NetBSD.org>; Thu,  3 Aug 2017 04:00:42 +0000 (UTC)
Message-Id: <20170803040042.3EE4B7A1F5@mollari.NetBSD.org>
Date: Thu,  3 Aug 2017 04:00:42 +0000 (UTC)
From: isaki@NetBSD.org
Reply-To: isaki@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: audio_fill_silence() stops playback.
X-Send-Pr-Version: www-1.0

>Number:         52459
>Category:       kern
>Synopsis:       audio_fill_silence() stops playback.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    nat
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 03 04:05:00 +0000 2017
>Closed-Date:    Fri Oct 27 20:52:21 +0000 2017
>Last-Modified:  Fri Oct 27 20:52:21 +0000 2017
>Originator:     Tetsuya Isaki
>Release:        NetBSD-current
>Organization:
NetBSD
>Environment:
NetBSD 8.99.1 x68k
>Description:
If the audio play chain enters audio_fill_silence() in
audio_pint() even once, playback stops.

The audio play chain is:
- audiostartp() calls mix_write().
- mix_write() calls hw_if->start_output().
- start_output() calls audio_pint() if DMA transfer is done.

and then current audio_pint() does:
  :
  if (available datasize < blksize) {
    audio_fill_silence()
  } else {
    mix_write()
  }
  :

So if the available data is not enough even once,
mix_write() is not called anymore and audio playback stops.
I think that it should call mix_write() even if it calls
audio_fill_silence().

Index: sys/dev/audio.c
===================================================================
RCS file: /cvsroot/src/sys/dev/audio.c,v
retrieving revision 1.384
diff -u -r1.384 audio.c
--- sys/dev/audio.c	30 Jul 2017 02:41:58 -0000	1.384
+++ sys/dev/audio.c	3 Aug 2017 03:32:41 -0000
@@ -3691,12 +3691,10 @@
 			    vc->sc_mpr.s.inp, cc);
 			used -= cc;
 		}
-		goto wake_mix;
 	}

 	mix_write(sc);

-wake_mix:
 	cv_broadcast(&sc->sc_condvar);
 }


>How-To-Repeat:
I don't know how to repeat on your environment.
>Fix:
See above patch.

>Release-Note:

>Audit-Trail:
From: Tetsuya Isaki <isaki@pastel-flower.jp>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@netbsd.org,	gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org
Subject: Re: kern/52459: audio_fill_silence() stops playback.
Date: Sat, 05 Aug 2017 15:24:39 +0900

 At Thu,  3 Aug 2017 04:05:00 +0000 (UTC),
 > >How-To-Repeat:

 x68k's vs(4) (20170805) can easily repeat this
 in a few seconds after playback starts.
 ---
 Tetsuya Isaki <isaki@pastel-flower.jp / isaki@NetBSD.org>



Responsible-Changed-From-To: kern-bug-people->nat
Responsible-Changed-By: nat@NetBSD.org
Responsible-Changed-When: Sun, 06 Aug 2017 09:56:28 +0000
Responsible-Changed-Why:
Take.


From: "Nathanial Sloss" <nat@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/52459 CVS commit: src/sys/dev
Date: Sun, 6 Aug 2017 10:07:31 +0000

 Module Name:	src
 Committed By:	nat
 Date:		Sun Aug  6 10:07:31 UTC 2017

 Modified Files:
 	src/sys/dev: audio.c

 Log Message:
 Ensure to call mix write if inserting silence into the hw ring.

 Addresses PR kern/52459.

 Patch provided and tested by isaki@.


 To generate a diff of this commit:
 cvs rdiff -u -r1.386 -r1.387 src/sys/dev/audio.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/52459 CVS commit: [netbsd-8] src/sys/dev
Date: Thu, 31 Aug 2017 11:10:37 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Thu Aug 31 11:10:37 UTC 2017

 Modified Files:
 	src/sys/dev [netbsd-8]: audio.c

 Log Message:
 Pull up following revision(s) (requested by nat in ticket #238):
 	sys/dev/audio.c: revision 1.392
 	sys/dev/audio.c: revision 1.386
 	sys/dev/audio.c: revision 1.387
 Reset mixer ports on opening /dev/sound.
 This fixes an issue reported on port-arm@ by Brian Buhrow.

 Ensure to call mix write if inserting silence into the hw ring.
 Addresses PR kern/52459.
 Patch provided and tested by isaki@.

 If the harware ring is starved of data...Insert silence into the mix ring
 so mix_write can function properly.


 To generate a diff of this commit:
 cvs rdiff -u -r1.357.2.4 -r1.357.2.5 src/sys/dev/audio.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: nat@NetBSD.org
State-Changed-When: Fri, 27 Oct 2017 20:52:21 +0000
State-Changed-Why:
This has been fixed.  Thanks for the analysis, patch and PR!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.