[pulseaudio-discuss] pulseaudio a2dp disconnect problem

Eytan Naim neytan at marvell.com
Sun Aug 16 03:26:18 PDT 2015


Hi Tanu,

Thanks for your advice and cooperation.

As a result of the loopback_module asymmetric oddity, I compared "pacmd list" output command between two states (you can see attached files):

1.       After connection establishment, and before streaming starts.

2.       After streaming stops.



If the application would run normally I would expect to find similar output. – but for some reason the Bluetooth card change its active_profile from a2dp_sink to off, so, I assumed this may be the problem.

So after digging a little bit in the code, I found a condition in the ./src/modules/bluetooth/module-bluetooth-policy.c  that include all profiles except mine(a2dp source).
So I decided to apply the following hunk, to prevent the card changing its profile (it seemed reasonable for me, because all other profile are included in this condition).

Do you know this Bluetooth code? Does it make sense? Is there anyone I can ask to confirm it?



static pa_hook_result_t profile_available_hook_callback(pa_core *c, pa_card_profile *profile, void *userdata) {

    pa_card *card;

    const char *s;

    bool is_active_profile;

    pa_card_profile *selected_profile;



    pa_assert(c);

    pa_assert(profile);

    pa_assert_se((card = profile->card));



    /* Only consider bluetooth cards */

    s = pa_proplist_gets(card->proplist, PA_PROP_DEVICE_BUS);

    if (!s || !pa_streq(s, "bluetooth"))

        return PA_HOOK_OK;



    /* Do not automatically switch profiles for headsets, just in case */

    /* TODO: remove a2dp and hsp when we remove BlueZ 4 support */

    if (pa_streq(profile->name, "hsp") || pa_streq(profile->name, "a2dp") || pa_streq(profile->name, "a2dp_sink") ||

-         pa_streq(profile->name, "a2dp_source") || pa_streq(profile->name, "headset_head_unit"))

+        pa_streq(profile->name, "headset_head_unit")) {

        return PA_HOOK_OK;

…



It seemed it worked ☺, but the freezing issue still there ☹.

When an a2dp connection is lost, pa would freeze when trying to reconnect and reload the Bluetooth modules.



gdb output:

(gdb) thread apply all bt



Thread 1 (process 1998):

#0  arm_modulus (p=1031, m=123328564) at ./ldso/ldso/arm/dl-sysdep.h:29

#1  _dl_lookup_sysv_hash (type_class=<optimized out>,

    undef_name=<optimized out>, hash=123328564, symtab=0xb6d0f3ec,

    tpnt=0xb6fc5508) at ldso/ldso/dl-hash.c:255

#2  _dl_find_hash (

    name=name at entry=0xbec1b5c0 "module_bluez5_device_LTX_pa__get_deprecated",

    scope=<optimized out>, mytpnt=mytpnt at entry=0x0,

    type_class=type_class at entry=-2147483648, sym_ref=sym_ref at entry=0xbec1b558)

    at ldso/ldso/dl-hash.c:339

#3  0xb6d86b1c in do_dlsym (caller_address=<optimized out>,

    name=0xbec1b5c0 "module_bluez5_device_LTX_pa__get_deprecated",

    vhandle=<optimized out>) at ldso/libdl/libdl.c:733

#4  dlsym (vhandle=<optimized out>,

    name=0xbec1b5c0 "module_bluez5_device_LTX_pa__get_deprecated")

    at ldso/libdl/libdl.c:765

#5  0x000116d8 in bind_now_find_sym (d=<optimized out>, m=<optimized out>,

    symbol=<optimized out>) at daemon/ltdl-bind-now.c:101

#6  0xb6e039b8 in lt_dlsym () from /usr/lib/libltdl.so.7

#7  0xb6f5b400 in pa_load_sym (handle=0x5e8f8,

    module=module at entry=0xb686247a "module-bluez5-device",

    symbol=0xb6fa3121 "pa__get_deprecated") at pulsecore/ltdl-helper.c:42

---Type <return> to continue, or q <return> to quit---

#8  0xb6f5d128 in pa_module_load (c=0x24f00,

    name=0xb686247a "module-bluez5-device",

    argument=argument at entry=0x5e2b0 "path=/org/bluez/hci0/dev_98_D6_F7_34_98_E8") at pulsecore/module.c:151

