Re: [Bluez-devel] RE : a2dpd and mplayer - any chance to get it working?

Fabien Chevalier
2007-01-17T18:35:49Z

Hi Frederic, i think can help you for the second part:

> I was wondering about alsa plugins :
> xmms relies on alsa timing to play, so in the plugin, there is a sleep() call, this will wait a little bit until it is time to retievre new data.
> But it seems some players (like mplayer) wants to do their own timing or at least don't want to sleep. They need to use that time to do some decoding instead. If you sleep too long, the decoding will be defered and the sound or movie will be broken.
>
> Is there a rule to distinguish? Or some magic value to sleep?

The key idea is that ALSA applications expect ALSA to run on a hardware
device that implements a ring buffer as a mean of transferring data from
ALSA to the device.
This ring buffer is divided into small chunks, called 'periods'.
ALSA API is expected to block the caller when the ring buffer is full,
and unblock it when some room is freed. The size of the buffer, as well
as the period size is up to the application to select so that it best
fits its needs.

What you've done in the a2dp pcm plugin(if i understood well) is to
throttle the application using sleep. But that does not emulate the ring
buffer behaviour well enough, so it breaks MPlayer. :-(

Some more details can be found here :
http://www.alsa-project.org/alsa-doc/alsa-lib/pcm.html

Cheers,

Fabien