[gst-devel] Linux audio is a mess? [was: JACK and GStreamer, from the horse's mouth]
Wim Taymans
wim at fluendo.com
Thu Nov 30 17:29:40 CET 2006
On Thu, 2006-11-30 at 13:10 -0300, Edgard Lima wrote:
> Hi Paul,
>
> ok, Im a bit late on this discussion (on vacation), but...
>
> if you want to implement a pull based audiosink easily just look at
> sdlaudiosink (in gst-plugins-bad)
>
> we don't "write" to the device, instead a callback named
> "fill_this_buffer" is called
>
> the only thing you have to do is use a LOCK to protect producer and
> consumer, like this:
>
> filesrc -> decoder -> sdlaudiosink
>
> in closer look
>
> "decoder" writes to a ringbuffer and will be blocked when it is full.
> (we are in push mode here and not problem at all)
>
> from the sdlaudiosink what we do is to write data from this ringbuffer
> to a temporary buffer and them send to device when the callback is
> called, like this:
>
> func_write_from_ring_buffer_to_temp_buffer() {
> lock(A)
> memcpy(temp_buffer, ring_buffer)
> unlock(B)
> }
>
> func_sdl_callback_fill_my_buffer(*buff) {
> lock(B)
> memcpy(buff, temp_buff);
> unlock(A);
> }
>
> if the return of "func_sdl_callback_fill_my_buffer" is too late, them
> silent will be played.
>
> I dont know about JACK, so please comment this approach, does it work
> for you?
Just had a look at SDL audiosink. It's entirely not needed to use locks
around the ringbuffer. Also, the SDL audioosink does not seem to use a
ringbuffer at all, instead the data is passed between GStreamer and SDL
using a buffer of exactly one segment. This means a context switch
(forced because of the lock) for each segment exchanged between
gstreamer and SDL. You can improve SDL audiosink enormously by taking a
look at how jackaudiosink is implemented (hint, extend
GstBaseAudioSink).
Wim
>
> BR,
> Edgard
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
--
Wim Taymans <wim at fluendo.com>
More information about the gstreamer-devel
mailing list