<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <font face="Helvetica, Arial, sans-serif">Debugging using gdb
      pulseaudio when the pactl set-card-profile 0 a2dp_sink is launched
      and the cpu utilization of pulseaudio reach 99%<br>
      <br>
      Breaking gdb this its the backtrace:<br>
      <br>
      (gdb) c<br>
      Continuing.<br>
      ^C<br>
      Program received signal SIGINT, Interrupt.<br>
      check_match (sym=sym@entry=0x77ef34c4,
      strtab=strtab@entry=0x77ef3c84 "",
      undef_name=undef_name@entry=0x7762b9ac
      "_ITM_registerTMCloneTable", <br>
          type_class=type_class@entry=1) at ldso/ldso/dl-hash.c:161<br>
      161        if ((sym->st_value == 0 &&
      (ELF_ST_TYPE(sym->st_info) != STT_TLS))<br>
      (gdb) bt<br>
      #0  check_match (sym=sym@entry=0x77ef34c4,
      strtab=strtab@entry=0x77ef3c84 "", <br>
          undef_name=undef_name@entry=0x7762b9ac
      "_ITM_registerTMCloneTable", type_class=type_class@entry=1) at
      ldso/ldso/dl-hash.c:161<br>
      #1  0x77fe1b5c in _dl_lookup_sysv_hash (type_class=1,
      undef_name=0x7762b9ac "_ITM_registerTMCloneTable", hash=192047269,
      symtab=0x77ef1494, <br>
          tpnt=0x77ff52c0) at ldso/ldso/dl-hash.c:261<br>
      #2  _dl_find_hash (name=0x7762b9ac "_ITM_registerTMCloneTable",
      scope=<optimized out>, mytpnt=0x456a90, type_class=1,
      sym_ref=0x0)<br>
          at ldso/ldso/dl-hash.c:339<br>
      #3  0x77fe1dc8 in _dl_perform_mips_global_got_relocations
      (tpnt=0x456a90, lazy=0) at ldso/ldso/mips/elfinterp.c:390<br>
      #4  0x77cec848 in do_dlopen (libname=0x45e0c0
      "/usr/lib/pulse-6.0/modules/module-null-sink.so", flag=2) at
      ldso/libdl/libdl.c:557<br>
      #5  0x77cecb0c in dlopen (libname=0x45e0c0
      "/usr/lib/pulse-6.0/modules/module-null-sink.so", flag=2) at
      ldso/libdl/libdl.c:664<br>
      #6  0x0040a078 in bind_now_open (d=<optimized out>,
      fname=0x45e0c0 "/usr/lib/pulse-6.0/modules/module-null-sink.so",
      advise=<optimized out>)<br>
          at daemon/ltdl-bind-now.c:74<br>
      #7  0x77da26f0 in tryall_dlopen ()<br>
         from
/home/mimmo/projects/linino_CC/scripts/../staging_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx/usr/lib/libltdl.so.7<br>
      #8  0x77da3098 in find_handle_callback ()<br>
         from
/home/mimmo/projects/linino_CC/scripts/../staging_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx/usr/lib/libltdl.so.7<br>
      #9  0x77da2dd8 in foreach_dirinpath ()<br>
         from
/home/mimmo/projects/linino_CC/scripts/../staging_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx/usr/lib/libltdl.so.7<br>
      #10 0x77da2ef4 in find_handle ()<br>
         from
/home/mimmo/projects/linino_CC/scripts/../staging_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx/usr/lib/libltdl.so.7<br>
      #11 0x77da4c60 in try_dlopen ()<br>
         from
/home/mimmo/projects/linino_CC/scripts/../staging_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx/usr/lib/libltdl.so.7<br>
      #12 0x77da5028 in lt_dlopenadvise ()<br>
         from
/home/mimmo/projects/linino_CC/scripts/../staging_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx/usr/lib/libltdl.so.7<br>
      #13 0x77da51a0 in lt_dlopenext ()<br>
         from
