Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Jul 1997 06:53:52 +0200 (MET DST)
From:      oliver.fromme@heim3.tu-clausthal.de (Oliver Fromme)
To:        multimedia@freebsd.org
Subject:   Re: dma handling in the sound driver
Message-ID:  <199707210453.GAA13291@elch.heim4.tu-clausthal.de>
In-Reply-To: <199707210328.UAA00494@rah.star-gate.com> from "Amancio Hasty" at Jul 20, 97 08:28:52 pm

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

Hello,

Just a small comment/question...

Amancio Hasty wrote:
 > [...]
 > SNDCTL_DSP_SETFRAGMENT
 > sets the block of io which the sub modules use to send or receive
 > data.
 > 
 > SNDCTL_DSP_SETBLKSIZE
 > for all practical purposes is the same as the above.
 > 
 > If the user does not set the block size then the dma routines choses
 > a size equal to about 1/2 second worth of data. For typical sun
 > style au files this is 4096 bytes .

I am currently facing the following problem:  I am writing a
frontend for mpg123 (MPEG audio player).  When the user
presses the Pause/Stop button (or Fast Forward or whatever),
there's always a small delay -- I guess it is because of that
1/2 second DMA buffer.  However, I'd like the audio to stop
_immediately_ when a button is pressed, not 1/2 second later
or something like that.

There are probably two solutions:

 - Using one of the above ioctls to reduce the buffer block
   size (about 1/10 or maybe 1/5 second would be acceptable).
   However, that probably increases the risk that the audio
   playback is interrupted because the buffer can't be filled
   in time by the application.  This might especially be a
   problem on slower CPUs, and/or if several other processes
   are running in parallel.

 - Tell the audio device somehow to stop playback, and (in case
   of Fast Forward) forget the rest of the buffered data.  (In
   the latter case, it would be an additional bonus if the
   audio device could tell the application how much data was
   discarded.)  -- However, as far as I know, this isn't
   possible, is it?

Any suggestions and helpful hints are greatly appreciated.

Regards
   Oliver

PS: On Solaris, I solved the problem like this:  By doing a
write() with 0 bytes, a special "mark" is inserted in the
buffer.  When the playback has reached that mark, a signal
(SIGPOLL) is delivered to the process, so we know how much data
has been actually played.  Furthermore, the device supports
"pausing" by setting a flag (AUDIO_SETINFO ioctl), and it can
flush the remaining audio data from its buffer (I_FLUSH STREAMS
ioctl).

-- 
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?199707210453.GAA13291>