-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assistance debugging arecord "Couldn't get BlueALSA PCM: PCM not found" #352
Comments
You cannot have both pulseaudio and bluealsa accessing bluetooth audio; did you disable the pulseaudio bluetooth modules?
If bluealsa-aplay is capturing from your 'phone, then arecord will not be able to capture at the same time. |
From README:
Hence, connected devices will not be available in the
What kind of playing? You have smartphone connected to RPi and you can play audio from smartphone via bluetooth on RPi internal sound card using bluealsa-aplay, is that right? If the above statement is true, then there is an issue with bluealsa ALSA plugin. Please see this comment: #347 (comment) |
@borine trying to open PCM twice results in "EBUSY" error, e.g.: $ bluealsa-aplay 10:B1:F8:E6:10:D4 >/dev/null &
$ arecord -D smartphone
D: bluealsa-pcm.c:671: /org/bluealsa/hci0/dev_10_B1_F8_E6_10_D4/a2dpsnk/source: Setting constraints
Recording WAVE 'stdin' : Unsigned 8 bit, Rate 8000 Hz, Mono
D: bluealsa-pcm.c:368: /org/bluealsa/hci0/dev_10_B1_F8_E6_10_D4/a2dpsnk/source: Initializing HW
D: bluealsa-pcm.c:375: /org/bluealsa/hci0/dev_10_B1_F8_E6_10_D4/a2dpsnk/source: Couldn't open PCM: Device or resource busy |
Do you have defined |
Thanks for you tips. pulse is not installed or running. ("ps aux | grep pulse" to confirm) "If bluealsa-aplay is capturing from your 'phone, then arecord will not be able to capture at the same time" - is there another way? bluealsa-aplay-l or -L is not supported. bluealsa-aplay version 1.4.0 "You have smartphone connected to RPi and you can play audio from smartphone via bluetooth on RPi internal sound card using bluealsa-aplay, is that right?" - that is correct. Do you have defined bluealsa in your local .asoundrc file? - using asound.conf - I'm not an expert at alsa - the docs said to use asym - one for capture - one for playback. Playback works. Playback goes from asym ==> mon ==> softvol ==> dmix ==> hw. Capture goes from asym ==> dsnoop ==> bluealsa ==> hw Maybe my asound.conf is wrong? |
I'm afraid dsnoop is not supported by bluealsa. Also, I advise to use fresh master snapshot - bluez-alsa-1.4.0 is pretty much outdated. |
OK - downloaded, built, installed from git. Streaming from phone to RPI over bluetooth still works - that's good. bluealsa-aplay -V bluealsa-aplay -L bluealsa-aplay -l arecord -D bluealsa -d 1 /tmp/test.wav I removed the dsnoop from the asound.conf https://pastebin.com/FEQVhZsQ I think I'm closer....: arecord -D bluealsa:SRV=org.bluealsa,DEV=14:9F:3C:E7:48:54,PROFILE=a2dp -d 1 /tmp/test.wav |
Yes, that's the case where you try to open PCM more then once, which is currently not possible. If you kill bluealsa-aplay (or some other application which might use bluealsa), you shall be able to use arecord. |
It seems to be working now. It writes out a .wav file. The file seems to only have the wav header in it - but that's a minor detail. Thank you for your assistance and advice. Unfortunately, I think what I wanted to do is not possible - use a raspberry pi board for a bluetooth speaker with a built in audio spectrum visualizer. The bluetooth speaker part works - but there is no way to access the audio stream once it's running to connect the visualizer. sudo arecord -D bluealsa:SRV=org.bluealsa,DEV=14:9F:3C:E7:48:54,PROFILE=a2dp -d 5 /tmp/test.wav |
Currently it's not possible out of the box. But I think you shall search through bluez-alsa issues for |
Thanks Arkq. I think I might be at the end of my skills with this one. Whoever put this bluealsa stuff together knows 1000X more than I do. What would take them an hour would take me the rest of my life. I'll check back periodically, maybe I just shelve this idea for now. I guess this issue is closed out - thanks. |
I haven't tried this myself, but something like this might work:
or, if you want to pipe the stream directly into a spectrum visualizer program:
|
Actually, just tried it on my laptop with cava (https://github.com/karlstav/cava) cava requires the FIFO name to be put in its config fie, so I put in the
then tried it with:
cool !! |
Here's another solution, this time using bluealsa-aplay. This one requires an entry in ~/.asoundrc
A fifo will block if nothing is reading from it, so we need to start the visualizer before bluealsa-aplay; that's easier if we do it in a different terminal window.
I've used
but you could also use I like this solution better, because you do not need to hard-code the 'phone bluetooth address into any config files. . |
I think I found something I can work with. I used the fifo_copy approach from borine (thanks borine). I loaded snd_aloop into the module.conf. When you read the stream from the fifo with a simple file reader (cat /tmp/bluealsa.fifo works too) , the audio plays through the speaker. I couldn't get cava working, but I'll work on that later - looks like a cool program. But I think I can make this work - thanks all. |
Loopback is not needed in this solution; that's only required for dsnoop with bluealsa, and this method is intended to avoid the complexity of all that. BTW I wasn't trying to recommend cava - I have no experience with (or knowledge of) audio spectrum visualization. I was just looking for a very simple application I could use for testing, and cava was the first hit I found. I'm sure that just about any audio visualizer will work with the fifo_copy method. |
After a day of using it - it works okay. If you are not reading from the named pipe file, bluetooth-aplay will terminate after a while. And if you stop reading from the pipe - same thing - blueotooth-aplay will terminate. So the blocking in a pipe and bluetooth-aplay stopping is something you have to work around. (killall bluetooth-aplay & restart) - Thanks All |
A weakness of the fifo approach is that you have to make sure the visualizer is running at all times, otherwise playback will be blocked waiting for it to start, and any application using the fifo output will be terminated wehn the visualizer terminates. Do really need to monitor the input stream? You would have much more flexibility if you can monitor the output instead. Here is another solution that visualizes the audio playing though the i2c soundcard. This one does require the Loopback device, so you would need to load the snd-aloop kernel module. The alsa configuration looks like this:
The visualizer then needs to read the stream from the device hw:Looback,0,0. For example, using cava, the config would be:
and you can run bluealsa-aplay as
Now you can stop and start the visualizer as you wish, playback will continue unaffected. |
thanks borine - I just tried it out and I like that a lot better. bluealsa-aplay works as expected. And my application can pick up the loopback independent of the bluealsa-aplay. It even works with the standard java audio interface - I can record the stream to a wav file, and everything checks out. Now I can use the data for the visualizer. you rock - thanks. |
If you need to both record and visualize, then you can wrap the loopback capture device with dsnoop so that multiple applications can capture from it:
visualizer should then use the dsnoop device:
and you can record from it at the same time, eg:
|
This issue appears to be resolved |
I could use some assistance finding a way to get arecord to work. I can't seem to configure this to make a device available to record from. (Playing works fine - BT connection from phone audio to Raspberry PI board a2dp-sink with I2S amplifier/speaker using alsa). I just can't get access to read from the stream. I can see the mixer in alsamixer has a capture PCM - I just can open it. Thanks in advance for any advice.
error:
arecord -D bluealsa -d 1 /tmp/test.wav
ALSA lib bluealsa-pcm.c:763:(_snd_pcm_bluealsa_open) Couldn't get BlueALSA PCM: PCM not found
amixer -D bluealsa
Simple mixer control 'galaxys9 - A2DP',0
Capabilities: cvolume cswitch
Capture channels: Front Left - Front Right
Limits: Capture 0 - 127
Front Left: Capture 94 [74%] [on]
Front Right: Capture 94 [74%] [on]
arecord -l
**** List of CAPTURE Hardware Devices ****
<nothing?>
arecord -L
null
Discard all samples (playback) or generate zero samples (capture)
jack
JACK Audio Connection Kit
pulse
PulseAudio Sound Server
default
mono
softvol
dmixer
soundcard
dsnooped
bluetooth
usbstream:CARD=sndrpihifiberry
snd_rpi_hifiberry_dac
USB Stream Output
ps aux | grep alsa
root 250 0.0 0.4 3676 2056 ? SNs 10:08 0:00 /usr/sbin/alsactl -E HOME=/run/alsa -s -n 19 -c rdaemon
root 284 7.6 1.1 34888 5084 ? Ssl 10:08 7:05 /usr/bin/bluealsa -p a2dp-sink
dan 359 6.2 0.7 15504 3200 ? SLsl 10:09 5:45 /usr/bin/bluealsa-aplay 00:00:00:00:00:00
https://pastebin.com/5WhLsaXv
The text was updated successfully, but these errors were encountered: