Bluetooth audio devices/profiles are missing after logging in from GDM

Bug #1703415 reported by Will Cooke on 2017-07-10
44
This bug affects 19 people
Affects Status Importance Assigned to Milestone
PulseAudio
Unknown
Medium
gdm
Expired
Medium
gdm3 (Debian)
New
Unknown
gdm3 (Ubuntu)
High
Will Cooke
Xenial
High
Unassigned
Zesty
High
Unassigned
pulseaudio (Ubuntu)
High
Unassigned
Xenial
High
Unassigned
Zesty
High
Unassigned

Bug Description

This is actually a PulseAudio bug, but the workaround is to disable Bluetooth audio in GDM.

Further discussion (and the source of my understanding about this issue) upstream are here:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=805414

To summarise:

GDM opens the A2DP profile for a11y purposes to allow screenreaders to output over BT audio devices. However Pulse doesn't release those devices when no audio is being played and the upshot is that once in the users session A2DP is not available for any Bluetooth audio devices, this means that you can only use the low quality profile HSP/HFP.

There is a proposed workaround, but this means that a11y tools which need to output audio won't be able to use Bluetooth devices within GDM.

I think that for 17.10 shipping this work-around is acceptable, and we should revisit in the 18.04 cycle to try and get a proper fix in PA. The suggested PA bug is:

https://bugs.freedesktop.org/show_bug.cgi?id=57167

but that hasn't seen movement since 2012.

= The work around =

From the Debian wiki: https://wiki.debian.org/BluetoothUser/a2dp

Disable the Bluetooth sink in the GDM PA daemon.

Add this to /var/lib/gdm3/.config/pulse/default.pa

#!/usr/bin/pulseaudio -nF
#

# load system wide configuration
.include /etc/pulse/default.pa

### unload driver modules for Bluetooth hardware
.ifexists module-bluetooth-policy.so
  unload-module module-bluetooth-policy
.endif

.ifexists module-bluetooth-discover.so
  unload-module module-bluetooth-discover
.endif

I have tested this, and I can confirm that it allows access to A2DP again in the user session.

Related branches

In module-bluetooth-device.c in filter_cb() there's this piece of code:

    if (acquire)
        if (bt_transport_acquire(u, FALSE) >= 0) {
            if (u->source)
                pa_source_suspend(u->source, FALSE, PA_SUSPEND_IDLE|PA_SUSPEND_USER);

            if (u->sink)
                pa_sink_suspend(u->sink, FALSE, PA_SUSPEND_IDLE|PA_SUSPEND_USER);
        }

The acquire variable is set to true if the bluetooth audio state changed to "playing". This can happen without pulseaudio requesting it, so if we want to have strict equivalence "sink/source suspended" == "audio state is 'playing'" (and I think we want that), then it makes sense that module-bluetooth-device unsuspends the sink/source. The problem here is that there's no clean "force unsuspend" mechanism in pulseaudio. pa_sink_suspend(u->sink, FALSE, PA_SUSPEND_IDLE|PA_SUSPEND_USER) may not actually unsuspend the sink, because there are also other suspend reasons than just IDLE and USER. So, depending on the situation, the sink may or may not get unsuspended.

module-bluetooth-device could list all possible reasons in the pa_sink_suspend() call, but that would be ugly. When adding new suspend reasons, it would be very easy to forget to update the pa_sink_suspend() call in module-bluetooth-device, and besides, if those suspend reasons are originally set by some other code, the original reasons to suspend don't really disappear when module-bluetooth-device unsuspends the sink, the old reasons are just overridden.

I think there should be a function for forcing unsuspending. The semantics would be such that the sink gets unsuspended regardless of any standing suspend reasons, but all standing suspend reasons would be remembered, and once a new suspend request would be made, the forced unsuspend would cease to have effect, the sink would suspend and things would return to normal.

A related thing is that I would like to replace the single suspend reason bitfield in pa_sink with an individual suspend request object for each suspend request. The single suspend reason bitfield is prone to conflicts if multiple places use the same reason (for example, module-bluetooth-device uses the USER reason which is also used for other purposes).