#9  0xb6861ee0 in device_connection_changed_cb (y=<optimized out>, d=0x50bb8,

    u=0x38950) at modules/bluetooth/module-bluez5-discover.c:77

#10 0xb6f5b1a4 in pa_hook_fire (hook=0x37840, data=0x50bb8)

    at pulsecore/hook-list.c:104

#11 0xb684f8cc in endpoint_set_configuration (m=m at entry=0x50f10,

    userdata=userdata at entry=0x37830, conn=<optimized out>)

    at modules/bluetooth/bluez5-util.c:1313

#12 0xb684fcdc in endpoint_handler (c=<optimized out>, m=m at entry=0x50f10,

    userdata=userdata at entry=0x37830) at modules/bluetooth/bluez5-util.c:1517

#13 0xb6ddf800 in _dbus_object_tree_dispatch_and_unlock (tree=0x399e0,

    message=message at entry=0x50f10, found_object=found_object at entry=0xbec1b99c)

    at dbus-object-tree.c:1018

#14 0xb6dd1104 in dbus_connection_dispatch (connection=0x39c28)

    at dbus-connection.c:4718

#15 0xb6ec81b4 in dispatch_cb (ea=0x2124c, ev=0x35a20, userdata=0x407)

    at pulsecore/dbus-util.c:53

#16 0xb6f1a798 in dispatch_defer (m=<optimized out>) at pulse/mainloop.c:680

#17 pa_mainloop_dispatch (m=m at entry=0x21208) at pulse/mainloop.c:889

#18 0xb6f1ab98 in pa_mainloop_iterate (m=m at entry=0x21208, block=block at entry=1,

---Type <return> to continue, or q <return> to quit---

    retval=retval at entry=0xbec1ba9c) at pulse/mainloop.c:929

#19 0xb6f1abfc in pa_mainloop_run (m=m at entry=0x21208, retval=0xbec1ba9c,

    retval at entry=0xbec1ba94) at pulse/mainloop.c:944

#20 0x0000d9ec in main (argc=<optimized out>, argv=<optimized out>)

    at daemon/main.c:1134





-----Original Message-----
From: Tanu Kaskinen [mailto:tanuk at iki.fi]
Sent: Friday, August 14, 2015 12:00 PM
To: Eytan Naim; pulseaudio-discuss at lists.freedesktop.org
Subject: Re: [pulseaudio-discuss] pulseaudio a2dp disconnect problem



On Thu, 2015-08-13 at 12:35 +0000, Eytan Naim wrote:

> Hi Tanu,

>

> Thanks for the reply.

>

> I think that the loopback module shouldn’t be unloaded each time

> steaming stops for the simple reason that it is loaded when connection

> is established, and not when streaming starts.



Yes, that's oddly asymmetric, and should perhaps be fixed. That said, as long as module-loopback gets loaded again when the streaming continues, the current logic shouldn't necessarily cause too much trouble. In your case module-loopback doesn't get loaded again, but that might be because pulseaudio gets stuck before that has a chance to happen.



> I get all kind of PulseAudio problems, for example in the example

> below, PulseAudio success to stream in the start, but after pausing

> and playing again PulseAudio act differently.

>

> - It looks like PulseAudio has problem to handle changing connection

> state or something.

>

>

>

> The below log was produced by the following steps:

>

> a)      connection establishment

>

> b)      streaming session

>

> c)       stop from remote device

>

> d)      unloading loopback module

>

> e)      toggling streaming start/stop without PulseAudio suitable

> response

>

> f)       pacmd failure for long time (more then 3-4 minutes). – so

> it’s probably not a dbus thing.

>

>

>

> Please notice that each time I try a test, something a little

> different happens- but it always has to do with modules

> unloading/PulseAudio doesn’t response



Getting stuck is the most interesting problem here. Can you run pulseaudio in gdb, and when it gets stuck, stop and give command "thread apply all bt"?



--

Tanu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20150816/6393337f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pacmd_list_connect
Type: application/octet-stream
Size: 11866 bytes
Desc: pacmd_list_connect
URL: <http://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20150816/6393337f/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pacmd_list_pause
Type: application/octet-stream
Size: 9152 bytes
Desc: pacmd_list_pause
URL: <http://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20150816/6393337f/attachment-0003.obj>


More information about the pulseaudio-discuss mailing list