From owner-freebsd-multimedia Mon Jul 14 08:41:30 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id IAA27547 for multimedia-outgoing; Mon, 14 Jul 1997 08:41:30 -0700 (PDT) Received: from rah.star-gate.com (rah.star-gate.com [204.188.121.18]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id IAA27542 for ; Mon, 14 Jul 1997 08:41:27 -0700 (PDT) Received: from rah.star-gate.com (localhost.star-gate.com [127.0.0.1]) by rah.star-gate.com (8.8.5/8.8.5) with ESMTP id IAA04661; Mon, 14 Jul 1997 08:41:21 -0700 (PDT) Message-Id: <199707141541.IAA04661@rah.star-gate.com> X-Mailer: exmh version 2.0gamma 1/27/96 To: oliver.fromme@heim3.tu-clausthal.de (Oliver Fromme) cc: multimedia@freebsd.org Subject: Re: guspnp9: /dev/dsp close() hangs In-reply-to: Your message of "Mon, 14 Jul 1997 09:03:12 +0200." <199707140703.JAA18049@elch.heim4.tu-clausthal.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 14 Jul 1997 08:41:21 -0700 From: Amancio Hasty Sender: owner-multimedia@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Hi, This is the way that the code is supposed to look like: /* DMAbuf_close_dma (dev); */ /* sb_dsp_command (0xd4); */ dsp_cleanup(); sb_free_irq(); dsp_speaker(OFF); sb_dsp_busy = 0; sb_dsp_highspeed = 0; open_mode = 0; } Now if the code still hangs it just simply mean that we are either missing an interrupt or dma_sync never finished syncing all the buffers. Amancio >From The Desk Of Oliver Fromme : > > 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` " >&2 > echo " = number of attempts" >&2 > echo " = 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)