/home/mimmo/projects/linino_CC/scripts/../staging_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx/usr/lib/libltdl.so.7<br>
      #14 0x77f6c15c in pa_module_load (c=0x423868, name=0x7763f89c
      "module-null-sink", <br>
          argument=0x430758 "sink_name=auto_null
      sink_properties='device.description=\"Dummy Output\"'") at
      pulsecore/module.c:122<br>
      #15 0x7763f018 in load_null_sink_if_needed (c=0x423868,
      sink=<optimized out>, u=0x454418) at
      modules/module-always-sink.c:81<br>
      #16 0x7763f21c in unlink_hook_callback (c=<optimized out>,
      sink=<optimized out>, userdata=0x454418) at
      modules/module-always-sink.c:140<br>
      #17 0x77f69b74 in pa_hook_fire (hook=0x423a0c, data=0x474748) at
      pulsecore/hook-list.c:104<br>
      #18 0x77f8bd00 in pa_sink_unlink (s=0x474748) at
      pulsecore/sink.c:686<br>
      #19 0x773ecb2c in stop_thread (u=0x471b48) at
      modules/bluetooth/module-bluez5-device.c:1561<br>
      #20 0x773ef5e0 in set_profile_cb (c=<optimized out>,
      new_profile=0x4730d8) at
      modules/bluetooth/module-bluez5-device.c:1863<br>
      #21 0x77f65678 in pa_card_set_profile (c=<optimized out>,
      profile=0x4730d8, save=true) at pulsecore/card.c:279<br>
      #22 0x7771dc1c in command_set_card_profile (pd=<optimized
      out>, command=<optimized out>, tag=2, t=<optimized
      out>, userdata=0x46c368)<br>
          at pulsecore/protocol-native.c:4782<br>
      #23 0x77e9fc50 in pa_pdispatch_run (pd=0x485850, packet=0x463f58,
      ancil_data=0x478dd8, userdata=0x46c368) at
      pulsecore/pdispatch.c:341<br>
      #24 0x77726fd4 in pstream_packet_callback (p=0x478bf0,
      packet=0x463f58, ancil_data=0x478dd8, userdata=<optimized
      out>)<br>
          at pulsecore/protocol-native.c:4896<br>
      #25 0x77ea3258 in do_read (p=0x478bf0, re=0x478d30) at
      pulsecore/pstream.c:880<br>
      #26 0x77ea5b48 in do_pstream_read_write (p=0x478bf0) at
      pulsecore/pstream.c:193<br>
      #27 0x77f14628 in dispatch_pollfds (m=0x421708) at
      pulse/mainloop.c:655<br>
      #28 pa_mainloop_dispatch (m=0x421708) at pulse/mainloop.c:898<br>
      ---Type <return> to continue, or q <return> to quit---<br>
      #29 0x77f147e0 in pa_mainloop_iterate (m=0x421708,
      block=<optimized out>, retval=0x7fff6be8) at
      pulse/mainloop.c:929<br>
      #30 0x77f14864 in pa_mainloop_run (m=0x421708, retval=0x7fff6be8)
      at pulse/mainloop.c:944<br>
      #31 0x004056e8 in main (argc=<optimized out>,
      argv=<optimized out>) at daemon/main.c:1134<br>
      (gdb) <br>
      <br>
      <br>
      Any suggestion on why this happen?<br>
    </font><br>
    <div class="moz-cite-prefix">On 30/09/15 11:52, Mimmo wrote:<br>
    </div>
    <blockquote cite="mid:560BB0F7.6080500@linino.org" type="cite">
      <br>
      <br>
      On 30/09/15 11:21, Tanu Kaskinen wrote:
      <br>
      <blockquote type="cite">On Wed, 2015-09-30 at 10:20 +0200, Mimmo
        wrote:
        <br>
        <blockquote type="cite">Arduino Tian (an evolution of Arduino
          Yun) is a board that has a MIPS
          <br>
          processor where Linux is runinng. The distribution used is
          Linino,
          <br>
          derived from openWRT.
          <br>
          <br>
          On this board Wifi from Qualcomm and Bluetooth from CSR are
          embedded.
          <br>
          <br>
          Software version details:
          <br>
          - kernel 3.18.11
          <br>
          - bluez5 version 5.23
          <br>
          - pulseaudio 6.0
          <br>
          - dbus 1.9
          <br>
          <br>
          The Headset device is properly connected but using paplay:
          <br>
          <br>
          root@linino:~# paplay -v -d bluez_sink.5D_43_5A_03_31_EA
          /root/sample.wav
          <br>
          Opening a playback stream with sample specification 's16be 2ch
          44100Hz'
          <br>
          and channel map 'front-left,front-right'.
          <br>
          Connection established.
          <br>
          Stream successfully created.
          <br>
          Buffer metrics: maxlength=4194304, tlength=352800,
          prebuf=349276,
          <br>
          minreq=3528
          <br>
          Using sample spec 's16be 2ch 44100Hz', channel map
          'front-left,front-right'.
          <br>
          Connected to device bluez_sink.5D_43_5A_03_31_EA (index: 1,
          suspended: no).
          <br>
          <br>
          it start to play the music but without any sound. Trying to
          change the
          <br>
          card profile from HSP to A2DP with the command:
          <br>
          <br>
          pactl set-card-profile 0, a2dp_sink
          <br>
          <br>
          hangs the board and exit with connection failure: Timeout
          <br>
        </blockquote>
        Hangs the board? What does that mean? If pactl prints something
        after
        <br>
        the hang, apparently not the whole board gets hung (unless pactl
        runs
        <br>
        on a different machine).
        <br>
      </blockquote>
      It means that pactl exit after 10 secs but the pulseaudio process
      runs at 90-99% of the cpu, and I need to restart the pulseaudio
      process to continue to use the board.
      <br>
      <blockquote type="cite">
        <br>
        <blockquote type="cite">trying to trace the code, I noticed that
          it stops on the call
          <br>
          stop_thread on module-bluez5-device.c
          <br>
        </blockquote>
        How did you trace the code? Can you check with gdb where it's
        stopping?
        <br>
      </blockquote>
      I used strace to understand what system call did, and then I put
      so log messages. I'll try using gdb and let you know.
      <br>
      <blockquote type="cite">
        <blockquote type="cite">Can you help me to understand why is
          hanging changing the profile?
          <br>
          <br>
          Is it possible to force the default to A2DP instead of HSP?
          <br>
        </blockquote>
        "pactl set-card-profile" should save the chosen profile so that
        later
        <br>
        on a2dp would get activated automatically. However, the code
        hangs
        <br>
        before the new profile preference gets written to the disk...
        You could
        <br>
        in theory hack the card-database file in ~/.config/pulse, but
        it's
        <br>
        binary data, so not exactly easy.
        <br>
        <br>
      </blockquote>
      <br>
    </blockquote>
    <br>
  </body>
</html>