2007-01-17 07:03:40

by Frédéric DALLEAU

[permalink] [raw]

2007-01-29 03:01:04

by Brad Midgley

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

Robert

Frederic is the one who is writing this. He has had some trouble getting
xmms to play without the sleep() call and it may be related to the pcm
status.

Frederic may have been changing things, but at least in what's there I
don't see any status reporting.

Brad

> On Wednesday 17 January 2007 08:03, Frederic Dalleau wrote:
>> 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?
>
> I had a look at MPlayer to see what it's doing. It sleeps whenever needed, and
> it finds out how long to sleep by looking at the PCM status. I posted the
> following message to alsa-devel, but unfortunately so far nobody answered.
> Maybe someone on this list knows an answer.
>
> Robert
>
> ---------- Forwarded Message ----------
>
> Subject: snd_pcm_status_get_avail() and external I/O plugins
> Date: Thursday 18 January 2007 14:51
> From: Robert Huitl <[email protected]>
> To: [email protected]
>
> Hello,
>
> I have some trouble to get mplayer working with an external pcm I/O plugin
> (a2dp from bluez). The problem is that mplayer needs to know how much space
> is left in the ring buffer:
>
> snd_pcm_status(alsa_handler, status)
> ret = snd_pcm_status_get_avail(status) * bytes_per_sample;
>
> Now with the ALSA kernel driver, ret will vary, depending on how much data
> was written to the device, and how much time passed.
>
> However, with the I/O plugin, snd_pcm_status_get_avail() always returns the
> maximum value (causing mplayer to think that all samples have been played). I
> can't find a callback function for the status in snd_pcm_ioplug_callback_t
> where I could adjust the avail value.
>
> I'd appreciate any hints.
>
> Robert
>
> -------------------------------------------------------------------------
> 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
> _______________________________________________
> Bluez-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/bluez-devel


-------------------------------------------------------------------------
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
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-01-28 19:30:13

by Robert Huitl

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

Hi again,

On Wednesday 17 January 2007 08:03, Frederic Dalleau wrote:
> 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?

I had a look at MPlayer to see what it's doing. It sleeps whenever needed, and
it finds out how long to sleep by looking at the PCM status. I posted the
following message to alsa-devel, but unfortunately so far nobody answered.
Maybe someone on this list knows an answer.

Robert

---------- Forwarded Message ----------

Subject: snd_pcm_status_get_avail() and external I/O plugins
Date: Thursday 18 January 2007 14:51
From: Robert Huitl <[email protected]>
To: [email protected]

Hello,

I have some trouble to get mplayer working with an external pcm I/O plugin
(a2dp from bluez). The problem is that mplayer needs to know how much space
is left in the ring buffer:

snd_pcm_status(alsa_handler, status)
ret = snd_pcm_status_get_avail(status) * bytes_per_sample;

Now with the ALSA kernel driver, ret will vary, depending on how much data
was written to the device, and how much time passed.

However, with the I/O plugin, snd_pcm_status_get_avail() always returns the
maximum value (causing mplayer to think that all samples have been played). I
can't find a callback function for the status in snd_pcm_ioplug_callback_t
where I could adjust the avail value.

I'd appreciate any hints.

Robert

-------------------------------------------------------------------------
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
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-01-18 17:50:34

by Fabien Chevalier

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

Brad Midgley wrote:
> Guys
>
>> 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. :-(
>
> although vlc works, maybe it is using the same execution thread for both
> audio and video and getting i/o blocked. when I switch it to a2dp on an
> older machine, full-motion video goes from smooth to very choppy. this
> is using the 32-bit codec so it shouldn't take that much cpu.
>
> is this just a design problem with alsa that should be worked around in
> players?


I would rather vote for a bug in a2dp plugin. ;-)
Btw, did you try with sco plugin ? Is it better ?

Cheers,

Fabien

-------------------------------------------------------------------------
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
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-01-17 19:15:23

by Brad Midgley

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

Guys

> 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. :-(

although vlc works, maybe it is using the same execution thread for both
audio and video and getting i/o blocked. when I switch it to a2dp on an
older machine, full-motion video goes from smooth to very choppy. this
is using the 32-bit codec so it shouldn't take that much cpu.

is this just a design problem with alsa that should be worked around in
players?

Brad

-------------------------------------------------------------------------
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
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-01-17 18:35:49

by Fabien Chevalier

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

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

-------------------------------------------------------------------------
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
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-01-17 18:05:53

by Robert Huitl

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

On Wednesday 17 January 2007 08:03, Frederic Dalleau wrote:
> Robert,
> The sound is ok in mplayer! But the movie is a bit slow :D ...

Yes exactly :)
And then it prints that message about slow CPU, buggy sound drivers, etc.

