2007-05-26 17:15:39

by Matthias Hensler

[permalink] [raw]
Subject: [Bluez-devel] bluetooth-audio and bug in a2dpd (Patch included)

Hi!

Playing with the current plugz from CVS and a2dpd I experienced a lot of
choppy audio with a BW-HF02 bluetooth audio receiver. I tracked down the
problem to the transmit loop in a2dpd_output_a2dp.c. My receiver has an
own buffer which runs full after around 3-4 seconds. In that case the
write will fail with EAGAIN. The loop should take care of that and
retry, however errno gets lost in the current implementation, so no
single retry is made.

Furthermore there is only one retry round and a too small usleep value.
To make a2dpd finally work without any problems I had to fix the retry
issue, increase the usleep to 150ms and try up to 200 times again. A
patch for this is attached.

Please note that this is only a quick, but no optimal fix. In case of
XMMS for example the spectrum analyzer is not smooth while a2dpd is
spending its time in the loop waiting for the receiver to have some new
free bufferspace.

Without my patch it goes: 4 seconds filling the buffer then breaking
because of a full buffer interrupting the audio for around 1-2 seconds
(the connection to the receiver is closed and opened again).

With my patch it is: 4 seconds filling the buffer, waiting up to 500ms
(spectrum analyzer in XMMS stops), 2-3 seconds filling the buffer
(spectrum analyzer runs smoothly), waiting again for 500ms, and so on.

A proper solution would be to fill the buffer more constantly using a
kind of dynamic adaption (I tried a delay of 10ms after every transmit
which was a satisfying solution for my receiver).

Regards,
Matthias


Attachments:
(No filename) (0.00 B)
(No filename) (286.00 B)
(No filename) (164.00 B)
Download all attachments

2007-05-28 07:44:53

by Frédéric Dalleau

[permalink] [raw]
Subject: Re: [Bluez-devel] bluetooth-audio and bug in a2dpd (Patch included)

Mathias,

Thanks for the patch,
I forgot that DBG was erasing errno, irk...

I integrated it in order to get a working solution but as you said, this =

is not a solution.

> With my patch it is: 4 seconds filling the buffer, waiting up to 500ms
> (spectrum analyzer in XMMS stops), 2-3 seconds filling the buffer
> (spectrum analyzer runs smoothly), waiting again for 500ms, and so on.

This behavior is strange, a2dpd calculate delays precisely ;) Can you =

send me on my private email a whole .a2dprc and logfile, done with =

enabledebug=3D255 in .a2dpdrc?

a2dpd > logfile
press play, wait something like 10 secs then press stop on xmms.
Don't wait too much as this is very verbose (+/- 10mb).

Thanks,
Fr=E9d=E9ric.



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-05-26 23:32:37

by Chris Carlin

[permalink] [raw]
Subject: Re: [Bluez-devel] bluetooth-audio and bug in a2dpd (Patch included)

Matthias Hensler wrote:
> Hi!
>
> Playing with the current plugz from CVS and a2dpd I experienced a lot of
> choppy audio with a BW-HF02 bluetooth audio receiver. I tracked down the
> problem to the transmit loop in a2dpd_output_a2dp.c. My receiver has an
> own buffer which runs full after around 3-4 seconds. In that case the
> write will fail with EAGAIN. The loop should take care of that and
> retry, however errno gets lost in the current implementation, so no
> single retry is made.

Great!

This modification made my Motorola S805 headphones usable and my
Creative CB2530 headphones almost so (neither was usable at all before).

I had a feeling it was something sort of small but I was on the wrong
track with finding the cause for the EAGAIN.

~Chris

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel