[alsa-devel] Alsa and Gstreamer?

Radivoje Jovanovic radivojejovanovic at gmail.com
Tue Dec 28 00:08:56 CET 2010


Hi,
I have the stereo driver working on my system. If I try playing wave files
with aplay everything works just fine. The problem shows up when I try
playing movies through gstreamer. When I play the movie (I have 2 decoders ,
many movies and they all behave the same) the sound comes choppy. If I add
following change in the pcm_lib.c file snd_pcm_lib_write1 method.:
if ((err = transfer(substream, appl_ofs, data, offset, frames)) < 0) //NO
CHANGE
            goto _end; //NO CHANGE
//THIS IS THE  LINE I ADDED THAT INVALIDATES CACHE SO DMA IS 100% CORRECT
dma_sync_single_range_for_device(0, runtime->dma_buffer_p->addr , 0,
runtime->dma_buffer_p->bytes, DMA_TO_DEVICE);
I must say that memory allocation in my driver is done through
snd_pcm_lib_preallocate_pages_for_all and I am not sure why would data be
stuck in cache, so I cannot explain why this line makes the difference.

Now if I play just sound part in the gstreamer like this:

gst-launch-0.10 filesrc location=MY_MOVIE.mp4 ! qtdemux name=t ! queue !
faad ! alsasink

the sound plays just fine.

Also, if I play just video part it plays just fine. But if I play audio and
video together like this:
gst-launch-0.10 filesrc location=MY_MOVIE.mp4 ! qtdemux name=t ! queue  !
my_decoder ! my_video_sink t. ! queue ! faad ! alsasink

the whole clip plays much faster (if video is 36 seconds long now it will
last 25 seconds. Of course video and audio skip a lot).
Does anyone have an idea where can I even start looking for a problem?
Cheers,
Ogi


More information about the Alsa-devel mailing list