> If you plugin is the pcm.!default, then you can workaround the problem by
> outputting audio to esound instead of alsa (see mplayer preferences). Not
> the best, but worked for me. +/- helped having perfect synchronisation with
> movie.

Nice. I will try this, but actually I'd rather not have another sound daemon
(artsd is causing enough problems...)

> Brad,
> 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.

You are talking about this code, aren't you?

static snd_pcm_sframes_t a2dp_transfer2(snd_pcm_ioplug_t * io, char *buf,
int32_t datatoread)
[...]
// The data are sent to the daemon that act as a proxy thus we double
transfer delay to compensate latency
a2dp_timer_notifyframe(&a2dp->TimerInfos);
delay = a2dp_timer_sleep(&a2dp->TimerInfos, 4*A2DPTIMERPREDELAY);

Without really knowing what I was doing, I removed the a2dp_timer_sleep call.
The result: mplayer plays the video as fast as possible (sound was broken, of
course).

So maybe this delay is too long (however decreasing the delay did not improve
things) or should not be there at all.

> Is there a rule to distinguish? Or some magic value to sleep?

I had a look at the io->nonblock variable and compared its value while playing
with mplayer and play (part of sox), but it's 0 for both.

However, mplayer audio output devices implement a function
/* delay in seconds between first and last sample in buffer */
static float get_delay(void)

This function basically calls snd_pcm_delay(), which can be implemented in the
a2dp io plugin. Mplayer calls this function quite frequently, maybe this is
how it knows when to write new audio samples.

Robert

-------------------------------------------------------------------------
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
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-02-02 16:55:01

by Frédéric Dalleau

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

Hi,

I've been trying some things and just uploaded an *a2dpd2* plugin.
Tested the plugin with =

aplay,xmms,amarok,vlc,mocp,kaffeine,mplayer,beep-media-player.
This gave good sound on all except mplayer :( but at least the movie =

speed is now correct. This may be worth a try on another computer.
Not had time to try any gst based player.

reports appreciated.

Fr=E9d=E9ric
PS: Note the type plug/slave.pcm trick is not well supported by =

vlc,mocp,bmp. I used alsa-libs 1.0.13 but this should not be required.

> Frederic is the one who is writing this. He has had some trouble getting
> xmms to play without the sleep() call and it may be related to the pcm
> status.
> =

>>> 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 o=
r at
>>> least don't want to sleep. They need to use that time to do some decodi=
ng
>>> instead. If you sleep too long, the decoding will be defered and the so=
und
>>> or movie will be broken.
>>>
>>> Is there a rule to distinguish? Or some magic value to sleep?
-- =

Frederic

Without the wind, the grass does not move.


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easi=
er.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat=3D1=
21642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-03-27 10:39:41

by Tim Chick

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

On Friday 02 February 2007 16:55, Fr=E9d=E9ric DALLEAU wrote:
> Hi,
>
> I've been trying some things and just uploaded an *a2dpd2* plugin.
> Tested the plugin with
> aplay,xmms,amarok,vlc,mocp,kaffeine,mplayer,beep-media-player.
> This gave good sound on all except mplayer :( but at least the movie
> speed is now correct. This may be worth a try on another computer.
> Not had time to try any gst based player.
>
> reports appreciated.
>

It looks like this stuff is in flux at the moment?

I am using CVS from last night, and I see basically 100% CPU usage from =

a2dpd, with mpg321 and mplayer whilst it is streaming.

On an old version, from a few months ago, I did not see this problem.

This is running on a 400MHz ARM based system, so there should be plenty =

of CPU available.

Thanks,
Tim

-- =

Tim Chick, Applications Engineer - Convergence SBU
CSR, Cambridge, UK - http://www.csr.com



To access the latest news from CSR copy this link into a web browser: http=
://http://www.csr.com/email_sig.php

To get further information regarding CSR, please visit our Investor Relatio=
ns page at http://ir.csr.com/csr/about/overview

-------------------------------------------------------------------------
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=3Djoin.php&p=3Dsourceforge&CID=3DDE=
VDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel