karlstav / cava

Cross-platform Audio Visualizer
MIT License
4.14k stars 232 forks source link

Launching Cava changes bluetooth profile when using a bluetooth speaker with microphone #586

Open tannerellen opened 6 days ago

tannerellen commented 6 days ago

READ THIS BEFORE CREATING NEW ISSUE

Are you using cava from a package repository, like AUR?

I tested this on the latest using git clone and then building but it also affects the AUR version as well.

Describe the bug

On Arch Linux using Pipewire audio if I have audio playing through a bluetooth speaker that contains a microphone it will default to the A2DP bluetooth audio profile. If I then launch cava it will immediately change to an HSP headset audio profile.

This means that if music is playing everything sounds great, as soon as Cava is launched the audio quality is greatly reduced. I can manually switch the audio profile back but no other app causes this profile switch.

To Reproduce

Steps to reproduce the behavior:

  1. Default config
  2. Play audio through bluetooth speaker that also contains a microphone (or use a bluetooth headset).
  3. Make sure audio profile is A2DP
  4. Launch Cava
  5. See issue that bluetooth profile switches to a headset profile and audio quality is bad

Expected behavior

I would expect that the bluetooth audio profile doesn't change.

Screenshots

If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Terminal emulator

Additional context I'm using this in Hyprland window manager on Arch. using bluez, bluez-utils, and blueman for bluetooth connectivity.

platz-halter commented 6 days ago

I have the same configuration and the same problem. Pavucontrol also crashes when starting cava and displays this error:

ERROR:../pavucontrol/src/streamwidget.cc:110:void StreamWidget::setVolume(const pa_cvolume&, bool): assertion failed: (v.channels == channelMap.channels)
Bail out! ERROR:../pavucontrol/src/streamwidget.cc:110:void StreamWidget::setVolume(const pa_cvolume&, bool): assertion failed: (v.channels == channelMap.channels)
[1]    6882 IOT instruction (core dumped)  pavucontrol
karlstav commented 6 days ago

i have no idea why the profile would change. cava just tries to record from whatever is the default sink. I have no bluetooth device at hand to attempt repro

tried running pavucontrol and launching cava just now and it did not crash.

tannerellen commented 5 days ago

Ok, this is probably an issue further upstream then. I did a bit more digging and I think this is probably related to how wireplumber handles auto switching to headset profiles. So maybe this isn't so much a bug but just not ideal behavior with the interaction of the monitor source and wireplumber. It is a bit odd that cava triggers this and other apps don't but I did launch OBS and it momentarily switches to a headset profile, but then immediately switches back to A2DP.

In the meantime I am just disabling the auto switching behavior itself in my wireplumber config. For anyone that wants to do the same I added a config file in ~/.config/wireplumber/wireplumber.conf.d/80-policy.conf

with the contents:

wireplumber.settings = {
    bluetooth.autoswitch-to-headset-profile = false
}

I don't experience any crashes with pavucontrol so that is a separate issue.

Feel free to close this if you don't believe there is anything under cava control here.

karlstav commented 4 days ago

I can leave it open for now, maybe there is something to do. I have no bluetooth on my current setup, but if i remember it I will check next time i have to dig my laptop out.