arkq / bluez-alsa

Bluetooth Audio ALSA Backend
MIT License
862 stars 189 forks source link

Volume not updating with bluealsa plugin #733

Open Asikbct opened 3 days ago

Asikbct commented 3 days ago

Problem

When our DUT acts as A2DP source and connects then streams audio to external BT speaker using bluealsa plugin. With some model of speakers like realme buds headsets and JBL speakers, when we start to steam audio we could not control volume at initial. later like after 15 to 20 seconds we could able to control the volume of external BT speaker through MediaTransport volume property.

I have tried with the latest master branch when we try to get bluealsa PCM it throws error "ALSA lib bluealsa-pcm.c:1638:(_snd_pcm_bluealsa_open) Couldn't get BlueALSA PCM: Get PCM: Get properties: Incorrect variant for 'Volume': q != a"

Reproduction steps

  1. connect DUT with external BT speaker.
  2. Start audio stream with bluealsa plugin.
  3. Audio will start play from external BT speaker.
  4. If you increase/decrease the volume from DUT, it will not reflect on the external BT speaker.
  5. After some time, Volume can be updated.

Setup

OS ver: Linux username 5.4.210 #2 SMP PREEMPT Thu Oct 17 10:18:00 IST 2024 aarch64 GNU/Linux bluealsa ver: v4.1.1 bluetoothd ver: v5.72 aplay: version 1.2.1 by Jaroslav Kysela perex@perex.cz

Additional context

whenever we get volume update issue once started the streaming, that time we get this error print from bluez

D/bluetoothd[885]: profiles/audio/avctp.c:req_timeout() transaction 4 retry false D/bluetoothd: bluetoothd[885]: profiles/audio/avctp.c:req_timeout() transaction 4 retry false

arkq commented 2 days ago

ALSA lib bluealsa-pcm.c:1638:(_snd_pcm_bluealsa_open) Couldn't get BlueALSA PCM: Get PCM: Get properties: Incorrect variant for 'Volume': q != a

It seems that you are trying to use bluealsad and bluealsa ALSA plugin from different builds. There was a non-backward compatible change in 0d488c7b67.

profiles/audio/avctp.c:req_timeout() transaction 4 retry false

It looks like something is not right with the sink device (speaker/earbuds) then. Alternatively try different versions of BlueZ (maybe there is some bug in BlueZ). If nothing helps, in order to get better user experience with such devices, you will have to switch to software volume. Add SOFTVOL option to the ALSA device string, e.g. bluealsa:DEV=01:23:45:67:89:AB,PROFILE=a2dp,SOFTVOL=yes

Asikbct commented 2 days ago

@arkq Thanks for the response. bluealsa:DEV=01:23:45:67:89:AB,PROFILE=a2dp,SOFTVOL=yes if I give a PCM device name like the above, Will it work with Absolute volume support or only software Alsa volume handling? If it does not support abs volume support, how to change the sink speaker's system volume instead of audio volume?