NetBSD Problem Report #38493

From reed@reedmedia.net  Wed Apr 23 22:15:28 2008
Return-Path: <reed@reedmedia.net>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id C72E763B874
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 23 Apr 2008 22:15:28 +0000 (UTC)
Message-Id: <7329-1208988910@reedmedia.net>
Date: Wed, 23 Apr 2008 17:15:11 -0500
From: reed@reedmedia.net
Reply-To: reed@reedmedia.net
To: gnats-bugs@gnats.NetBSD.org
Subject: no good audio with cdplay
X-Send-Pr-Version: 3.95

>Number:         38493
>Category:       bin
>Synopsis:       no good audio with cdplay
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Apr 23 22:20:00 +0000 2008
>Closed-Date:    Sat Dec 31 03:48:36 +0000 2022
>Last-Modified:  Sat Dec 31 03:48:36 +0000 2022
>Originator:     reed@reedmedia.net
>Release:        NetBSD 4.99.55
>Organization:
  Jeremy C. Reed
>Environment:


System: NetBSD tx.reedmedia.net 4.99.55 NetBSD 4.99.55 (GENERIC) #1: Mon Mar 17 13:16:38 CDT 2008 reed@tx.reedmedia.net:/usr/src/obj/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
I have Toshiba Satellite A215-S7422 running NetBSD/amd64 4.99.55.
I have used cdplay many times ever since it was available -- just not on 
this system.

cdparanioa works fine to rip. (file says one track is "Claris clip art?" 
another is "RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, 
stereo 44100 Hz"

audioplay works fine to play these ripped tracks.

I use:  mixerctl -w outputs.black15.eapd=on

I have:

azalia0: codec[0] has no audio function groups
audio0 at azalia0: full duplex, independent
audio1 at pad0: half duplex

My cd is:

cd0 at atapibus0 drive 0: <MATSHITADVD-RAM UJ-850S, HB88  482625, 1.21> 
cdrom removable
cd0: 32-bit data port
cd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 2 (Ultra/33)
cd0(ixpide1:0:0): using PIO mode 4, Ultra-DMA mode 2 (Ultra/33) (using 
DMA)
cd0(ixpide1:0:0):  Check Condition on CDB: 0x28 00 00 00 00 00 00 00 01 00
cd0: dos partition I/O error
cd0: transfer error, downgrading to Ultra-DMA mode 1
cd0(ixpide1:0:0): using PIO mode 4, Ultra-DMA mode 1 (using DMA)

cdplay won't work for me. No audio. (mplayer and ogg123 and audioplay all 
work for audio for me.)

I also use "digital" from interactive mode and it shows:

digital xfer:   to /dev/sound (5 frames per wakeup, 0.33330s period)

(and then doesn't show the left and right volumes.)

play shows:

cdplay: scsi cmd failed: retsts 1 status 0

cdplay: scsi cmd failed: retsts 3 status 2

status shows it is playing and also I can hear the hardware doing 
something.

I also tried many different digital "frame" numbers.
I was able to hear some sporadic, choopy music with:
25, 20, 15, 10, 12. But I can't repeat and I tried many different
numbers beyond those from 1 to 50.

Also if I use interactive mode, sometimes running stop or digital multiple 
times have no effect until I quit and re-run cdplay.
>How-To-Repeat:

>Fix:


>Release-Note:

>Audit-Trail:
From: Matthias Drochner <M.Drochner@fz-juelich.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: bin/38493: no good audio with cdplay 
Date: Sat, 26 Apr 2008 17:21:02 +0200

 reed@reedmedia.net said:
 > I have Toshiba Satellite A215-S7422 running NetBSD/amd64 4.99.55. I
 > have used cdplay many times ever since it was available -- just not on
 >  this system. 

 It seems that on modern laptops there is no analogue connection
 between the CD drive and the soundcards.

 > I also use "digital" from interactive mode

 Fwiw, the "digital" feature of cdplay has never worked for me,
 on any machine. "cdda2wav -q -e -N" works.

 best regards
 Matthias




 -------------------------------------------------------------------
 -------------------------------------------------------------------
 Forschungszentrum Juelich GmbH
 52425 Juelich

 Sitz der Gesellschaft: Juelich
 Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
 Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
 Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
 Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr. Harald Bolt,
 Dr. Sebastian M. Schmidt
 -------------------------------------------------------------------
 -------------------------------------------------------------------

From: Mark Davies <mark@mcs.vuw.ac.nz>
To: M.Drochner@fz-juelich.de
Cc: gnats-bugs@netbsd.org
Subject: Re: bin/38493: no good audio with cdplay
Date: Sun, 27 Apr 2008 09:28:31 +1200

 On Sunday 27 April 2008 03:21:02 Matthias Drochner wrote:
 > It seems that on modern laptops there is no analogue connection
 > between the CD drive and the soundcards.

 And modern desktops. Haven't had it on Dell Optiplex Desktop's since about 
 the GX280 days, as well as on Latitude laptops.

 > Fwiw, the "digital" feature of cdplay has never worked for me,
 > on any machine.

 Or for me.

 cheers
 mark

From: Sergey Svishchev <svs@ropnet.ru>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/38493: no good audio with cdplay
Date: Sat, 17 May 2008 14:32:06 +0400

 On Wed, Apr 23, 2008 at 10:20:00PM +0000, reed@reedmedia.net wrote:

 >cdplay won't work for me. No audio. (mplayer and ogg123 and audioplay all 
 >work for audio for me.)

 While I have no fix for your problem at the moment, there's definitely
 a problem in cdplay; it shows up when you stop and then restart playback
 ('pause'/'resume' commands) -- kernel discards all audio samples for a time,
 as documented in audio(4).  The fix:

 --- cdplay.c	17 Dec 2006 21:47:53 -0000	1.34.2.1
 +++ cdplay.c	12 May 2008 16:51:10 -0000
 @@ -1344,7 +1348,7 @@
  		da.afd = -1;
  		return (0);
  	}
 -	ai.mode = AUMODE_PLAY;
 +	ai.mode = AUMODE_PLAY_ALL;
  	ai.play.sample_rate = 44100;
  	ai.play.channels = 2;
  	ai.play.precision = 16;

 -- 
 Sergey Svishchev

