Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Jul 1997 09:03:12 +0200 (MET DST)
From:      oliver.fromme@heim3.tu-clausthal.de (Oliver Fromme)
To:        hasty@rah.star-gate.com (Amancio Hasty)
Cc:        multimedia@freebsd.org
Subject:   Re: guspnp9: /dev/dsp close() hangs
Message-ID:  <199707140703.JAA18049@elch.heim4.tu-clausthal.de>
In-Reply-To: <199707140406.VAA01095@rah.star-gate.com> from "Amancio Hasty" at Jul 13, 97 09:06:53 pm

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

Amancio Hasty wrote:
 > In sb_dsp_close:
 > Move down sb_free_irq to after dsp_cleanup.
 > 
 >    /* DMAbuf_close_dma (dev); */
 >     /* sb_dsp_command (0xd4); */
 >     dsp_cleanup();
 >     sb_free_irq();

Am I also supposed to comment out the DMAbuf_close_dma?

I just moved sb_free_irq down, as you suggested, in both
sb_dsp.c and sb16_dsp.c.  The latter now looks like this
(remember, this is FreeBSD 2.2.2):

  sb_dsp_command01 (0xd9);
  sb_dsp_command01 (0xd5);

  DISABLE_INTR (flags);
  RELEASE_DMA_CHN (dma8);

  if (dma16 != dma8)
    RELEASE_DMA_CHN (dma16);
  dsp_cleanup ();
  sb_free_irq ();
  dsp_busy = 0;
  RESTORE_INTR (flags);

It doesn't seem to fix the problem.
I spent the past 2 hours testing:  On about 20% of all
44 kHz files, the 10 seconds block occurs at the close,
and on about 4% of all 22 kHz files (all of that 16 bit
stereo, on my AWE32).

The follwoing shell script can be used for testing:

================== cut here ==================
#!/bin/sh -
if [ $# -ne 2 ]; then
	echo "Usage: `basename $0` <count> <file>" >&2
	echo "   <count> = number of attempts" >&2
	echo "   <file>  = mpeg file to play" >&2
	exit 1
fi
ATTEMPT=$1
BLOCKS=0
while [ $ATTEMPT -gt 0 ]; do
	/usr/bin/printf "\rAttempts left: $ATTEMPT (of $1)   "
	mpg123 -q "$2" &
	PID=$!
	sleep 2
	kill -INT $PID
	sleep 1
	if [ `ps -p $PID | wc -l` -gt 1 ]; then
		sleep 5
		if [ `ps -p $PID | wc -l` -gt 1 ]; then
			echo "*** blocks."
			kill -INT $PID
			sleep 1
			if [ `ps -p $PID | wc -l` -gt 1 ]; then
				kill -KILL $PID
			fi
			BLOCKS=`expr $BLOCKS + 1`
		fi
	fi
	ATTEMPT=`expr $ATTEMPT - 1`
done
/usr/bin/printf "\rBlocked $BLOCKS times (out of $1 attempts).   \n"
================== cut here ==================

I'd recommend that you turn the volume on your stereo down,
unless you'd like to hear the first 2 seconds of your mpeg
files 200 times.  ;-)

One side note:  When I change the first "sleep 2" to "sleep 1",
22 kHz files _never_ block, while the behaviour for 44 kHz
remains unchanged.  Increasing the sleep value above 2 doesn't
seem to change anything.

And on another note, I also tried the follwoing: replaced the
mpg123 with pcmplay, playing a 1 or 2 seconds raw pcm file, and
removed the first kill.  Same result, i.e. it's definitely not
a bug in mpg123.

Oliver

PS: pcmplay is part of the audio/tosha FreeBSD port.

-- 
Oliver Fromme, Leibnizstr. 18-61, 38678 Clausthal, Germany
(Info: finger userinfo:olli@dorifer.heim3.tu-clausthal.de)



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