bluez-alsa: Audio volume does not go to 100% on Raspberry Pi

Problem

Yesterday, I reinstalled bluealsa (as a sink) after a fresh Raspberry Pi OS Bookworm install on my Raspberry Pi 4, but the volume control from my phone wasn’t working, even though I could see the volume changes from bluetoothctl the audio wasn’t very loud (it’s actually never been, but I never thought of investigating and trying to figure out why before).

Using alsamixer, though, I noticed that it does change the volume of the bluealsa capture device, even though I can’t hear the difference: when the volume is set to any value except 0, you always hear it at the maximum volume; when it’s 0, the audio is just muted. Also, I can control the volume just fine from alsamixer. it only changes the volume up to 0dB, which is not the maximum volume on Raspberry Pi.

Reproduction steps

Run bluealsa and bluealsa-aplay. I used these parameters: -p midi --midi-advertisement -p a2dp-source -p a2dp-sink --a2dp-volume -c sbc -c aac -c aptx -c aptx-hd -c ldac --ldac-abr --ldac-quality=high for bluealsa, and both none and --pcm=plughw:0,0 --mixer-name=PCM --mixer-index=0 for bluealsa-aplay, as amixer scontents shows that the mixer is called PCM and not Master. The volume will not change. The volume will only reach up to 0dB while the Raspberry Pi’s maximum volume is 4dB. If you try to set a higher volume than that, it will crash because of an assertion error.

Setup

  • Raspberry Pi OS Bookworm (64-bit)
  • BlueALSA is at the latest version at the time of writing (v4.2.0)
  • BlueZ 5.66
  • ALSA 1.2.8
  • Built from branch master and release tag v4.2.0 (261f184 (HEAD, tag: v4.2.0) Minor version bump (release 4.2.0)).

Configure options:

  • --enable-manpages
  • --enable-aac
  • --enable-ldac
  • --with-libopenaptx
  • --enable-mp3lame
  • --enable-mpg123
  • --enable-aptx
  • --enable-aptx-hd
  • --enable-msbc
  • --enable-rfcomm
  • --enable-hcitop
  • --enable-systemd
  • --enable-cli
  • --enable-faststream
  • --enable-midi
  • --enable-ofono
  • --enable-upower
  • --enable-a2dpconf
  • --with-systemdbluealsaargs='-S -p midi --midi-advertisement -p a2dp-source -p a2dp-sink --a2dp-volume -c sbc -c aac -c aptx -c aptx-hd -c ldac --ldac-abr --ldac-quality=high'

Additional context (old)

Checking the logs (even with the --enable-debug flag on the ./configure command and recompiling), the only actually useful info I could see was:

bluealsa-aplay: [197226] D: ../../../utils/aplay/aplay.c:692: Opening ALSA playback PCM: name=default channels=2 rate=96000
bluealsa-aplay: [197226] D: ../../../utils/aplay/aplay.c:708: Opening ALSA mixer: name=default elem=Master index=0
bluealsa-aplay: [197226] D: ../../../utils/aplay/aplay.c:467: Setting up ALSA mixer volume synchronization
bluealsa-aplay: [29403] E: ../../../utils/aplay/aplay.c:349: Couldn't get ALSA mixer playback dB level: Invalid argument
bluealsa-aplay: [29339] E: ../../../utils/aplay/aplay.c:433: Couldn't set ALSA mixer playback dB level: Invalid argument

on the logs of bluealsa-aplay. Looks like the only workaround is to use the --volume=software parameter on bluealsa-aplay for now.

The audio seems to be passing through pipewire when running bluealsa-aplay as user. If I run it as root so that it won’t pass through pipewire, I’ll still get sound playing, but with the same issue as above, but with different logs:

bluealsa-aplay: [197569] D: ../../../utils/aplay/aplay.c:692: Opening ALSA playback PCM: name=default channels=2 rate=96000
bluealsa-aplay: [197569] D: ../../../utils/aplay/aplay.c:708: Opening ALSA mixer: name=default elem=Master index=0
bluealsa-aplay: [197569] W: ../../../utils/aplay/aplay.c:712: Couldn't open ALSA mixer: Mixer element not found

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (7 by maintainers)

Commits related to this issue

Most upvoted comments

While testing, though, I got into another issue: if I stop the music, then change the volume from my phone after it gets marked as inactive and then play it again, the volume will get back to the previous value. If I change it through alsamixer, instead, it will set it to the value from alsamixer as soon as audio is played.

This behavior is by “design” 😄. The case is that whenever the playback stops, bluealsa-aplay releases PCM and mixer, so others could use it (because bluealsa-aplay does not know for how long the playback has stopped). So when the playback mixer is released, it is not linked with Bluetooth mixer. Then, when playback starts, the mixers are linked and volume is synchronized again.

Update: it also just crashed because of an assertion error while the device was inactive:

Could you run bluealsa-aplay via gdb and in case of crash send here the backtrace?