<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - cannot select a2dp profile"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=92102#c10">Comment # 10</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - cannot select a2dp profile"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=92102">bug 92102</a>
              from <span class="vcard"><a class="email" href="mailto:pixelshader@gmail.com" title="Elias E. del Real <pixelshader@gmail.com>"> <span class="fn">Elias E. del Real</span></a>
</span></b>
        <pre>I have a Sony MDR-ZX220BT bluetooth headset that encounters this problem.
I'm using Ubuntu 16.10, bluez "5.41-0ubuntu3", and pulseaudio
"1:9.0-2ubuntu2.1".


From
<a href="https://bugs.launchpad.net/ubuntu/+source/bluez/+bug/1438510">https://bugs.launchpad.net/ubuntu/+source/bluez/+bug/1438510</a>
<a href="https://bugs.launchpad.net/ubuntu/+source/indicator-sound/+bug/1577197">https://bugs.launchpad.net/ubuntu/+source/indicator-sound/+bug/1577197</a>
it looks like the sequence that works is:

1. Select the "off" profile in pulseaudio.
2.1 Disconnect the bluetooth earphones.
2.2 Reconnect the bluetooth earphones.
3. Select the "a2dp_sink" profile in pulseaudio.

Or for commands:
1. pactl set-card-profile bluez_card.00_18_09_62_4B_98 off
2. bluetoothctl
2.1    disconnect 00:18:09:62:4B:98
2.2    connect 00:18:09:62:4B:98
3. pactl set-card-profile bluez_card.00_18_09_62_4B_98 a2dp_sink

Bluetooth users are resorting to a scripted version of the above as a
workaround:
<a href="https://gist.github.com/pylover/d68be364adac5f946887b85e6ed6e7ae#file-a2dp-py">https://gist.github.com/pylover/d68be364adac5f946887b85e6ed6e7ae#file-a2dp-py</a>


What I'm seeing in /var/log/syslog if I select "a2dp_sink" as the profile, then
disconnect, and reconnect:

Nov 25 00:47:50 fireflower pulseaudio[2178]: [pulseaudio]
module-bluez5-device.c: Default profile not connected, selecting off profile
Nov 25 00:47:50 fireflower bluetoothd[970]:
/org/bluez/hci0/dev_00_18_09_62_4B_98/fd17: fd(24) ready
Nov 25 00:47:50 fireflower pulseaudio[2178]: [pulseaudio] bluez5-util.c:
Transport TryAcquire() failed for transport
/org/bluez/hci0/dev_00_18_09_62_4B_98/fd17 (Operation Not Authorized)
Nov 25 00:47:50 fireflower kernel: [ 7852.918655] input: 00:18:09:62:4B:98 as
/devices/virtual/input/input37


The message from bluetoothd "fd(24) ready" showing up then makes me wonder if
this is a race between pulseaudio and the bluetooth connection?

If I then run:

pactl set-card-profile bluez_card.00_18_09_62_4B_98 a2dp_sink

I get nothing new in /var/log/syslog .

If I run:

pactl set-card-profile bluez_card.00_18_09_62_4B_98 off

I get nothing new in /var/log/syslog .


If I again run:

pactl set-card-profile bluez_card.00_18_09_62_4B_98 a2dp_sink

I get this output:

Failure: Input/Output error

and /var/log/syslog logs:

Nov 25 00:52:26 fireflower pulseaudio[2178]: [pulseaudio] bluez5-util.c:
Transport Acquire() failed for transport
/org/bluez/hci0/dev_00_18_09_62_4B_98/fd17 (Operation Not Authorized)


If I run

pactl list cards | tail -n 26

I see:

Card #18
        Name: bluez_card.00_18_09_62_4B_98
        Driver: module-bluez5-device.c
        Owner Module: 43
        Properties:
                device.description = "MDR-ZX220BT"
                device.string = "00:18:09:62:4B:98"
                device.api = "bluez"
                device.class = "sound"
                device.bus = "bluetooth"
                device.form_factor = "headset"
                bluez.path = "/org/bluez/hci0/dev_00_18_09_62_4B_98"
                bluez.class = "0x240404"
                bluez.alias = "MDR-ZX220BT"
                device.icon_name = "audio-headset-bluetooth"
                device.intended_roles = "phone"
        Profiles:
                headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1,
sources: 1, priority: 20, available: yes)
                a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1,
sources: 0, priority: 10, available: yes)
                off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
        Active Profile: off
        Ports:
                headset-output: Headset (priority: 0, latency offset: 0 usec,
available)
                        Part of profile(s): headset_head_unit, a2dp_sink
                headset-input: Headset (priority: 0, latency offset: 0 usec)
                        Part of profile(s): headset_head_unit


If I disconnect and connect the device via bluetoothctl, /var/log/syslog logs:

Nov 25 00:55:38 fireflower acpid: input device has been disconnected, fd 15

and

Nov 25 00:57:02 fireflower kernel: [ 8404.425497] input: 00:18:09:62:4B:98 as
/devices/virtual/input/input38


If in the "Sound" GUI (System Settings > Sound), I go to the Output tab, and
select the headset, /var/log/syslog logs:

Nov 25 00:57:37 fireflower pulseaudio[2178]: [pulseaudio] backend-native.c:
connect(): Function not implemented


If in the pulseaudio "Volume Control" UI I go to the Configuration tab, it
shows the profile is "Off".

If there, I select "High Fidelity Playback (A2DP Sink), /var/log/syslog logs:

Nov 25 01:00:55 fireflower bluetoothd[970]:
/org/bluez/hci0/dev_00_18_09_62_4B_98/fd18: fd(24) ready</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the QA Contact for the bug.</li>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>