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

Bug #1703415 reported by Will Cooke
44
This bug affects 19 people
Affects Status Importance Assigned to Milestone
PulseAudio
New
Unknown
gdm
Fix Released
Unknown
gdm3 (Debian)
New
Unknown
gdm3 (Ubuntu)
Fix Released
High
Will Cooke

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.

Tags: a2dp

Related branches

Revision history for this message
In , Tanu Kaskinen (tanuk) wrote :

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).

Revision history for this message
In , Tanu Kaskinen (tanuk) wrote :

(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)
affects: gdm → pulseaudio
Revision history for this message
Jeremy Bícha (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.

Revision history for this message
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.

Revision history for this message
Will Cooke (willcooke) wrote :

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

Revision history for this message
Jeremy Bícha (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
Revision history for this message
Will Cooke (willcooke) wrote : Automatically added comment
tags: added: desktop-trello-import
tags: removed: desktop-trello-import
Changed in gdm3 (Ubuntu):
importance: Undecided → High
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Re: Disable Bluetooth sink in GDM to allow A2DP in the user session

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.

Revision history for this message
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

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

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

Revision history for this message
Daniel van Vugt (vanvugt) wrote :
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
Revision history for this message
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)
Changed in gdm3 (Ubuntu):
assignee: nobody → Will Cooke (willcooke)
status: Triaged → Fix Committed
Jeremy Bícha (jbicha)
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
Revision history for this message
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
Revision history for this message
Thorsten Munsch (thorsten-munsch) wrote :

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
Revision history for this message
In , Gitlab-migration (gitlab-migration) wrote :

-- 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
Revision history for this message
Saroumane (saroumane) wrote :

Hello,
I'm landing here after tracking a bug : I could not output sound to my SRS-XB22 bluetooth speaker.
I had in logs :
`src/service.c:btd_service_connect() a2dp-sink profile connect failed for F8:DF:15:7F:ED:AA: Protocol not available`

I found a workaround here https://askubuntu.com/questions/1172000/a2dp-sink-profile-connect-failed
```
$ pactl load-module module-bluetooth-policy
$ pactl load-module module-bluetooth-discover
```

I did not understand why these commands were mandatory as I already have them in `/etc/pulse/default.pa`

Then I checked my `~/.config/pulse/default.pa` and found this :
```
#!/usr/bin/pulseaudio -nF
#
# Work around for PA not allowing access to A2DP profiles in the user session
# because GDM already has it open.
# LP: #1703415

# 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
```

So here, we are : today, with
- Ubuntu 20.10
- Pulseaudio 1:13.99.2-1ubuntu2.1
- BlueZ 5.55-0ubuntu1.1

=> I do not reproduce the original bug.

=> Moreover, the now unnecessary workaround in `~/.config/pulse/default.pa` is preventing normal use for bluetooth devices.

**Workaround for the workaround** : comment the lines in `~/.config/pulse/default.pa`
```
#!/usr/bin/pulseaudio -nF
#
# Work around for PA not allowing access to A2DP profiles in the user session
# because GDM already has it open.
# LP: #1703415

# 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
```

tags: added: a2dp
no longer affects: gdm3 (Ubuntu Zesty)
no longer affects: pulseaudio (Ubuntu Zesty)
Changed in gdm:
importance: Medium → Unknown
status: Expired → Unknown
Changed in pulseaudio:
importance: Medium → Unknown
no longer affects: bluez (Ubuntu Xenial)
no longer affects: gdm3 (Ubuntu Xenial)
no longer affects: pulseaudio (Ubuntu Xenial)
Changed in bluez (Ubuntu):
status: New → Confirmed
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Oops. It appears this was fixed in gdm3 in 2017. If you have any more problems then please open new bugs.

no longer affects: bluez (Ubuntu)
no longer affects: pulseaudio (Ubuntu)
Changed in pulseaudio:
status: Unknown → New
Changed in gdm:
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
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.