(In reply to comment #0)
> The problem here is that
> there's no clean "force unsuspend" mechanism in pulseaudio.
> pa_sink_suspend(u->sink, FALSE, PA_SUSPEND_IDLE|PA_SUSPEND_USER) may not
> actually unsuspend the sink, because there are also other suspend reasons
> than just IDLE and USER. So, depending on the situation, the sink may or may
> not get unsuspended.
>
> module-bluetooth-device could list all possible reasons in the
> pa_sink_suspend() call, but that would be ugly. When adding new suspend
> reasons, it would be very easy to forget to update the pa_sink_suspend()
> call in module-bluetooth-device, and besides, if those suspend reasons are
> originally set by some other code, the original reasons to suspend don't
> really disappear when module-bluetooth-device unsuspends the sink, the old
> reasons are just overridden.

Correction: there is the PA_SUSPEND_ALL suspend cause. That looks like a good simple solution to this bug, even though it doesn't solve all the described problems. But at least it will reliably unsuspend the sink.

Will Cooke (willcooke) on 2017-07-10
affects: gdm → pulseaudio
Jeremy Bicha (jbicha) wrote :

Will, could you check if this is a duplicate of LP: #1489651 ?

I believe Debian has the same problem and the Debian GNOME team is thinking about pushing a workaround to Debian 9.

Will Cooke (willcooke) wrote :

If this is accepted, we need to add a known issue to the release notes, and add a task for next cycle to follow up with the PulseAudio developers.

Will Cooke (willcooke) wrote :

@jbicha - Confirmed: same bug. I have a branch with a workaround which I'll attach here shortly.

Jeremy Bicha (jbicha) wrote :

Ok. Also consider backporting this to 16.04 LTS and 17.04.

Changed in gdm3 (Debian):
status: Unknown → New
Changed in pulseaudio:
importance: Unknown → Medium
status: Unknown → Confirmed
tags: added: desktop-trello-import
tags: removed: desktop-trello-import
Changed in gdm3 (Ubuntu):
importance: Undecided → High

I think you might have two different bugs...

A2DP failing to appear in the list or refusing to set is a longstanding problem that has occurred well before the introduction of gdm. It's one of the things we tried to fix in xenial recently but I know it can still occur sometimes even in artful.

How I experience this bug however is that the Bluetooth device is shown as connected but upon login there is no corresponding audio device.

Daniel van Vugt (vanvugt) wrote :

The Arch wiki mentions this problem and only suggests disabling the gdm pulse instance :P

https://wiki.archlinux.org/index.php/Bluetooth_headset#Connecting_works.2C_but_I_cannot_play_sound

Daniel van Vugt (vanvugt) wrote :

A better upstream bug report for PulseAudio might be:
https://bugs.freedesktop.org/show_bug.cgi?id=98144

Changed in gdm:
importance: Unknown → Medium
status: Unknown → Confirmed
summary: - Disable Bluetooth sink in GDM to allow A2DP in the user session
+ Bluetooth audio devices/profiles are missing after logging in from GDM
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gdm3 (Ubuntu):
status: New → Confirmed
Changed in pulseaudio (Ubuntu):
status: New → Confirmed
Changed in pulseaudio (Ubuntu):
importance: Undecided → High
status: Confirmed → Triaged
Changed in gdm3 (Ubuntu):
status: Confirmed → Triaged
Will Cooke (willcooke) on 2017-07-13
Changed in gdm3 (Ubuntu):
assignee: nobody → Will Cooke (willcooke)
status: Triaged → Fix Committed
Jeremy Bicha (jbicha) on 2017-07-13
Changed in gdm3 (Ubuntu Xenial):
importance: Undecided → High
status: New → Triaged
Changed in gdm3 (Ubuntu Zesty):
importance: Undecided → High
status: New → Triaged
Changed in pulseaudio (Ubuntu Xenial):
importance: Undecided → High
status: New → Triaged
Changed in pulseaudio (Ubuntu Zesty):
importance: Undecided → High
status: New → Triaged
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gdm3 - 3.24.2-1ubuntu9

---------------
gdm3 (3.24.2-1ubuntu9) artful; urgency=medium

  * debian/default.pa
    - Added new file to disable Bluetooth audio devices in PulseAudio from
      gdm3. (LP: #1703415) (LP: #1489651)
  * debian/gdm3.install
    - Added details of the default.pa file
  * debian/gdm3.postinst
    - Added installation of default.pa and creation of dir if it doesn't
      exist.

 -- Will Cooke <email address hidden> Thu, 13 Jul 2017 12:14:34 +0100

Changed in gdm3 (Ubuntu):
status: Fix Committed → Fix Released

I can confirm this one on (X)ubuntu 14.04.5 LTS with XFCE 4.10 desktop.

The suggested fixes work for me aswell.

Another problem appears when bluetooth is disabled on boot (which I always do because of paranoia ;)).

Both Pulseaudio modules won't get loaded by my XFCE autostart script. I have to run it again after bluetooth is enabled manually.

Then my JBL Flip 3 speaker appers instantly in the Pulseaudio settings besides the onboard sound device.

Everything else works like a charm.

Changed in gdm:
status: Confirmed → Expired

-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/340.

Changed in pulseaudio:
status: Confirmed → Unknown
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.