<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 16.08.2015 12:26, Eytan Naim wrote:<br>
</div>
<blockquote
cite="mid:783b773e8e9a454fbd29adab0626dc96@IL-EXCH02.marvell.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
{mso-style-priority:99;
mso-style-link:"Plain Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
span.PlainTextChar
{mso-style-name:"Plain Text Char";
mso-style-priority:99;
mso-style-link:"Plain Text";
font-family:"Calibri","sans-serif";}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:520507054;
mso-list-type:hybrid;
mso-list-template-ids:1505550968 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoPlainText">Hi Tanu,<o:p></o:p></p>
<p class="MsoPlainText">Thanks for your advice and cooperation.<o:p></o:p></p>
<p class="MsoPlainText">As a result of the loopback_module
asymmetric oddity, I compared "pacmd list" output command
between two states (you can see attached files):<o:p></o:p></p>
<p class="MsoPlainText"
style="margin-left:.5in;text-indent:-.25in;mso-list:l0 level1
lfo1">
<!--[if !supportLists]--><span style="mso-list:Ignore">1.<span
style="font:7.0pt "Times New Roman"">
</span></span><!--[endif]--><span dir="LTR"></span>After
connection establishment, and before streaming starts.<o:p></o:p></p>
<p class="MsoPlainText"
style="margin-left:.5in;text-indent:-.25in;mso-list:l0 level1
lfo1">
<!--[if !supportLists]--><span style="mso-list:Ignore">2.<span
style="font:7.0pt "Times New Roman"">
</span></span><!--[endif]--><span dir="LTR"></span>After
streaming stops.<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:.5in"><o:p> </o:p></p>
<p class="MsoPlainText">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.<o:p></o:p></p>
<p class="MsoPlainText">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).<br>
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).<o:p></o:p></p>
<p class="MsoPlainText">Do you know this Bluetooth code? Does it
make sense? Is there anyone I can ask to confirm it?<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%">static
pa_hook_result_t profile_available_hook_callback(pa_core *c,
pa_card_profile *profile, void *userdata) {<o:p></o:p></span></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%">
pa_card *card;<o:p></o:p></span></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%">
const char *s;<o:p></o:p></span></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%">
bool is_active_profile;<o:p></o:p></span></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%">
pa_card_profile *selected_profile;<o:p></o:p></span></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%">
pa_assert(c);<o:p></o:p></span></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%">
pa_assert(profile);<o:p></o:p></span></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%">
pa_assert_se((card = profile->card));<o:p></o:p></span></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%">
/* Only consider bluetooth cards */<o:p></o:p></span></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%">
s = pa_proplist_gets(card->proplist, PA_PROP_DEVICE_BUS);<o:p></o:p></span></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%">
if (!s || !pa_streq(s, "bluetooth"))<o:p></o:p></span></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%">
return PA_HOOK_OK;<o:p></o:p></span></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%">
/* Do not automatically switch profiles for headsets, just
in case */<o:p></o:p></span></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%">
/* TODO: remove a2dp and hsp when we remove BlueZ 4 support
*/<o:p></o:p></span></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%">
if (pa_streq(profile->name, "hsp") ||
pa_streq(profile->name, "a2dp") ||
pa_streq(profile->name, "a2dp_sink") ||<o:p></o:p></span></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%">-
pa_streq(profile->name, "a2dp_source") ||
pa_streq(profile->name, "headset_head_unit"))<o:p></o:p></span></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%">+
pa_streq(profile->name, "headset_head_unit")) {<o:p></o:p></span></p>
<p class="MsoPlainText" style="text-indent:.5in"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%">
return PA_HOOK_OK;<o:p></o:p></span></p>
<p class="MsoPlainText"><span
style="color:#558ED5;mso-style-textfill-fill-color:#558ED5;mso-style-textfill-fill-alpha:100.0%">…<o:p></o:p></span></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">It seemed it worked <span
style="font-family:Wingdings">J</span>, but the freezing
issue still there
<span style="font-family:Wingdings">L</span>.<o:p></o:p></p>
<p class="MsoPlainText">When an a2dp connection is lost, pa
would freeze when trying to reconnect and reload the Bluetooth
modules.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">gdb output:<o:p></o:p></p>
<p class="MsoPlainText">(gdb) thread apply all bt<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Thread 1 (process 1998):<o:p></o:p></p>
<p class="MsoPlainText">#0 arm_modulus (p=1031, m=123328564) at
./ldso/ldso/arm/dl-sysdep.h:29<o:p></o:p></p>
<p class="MsoPlainText">#1 _dl_lookup_sysv_hash
(type_class=<optimized out>,<o:p></o:p></p>
<p class="MsoPlainText"> undef_name=<optimized out>,
hash=123328564, symtab=0xb6d0f3ec,<o:p></o:p></p>
<p class="MsoPlainText"> tpnt=0xb6fc5508) at
ldso/ldso/dl-hash.c:255<o:p></o:p></p>
<p class="MsoPlainText">#2 _dl_find_hash (<o:p></o:p></p>
<p class="MsoPlainText"> name=name@entry=0xbec1b5c0
"module_bluez5_device_LTX_pa__get_deprecated",<o:p></o:p></p>
<p class="MsoPlainText"> scope=<optimized out>,
mytpnt=mytpnt@entry=0x0,<o:p></o:p></p>
<p class="MsoPlainText">
type_class=type_class@entry=-2147483648,
sym_ref=sym_ref@entry=0xbec1b558)<o:p></o:p></p>
<p class="MsoPlainText"> at ldso/ldso/dl-hash.c:339<o:p></o:p></p>
<p class="MsoPlainText">#3 0xb6d86b1c in do_dlsym
(caller_address=<optimized out>,<o:p></o:p></p>
<p class="MsoPlainText"> name=0xbec1b5c0
"module_bluez5_device_LTX_pa__get_deprecated",<o:p></o:p></p>
<p class="MsoPlainText"> vhandle=<optimized out>) at
ldso/libdl/libdl.c:733<o:p></o:p></p>
<p class="MsoPlainText">#4 dlsym (vhandle=<optimized
out>,<o:p></o:p></p>
<p class="MsoPlainText"> name=0xbec1b5c0
"module_bluez5_device_LTX_pa__get_deprecated")<o:p></o:p></p>
<p class="MsoPlainText"> at ldso/libdl/libdl.c:765<o:p></o:p></p>
<p class="MsoPlainText">#5 0x000116d8 in bind_now_find_sym
(d=<optimized out>, m=<optimized out>,<o:p></o:p></p>
<p class="MsoPlainText"> symbol=<optimized out>) at
daemon/ltdl-bind-now.c:101<o:p></o:p></p>
<p class="MsoPlainText">#6 0xb6e039b8 in lt_dlsym () from
/usr/lib/libltdl.so.7<o:p></o:p></p>
<p class="MsoPlainText"><span
style="background:lime;mso-highlight:lime">#7 0xb6f5b400 in
pa_load_sym (handle=0x5e8f8,<o:p></o:p></span></p>
<p class="MsoPlainText"><span
style="background:lime;mso-highlight:lime">
module=module@entry=0xb686247a "module-bluez5-device",</span><o:p></o:p></p>
<p class="MsoPlainText"> symbol=0xb6fa3121
"pa__get_deprecated") at pulsecore/ltdl-helper.c:42<o:p></o:p></p>
<p class="MsoPlainText">---Type <return> to continue, or q
<return> to quit---<o:p></o:p></p>
<p class="MsoPlainText">#8 0xb6f5d128 in pa_module_load
(c=0x24f00,<o:p></o:p></p>
<p class="MsoPlainText"> name=0xb686247a
"module-bluez5-device",<o:p></o:p></p>
<p class="MsoPlainText"> argument=argument@entry=0x5e2b0
"path=/org/bluez/hci0/dev_98_D6_F7_34_98_E8") at
pulsecore/module.c:151<o:p></o:p></p>
<p class="MsoPlainText">#9 0xb6861ee0 in
device_connection_changed_cb (y=<optimized out>,
d=0x50bb8,<o:p></o:p></p>
<p class="MsoPlainText"> u=0x38950) at
modules/bluetooth/module-bluez5-discover.c:77<o:p></o:p></p>
<p class="MsoPlainText">#10 0xb6f5b1a4 in pa_hook_fire
(hook=0x37840, data=0x50bb8)<o:p></o:p></p>
<p class="MsoPlainText"> at pulsecore/hook-list.c:104<o:p></o:p></p>
<p class="MsoPlainText">#11 0xb684f8cc in
endpoint_set_configuration (m=m@entry=0x50f10,<o:p></o:p></p>
<p class="MsoPlainText"> userdata=userdata@entry=0x37830,
conn=<optimized out>)<o:p></o:p></p>
<p class="MsoPlainText"> at
modules/bluetooth/bluez5-util.c:1313<o:p></o:p></p>
<p class="MsoPlainText">#12 0xb684fcdc in endpoint_handler
(c=<optimized out>, m=m@entry=0x50f10,<o:p></o:p></p>
<p class="MsoPlainText"> userdata=userdata@entry=0x37830) at
modules/bluetooth/bluez5-util.c:1517<o:p></o:p></p>
<p class="MsoPlainText">#13 0xb6ddf800 in
_dbus_object_tree_dispatch_and_unlock (tree=0x399e0,<o:p></o:p></p>
<p class="MsoPlainText"> message=message@entry=0x50f10,
found_object=found_object@entry=0xbec1b99c)<o:p></o:p></p>
<p class="MsoPlainText"> at dbus-object-tree.c:1018<o:p></o:p></p>
<p class="MsoPlainText">#14 0xb6dd1104 in
dbus_connection_dispatch (connection=0x39c28)<o:p></o:p></p>
<p class="MsoPlainText"> at dbus-connection.c:4718<o:p></o:p></p>
<p class="MsoPlainText">#15 0xb6ec81b4 in dispatch_cb
(ea=0x2124c, ev=0x35a20, userdata=0x407)<o:p></o:p></p>
<p class="MsoPlainText"> at pulsecore/dbus-util.c:53<o:p></o:p></p>
<p class="MsoPlainText">#16 0xb6f1a798 in dispatch_defer
(m=<optimized out>) at pulse/mainloop.c:680<o:p></o:p></p>
<p class="MsoPlainText">#17 pa_mainloop_dispatch
(m=m@entry=0x21208) at pulse/mainloop.c:889<o:p></o:p></p>
<p class="MsoPlainText">#18 0xb6f1ab98 in pa_mainloop_iterate
(m=m@entry=0x21208, block=block@entry=1,<o:p></o:p></p>
<p class="MsoPlainText">---Type <return> to continue, or q
<return> to quit---<o:p></o:p></p>
<p class="MsoPlainText"> retval=retval@entry=0xbec1ba9c) at
pulse/mainloop.c:929<o:p></o:p></p>
<p class="MsoPlainText">#19 0xb6f1abfc in pa_mainloop_run
(m=m@entry=0x21208, retval=0xbec1ba9c,<o:p></o:p></p>
<p class="MsoPlainText"> retval@entry=0xbec1ba94) at
pulse/mainloop.c:944<o:p></o:p></p>
<p class="MsoPlainText">#20 0x0000d9ec in main
(argc=<optimized out>, argv=<optimized out>)<o:p></o:p></p>
<p class="MsoPlainText"> at daemon/main.c:1134<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">-----Original Message-----<br>
From: Tanu Kaskinen [<a class="moz-txt-link-freetext" href="mailto:tanuk@iki.fi">mailto:tanuk@iki.fi</a>] <br>
Sent: Friday, August 14, 2015 12:00 PM<br>
To: Eytan Naim; <a class="moz-txt-link-abbreviated" href="mailto:pulseaudio-discuss@lists.freedesktop.org">pulseaudio-discuss@lists.freedesktop.org</a><br>
Subject: Re: [pulseaudio-discuss] pulseaudio a2dp disconnect
problem</p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">On Thu, 2015-08-13 at 12:35 +0000, Eytan
Naim wrote:<o:p></o:p></p>
<p class="MsoPlainText">> Hi Tanu,<o:p></o:p></p>
<p class="MsoPlainText">> <o:p></o:p></p>
<p class="MsoPlainText">> Thanks for the reply.<o:p></o:p></p>
<p class="MsoPlainText">> <o:p></o:p></p>
<p class="MsoPlainText">> I think that the loopback module
shouldn’t be unloaded each time
<o:p></o:p></p>
<p class="MsoPlainText">> steaming stops for the simple
reason that it is loaded when connection
<o:p></o:p></p>
<p class="MsoPlainText">> is established, and not when
streaming starts.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">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.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">> I get all kind of PulseAudio
problems, for example in the example
<o:p></o:p></p>
<p class="MsoPlainText">> below, PulseAudio success to stream
in the start, but after pausing
<o:p></o:p></p>
<p class="MsoPlainText">> and playing again PulseAudio act
differently.<o:p></o:p></p>
<p class="MsoPlainText">> <o:p></o:p></p>
<p class="MsoPlainText">> - It looks like PulseAudio has
problem to handle changing connection
<o:p></o:p></p>
<p class="MsoPlainText">> state or something.<o:p></o:p></p>
<p class="MsoPlainText">> <o:p></o:p></p>
<p class="MsoPlainText">> <o:p></o:p></p>
<p class="MsoPlainText">> <o:p></o:p></p>
<p class="MsoPlainText">> The below log was produced by the
following steps:<o:p></o:p></p>
<p class="MsoPlainText">> <o:p></o:p></p>
<p class="MsoPlainText">> a) connection establishment<o:p></o:p></p>
<p class="MsoPlainText">> <o:p></o:p></p>
<p class="MsoPlainText">> b) streaming session<o:p></o:p></p>
<p class="MsoPlainText">> <o:p></o:p></p>
<p class="MsoPlainText">> c) stop from remote device<o:p></o:p></p>
<p class="MsoPlainText">> <o:p></o:p></p>
<p class="MsoPlainText">> d) unloading loopback module<o:p></o:p></p>
<p class="MsoPlainText">> <o:p></o:p></p>
<p class="MsoPlainText">> e) toggling streaming
start/stop without PulseAudio suitable
<o:p></o:p></p>
<p class="MsoPlainText">> response<o:p></o:p></p>
<p class="MsoPlainText">> <o:p></o:p></p>
<p class="MsoPlainText">> f) pacmd failure for long
time (more then 3-4 minutes). – so
<o:p></o:p></p>
<p class="MsoPlainText">> it’s probably not a dbus thing.<o:p></o:p></p>
<p class="MsoPlainText">> <o:p></o:p></p>
<p class="MsoPlainText">> <o:p></o:p></p>
<p class="MsoPlainText">> <o:p></o:p></p>
<p class="MsoPlainText">> Please notice that each time I try
a test, something a little
<o:p></o:p></p>
<p class="MsoPlainText">> different happens- but it always
has to do with modules
<o:p></o:p></p>
<p class="MsoPlainText">> unloading/PulseAudio doesn’t
response<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">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"?<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">--<o:p></o:p></p>
<p class="MsoPlainText">Tanu<o:p></o:p></p>
</div>
<br>
</blockquote>
<br>
It is correct that the profile is set to "off" when a stream stops.
The a2dp connection<br>
is torn down on the bluetooth end, so it would not make sense to
keep the profile in<br>
pulesaudio. This is definitely not the cause of your problem. And
actually I cannot<br>
see that it's asymmetric. The loopback module is loaded as soon as
the profile is<br>
switched to a2dp and unloaded as soon as the profile changes to
"off".<br>
BTW, you can avoid loading and unloading the loopback module
automatically by<br>
loading module-bluetooth-policy with argument a2dp_source=0. But
then you have<br>
to load the loopback manually and move it to the right source. Maybe
it is a good idea<br>
to test that because the issue might also be caused by
module-bluetooth-policy.<br>
<br>
The phone application I wrote handles insertion of loopback modues
and does not<br>
rely on module-bluetuetooth policy for that. Up to now I have not
seen a similar<br>
issue, the application reacts to switches between a2dp/hsp/off
without problems. <br>
<br>
Georg <br>
</body>
</html>