bt-speaker
bt-speaker copied to clipboard
on-connect and on-disconnect audio does not play, aplay is blocking
Hello,
Great project. I am trying to tinker with this to work for my needs.
One issue I have run into is that the service which streams the audio appears to block the alsa sink device from other sources. When I connect to the speaker, I get the following output:
Device connected. device=/org/bluez/hci0/dev_14_A3_64_58_DB_F9
Hiding adapter from all devices.
aplay: main:722: audio open error: Device or resource busy
Similarly on disconnect:
Device disconnected. device=/org/bluez/hci0/dev_14_A3_64_58_DB_F9
Showing adapter to all devices.
aplay: main:722: audio open error: Device or resource busy
But I can play audio just fine (except for the WiFi-caused underruns in issue #4 ).
Here is my /etc/bt_speaker/config.ini
file:
[bt_speaker]
play_command = aplay -D plug0 -f cd -
connect_command = aplay -D plug0 /usr/share/sounds/freedesktop/stereo/service-login.wav
disconnect_command = aplay -D plug0 /usr/share/sounds/freedesktop/stereo/service-logout.wav
[bluez]
device_path = /org/bluez/hci0
[alsa]
mixer = PCM
Let me know what I can try.
I think your sound card (plug0) does not have an integrated hardware mixer. That is why you can only use one sound stream at a time, preventing the login/logout sounds which are played after the bluetooth audio stream connects (to your soundcard).
I don't think a mixer function belongs in this repository, so your best bet is to setup a software mixer with alsa.
http://alsa.opensrc.org/Hardware_mixing,_software_mixing
Or you could try to use a full suite like pulseaudio or jack. But I only had trouble with those on the Pi, thats the reason I made this project.
Or you could try to use a full suite like pulseaudio or jack. But I only had trouble with those on the Pi, thats the reason I made this project.
And that's the reason I am using this project. I love simple and low-level over the black magic of pulseaudio.
I think software mixing is the ticket. Thanks for your help.
I would like to leave this open until I can post a solution or my findings. What do you think?
Just out of curiosity, do you think the lack of a hardware mixer is due to a driver issue, or the USB audio chip (PCM2704) simply lacks the functionality?
A very quick research left me with even more questions but I get the impression that the mixing function is build in the driver (called mmap
) rather than using real hardware mixing.
Anybody correct me if I am wrong.
ALSA seems to have settings for mmap in the config too. I think people will appreciate it if you can manage to post a working config.