From: Matthias Drochner <M.Drochner@fz-juelich.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org,
	reed@reedmedia.net
Subject: Re: bin/38493: no good audio with cdplay 
Date: Mon, 14 Jul 2008 14:22:28 +0200

 This is a multipart MIME message.

 --==_Exmh_6896404818000
 Content-Type: text/plain; charset=us-ascii


 svs@ropnet.ru said:
 >  -	ai.mode = AUMODE_PLAY;
 >  +	ai.mode = AUMODE_PLAY_ALL; 

 Thanks - this improves the "resume" for me too.
 Here is an aggregate patch which also fixes some other
 problems:
 -The timeout for the raw SCSI command to read audio data
  is much too small. This caused complete failure for me.
 -"digital 1" does not work, at least with HZ=100.
  (The signal handler can't keep up.)
 -"digital 20" or so leads to poor interactive behaviour
  (because the program blocks most of the time in the
   signal handler)
 With that patch, digital mode is usable for me.
 (This code is a mess and should be rewritten, but
 not before 5.0 imo.)

 best regards
 Matthias





 -------------------------------------------------------------------
 -------------------------------------------------------------------
 Forschungszentrum Juelich GmbH
 52425 Juelich

 Sitz der Gesellschaft: Juelich
 Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
 Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
 Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
 Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr. Harald Bolt,
 Dr. Sebastian M. Schmidt
 -------------------------------------------------------------------
 -------------------------------------------------------------------

 --==_Exmh_6896404818000
 Content-Type: text/plain ; name="cdplay.txt"; charset=us-ascii
 Content-Description: cdplay.txt
 Content-Disposition: attachment; filename="cdplay.txt"

 #
 # old_revision [b0293fd440ffeb0cc85778a3a79fcbb762e17b78]
 #
 # patch "usr.bin/cdplay/cdplay.c"
 #  from [97aad6bcf900d21ed7d4dea09dfce00aa70d314e]
 #    to [d976096f1ed56cbf03af1c70350d0d3484e50413]
 #
 ============================================================
 --- usr.bin/cdplay/cdplay.c	97aad6bcf900d21ed7d4dea09dfce00aa70d314e
 +++ usr.bin/cdplay/cdplay.c	d976096f1ed56cbf03af1c70350d0d3484e50413
 @@ -483,7 +483,7 @@ run(int cmd, const char *arg)

  	case CMD_DIGITAL:
  		if (digital == 0) {
 -			int fpw;
 +			int fpw, intv_usecs, hz_usecs;

  			fpw = atoi(arg);
  			if (fpw > 0)
 @@ -491,6 +491,23 @@ run(int cmd, const char *arg)
  			else
  				da.fpw = 5;
  			da.read_errors = 0;
 +
 +			/* real rate: 75 frames per second */
 +			intv_usecs = 13333 * da.fpw;
 +			/*
 +			 * interrupt earlier for safety, by a value which
 +			 * doesn't hurt interactice response if we block
 +			 * in the signal handler
 +			 */
 +			intv_usecs -= 50000;
 +			hz_usecs = 1000000 / sysconf(_SC_CLK_TCK);
 +			if (intv_usecs < hz_usecs) {
 +				/* can't have a shorter interval, increase
 +				   buffer size to compensate */
 +				da.fpw += (hz_usecs - intv_usecs) / 13333;
 +				intv_usecs = hz_usecs;
 +			}
 +
  			da.aubuf = malloc(da.fpw * CDDA_SIZE);
  			if (da.aubuf == NULL) {
  				warn("Not enough memory for audio buffers");
 @@ -500,9 +517,10 @@ run(int cmd, const char *arg)
  				warn("Cannot open audio device");
  				return (1);
  			}
 -			itv_timer.it_interval.tv_sec = itv_timer.it_value.tv_sec = da.fpw / 75;
 +			itv_timer.it_interval.tv_sec = itv_timer.it_value.tv_sec =
 +				intv_usecs / 1000000;
  			itv_timer.it_interval.tv_usec = itv_timer.it_value.tv_usec =
 -			    (da.fpw * 6666) % 1000000;
 +				intv_usecs % 1000000;
  			rv = setitimer(ITIMER_REAL, &itv_timer, NULL);
  			if (rv == 0) {
  				digital = 1;
 @@ -932,7 +950,8 @@ print_status(const char *arg)
  	else
  		printf("shuffle play:\t%s\n", (shuffle != 0) ? "on" : "off");
  	if (digital)
 -		printf("digital xfer:\tto %s (%d frames per wakeup, %ld.%03lds period)\n",
 +		printf("digital xfer:\tto %s "
 +		       "(%d frames per wakeup, %ld.%06lds period)\n",
  		    da.auname, da.fpw, itv_timer.it_interval.tv_sec,
  		    itv_timer.it_interval.tv_usec);
  	else
 @@ -1346,7 +1365,7 @@ openaudio()
  		da.afd = -1;
  		return (0);
  	}
 -	ai.mode = AUMODE_PLAY;
 +	ai.mode = AUMODE_PLAY_ALL;
  	ai.play.sample_rate = 44100;
  	ai.play.channels = 2;
  	ai.play.precision = 16;
 @@ -1387,7 +1406,7 @@ readaudio(afd, lba, blocks, data)
  	sc.datalen = CDDA_SIZE * blocks;
  	sc.senselen = sizeof(sc.sense);
  	sc.flags = SCCMD_READ;
 -	sc.timeout = da.fpw * 15;
 +	sc.timeout = 10000; /* 10s */
  	rc = ioctl(afd, SCIOCCOMMAND, &sc);
  	if (rc < 0 || sc.retsts != SCCMD_OK) {
  		if (da.read_errors < 10) {

 --==_Exmh_6896404818000--

From: "Jeremy C. Reed" <reed@reedmedia.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/38493: no good audio with cdplay 
Date: Mon, 14 Jul 2008 09:22:58 -0500 (CDT)

 Thank you Matthias and Sergey. With today's patches, I can finally listen 
 to CDs with cdplay. It does start with a little popping/missing audio, but 
 appears to get better/sound better over about 15 seconds. I tested with 
 two CDs.

 Can you commit this?

From: Matthias Drochner <M.Drochner@fz-juelich.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org,
	reed@reedmedia.net
Subject: Re: bin/38493: no good audio with cdplay 
Date: Mon, 14 Jul 2008 18:24:41 +0200

 reed@reedmedia.net said:
 > It does start with a little popping/missing audio, but 
 >  appears to get better/sound better over about 15 seconds.

 Hmm - there could be some interaction with the audio
 buffer and its low/high water marks. The writing should adapt
 to the audio speed instead of using a fixed blocksize and
 timer interval. I don't have a good idea how to do that
 without changing the code structure.
 Does it help to use larger blocks, eg "digital 10"
 or "digital 20"? (At about 30 a limitation of the
 VM system is hit - raw SCSI commands cannot exceed
 MAXPHYS=64k bytes.)
 Does it have a positive effect for you to remove
 the sched_yield() call in sig_timer(). I don't think
 that makes much sense.

 > Can you commit this?
 Yes, but be should do some finetuning before.

 best regards
 Matthias




 -------------------------------------------------------------------
 -------------------------------------------------------------------
 Forschungszentrum Juelich GmbH
 52425 Juelich

 Sitz der Gesellschaft: Juelich
 Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
 Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
 Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
 Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr. Harald Bolt,
 Dr. Sebastian M. Schmidt
 -------------------------------------------------------------------
 -------------------------------------------------------------------

From: "Jeremy C. Reed" <reed@reedmedia.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/38493: no good audio with cdplay 
Date: Wed, 16 Jul 2008 09:19:44 -0500 (CDT)

 >  > It does start with a little popping/missing audio, but 
 >  >  appears to get better/sound better over about 15 seconds.
 >  
 >  Hmm - there could be some interaction with the audio
 >  buffer and its low/high water marks. The writing should adapt
 >  to the audio speed instead of using a fixed blocksize and
 >  timer interval. I don't have a good idea how to do that
 >  without changing the code structure.
 >  Does it help to use larger blocks, eg "digital 10"

 digital 10 works good (including with your patch).

 >  > Can you commit this?
 >  Yes, but be should do some finetuning before.

 Okay. As it is now with your patch it seems good. Before the audio was 
 unusable. Thanks again.

From: "Jeremy C. Reed" <reed@reedmedia.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/38493: no good audio with cdplay 
Date: Wed, 16 Jul 2008 09:31:09 -0500 (CDT)

 On Wed, 16 Jul 2008, Jeremy C. Reed wrote:

 >  >  Does it help to use larger blocks, eg "digital 10"
 >  
 >  digital 10 works good (including with your patch).

 I spoke too soon -- I was using cdplay without your patch. After listening 
 for about five minutes, it started popping / skipping again a lot (many 
 times a second) with periodic good quality.

 digital 10 made it sound worse with your patch. I went back to default (5 
 frames per wakeup, 0.016665s period). And it sounded a lot better (with 
 your patch).

From: Matthias Drochner <drochner@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/38493 CVS commit: src/usr.bin/cdplay
Date: Wed, 16 Jul 2008 17:26:25 +0000 (UTC)

 Module Name:	src
 Committed By:	drochner
 Date:		Wed Jul 16 17:26:25 UTC 2008

 Modified Files:
 	src/usr.bin/cdplay: cdplay.c

 Log Message:
 some improvements to digital play mode:
 -use AUMODE_PLAY_ALL, from Sergey Svishchev -- this might cause
  stuttering if the write to audio can't keep up, but it avoids pauses
  if the audio buffer drains out on stop/resume
 -The timeout for the raw SCSI command to read audio data
  was too small, causing complete failure for me.
 -Since the itimer can't do faster than HZ, a too small buffer doesn't
  work. Try to calculate a sensible buffer size.
 -While it makes sense to deliver data a bit faster than necessary,
  it should be not that much that the blocking in the signal handler
  hurts interactive response. Allow for 50ms.
 -Comment out a sched_yield() in the signal handler - this doesn't
  look right.
 This is far from being perfect, but it makes digital mode usable for me.
 And for Jeremy C. Reed, the author of PR bin/38493.


 To generate a diff of this commit:
 cvs rdiff -r1.38 -r1.39 src/usr.bin/cdplay/cdplay.c

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

From: Matthias Drochner <M.Drochner@fz-juelich.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org,
	reed@reedmedia.net
Subject: Re: bin/38493: no good audio with cdplay 
Date: Wed, 16 Jul 2008 19:29:47 +0200

 reed@reedmedia.net said:
 >  digital 10 made it sound worse with your patch. I went back to
 > default (5 
 >  frames per wakeup, 0.016665s period). And it sounded a lot better
 > (with 
 >  your patch). 

 OK, so I've left the default at 5 and committed the rest.
 If you feel so, you could try to turn knobs and see what
 helps and what not...

 best regards
 Matthias




 -------------------------------------------------------------------
 -------------------------------------------------------------------
 Forschungszentrum Juelich GmbH
 52425 Juelich

 Sitz der Gesellschaft: Juelich
 Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
 Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
 Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
 Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr. Harald Bolt,
 Dr. Sebastian M. Schmidt
 -------------------------------------------------------------------
 -------------------------------------------------------------------

State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 31 Dec 2022 03:48:36 +0000
State-Changed-Why:
The patches here were committed in 2008 (14 years ago!) -- assume the
problem is fixed.

If you have a remaining problem (which is probably entirely different
anyway) please file a new PR.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: gnats-precook-prs,v 1.4 2018/12/21 14:20:20 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.