arkq / bluez-alsa

Bluetooth Audio ALSA Backend
MIT License
850 stars 188 forks source link

play failure at some times with rpi #261

Closed sherifomran closed 3 years ago

sherifomran commented 4 years ago

I installed the bluealsa and it was working fine but at some time i get the following


pi@raspberrypi:~ $ mpg123 --verbose -o bluealsa:DEV=00:0B:D5:F5:F8:B9,PROFILE=sco -f 200 ~/AudioMan/sounds/Azan.mp3
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
    version 1.25.10; written and copyright by Michael Hipp and others
    free software (LGPL) without any warranty but with best wishes
Decoder: generic
Trying output module: bluealsa, device: DEV=00:0B:D5:F5:F8:B9,PROFILE=sco
[src/libout123/module.c:133] error: Failed to open module bluealsa.
[src/libout123/libout123.c:455] error: Found no driver out of [bluealsa] working with device DEV=00:0B:D5:F5:F8:B9,PROFILE=sco.
main: [src/mpg123.c:309] error: out123 error 3: failure loading driver module

I tried another speaker but i get

pi@raspberrypi:~ $ mpg123 -a bluealsa:DEV=FC:58:FA:7C:33:42,PROFILE=a2dp ~/AudioMan/sounds/Azan.mp3 High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3 version 1.25.10; written and copyright by Michael Hipp and others free software (LGPL) without any warranty but with best wishes Cannot connect to server socket err = No such file or directory Cannot connect to server request channel jack server is not running or cannot be started JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock Expression 'alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, &dir )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 924 Segmentation fault

borine commented 4 years ago

I think the mpg123 command line is wrong; try:

mpg123 -o alsa -a bluealsa:DEV=00:0B:D5:F5:F8:B9,PROFILE=sco -f 200 ~/AudioMan/sounds/Azan.mp3
sherifomran commented 4 years ago

It is not a mistake in the command because it used to work fine, but at some time, it can not open the socket connection

pi@raspberrypi:~ $ mpg123 -o bluealsa:DEV=00:0B:D5:F5:F8:B9,PROFILE=sco -f 200 ~/AudioMan/sounds/Azan.mp3
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
    version 1.25.10; written and copyright by Michael Hipp and others
    free software (LGPL) without any warranty but with best wishes
[src/libout123/module.c:133] error: Failed to open module bluealsa.
[src/libout123/libout123.c:455] error: Found no driver out of [bluealsa] working with device DEV=00:0B:D5:F5:F8:B9,PROFILE=sco.
main: [src/mpg123.c:309] error: out123 error 3: failure loading driver module
pi@raspberrypi:~ $ bluetoothctl
Agent registered
[SBL 3 C3]# info
Device FC:58:FA:7C:33:42 (public)
    Name: SBL 3 C3
    Alias: SBL 3 C3
    Class: 0x00260404
    Icon: audio-card
    Paired: yes
    Trusted: yes
    Blocked: no
    Connected: yes
    LegacyPairing: no
    UUID: Serial Port               (00001101-0000-1000-8000-00805f9b34fb)
    UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
    UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
    UUID: Advanced Audio Distribu.. (0000110d-0000-1000-8000-00805f9b34fb)
    UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
[SBL 3 C3]# devices
Device FC:58:FA:7C:33:42 SBL 3 C3
Device 00:0B:D5:F5:F8:B9 JABRA DRIVE
[SBL 3 C3]# info 00:0B:D5:F5:F8:B9 
Device 00:0B:D5:F5:F8:B9 (public)
    Name: JABRA DRIVE
    Alias: JABRA DRIVE
    Class: 0x00240404
    Icon: audio-card
    Paired: yes
    Trusted: yes
    Blocked: no
    Connected: yes
    LegacyPairing: no
    UUID: Headset                   (00001108-0000-1000-8000-00805f9b34fb)
    UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
    UUID: Advanced Audio Distribu.. (0000110d-0000-1000-8000-00805f9b34fb)
    UUID: Handsfree                 (0000111e-0000-1000-8000-00805f9b34fb)
[SBL 3 C3]# exit
pi@raspberrypi:~ $ mpg123 -o alsa bluealsa:DEV=00:0B:D5:F5:F8:B9,PROFILE=sco -f 200 ~/AudioMan/sounds/Azan.mp3
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
    version 1.25.10; written and copyright by Michael Hipp and others
    free software (LGPL) without any warranty but with best wishes
ALSA lib ../../../src/asound/bluealsa-pcm.c:682:(_snd_pcm_bluealsa_open) Unknown field interface
[src/libout123/modules/alsa.c:181] error: cannot open device default
[src/libout123/libout123.c:455] error: Found no driver out of [alsa] working with device <default>.
main: [src/mpg123.c:309] error: out123 error 3: failure loading driver module
pi@raspberrypi:~ $ mpg123 -o alsa bluealsa:DEV=00:0B:D5:F5:F8:B9,PROFILE=a2dp -f 200 ~/AudioMan/sounds/Azan.mp3
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
    version 1.25.10; written and copyright by Michael Hipp and others
    free software (LGPL) without any warranty but with best wishes
ALSA lib ../../../src/asound/bluealsa-pcm.c:682:(_snd_pcm_bluealsa_open) Unknown field interface
[src/libout123/modules/alsa.c:181] error: cannot open device default
[src/libout123/libout123.c:455] error: Found no driver out of [alsa] working with device <default>.
main: [src/mpg123.c:309] error: out123 error 3: failure loading driver module
pi@raspberrypi:~ $ 
`
sherifomran commented 4 years ago

src/libout123/module.c:133 I get failed to open module bluealsa src/libout123/libout123.c:455 error: found no driver out of [bluealsa] working with device bluealsa:DEV=00:0B:D5:F5:F8:B9,PROFILE=sco main: [src/mpg123.c:309] error: out123 error 3 failure loading driver module

are we using pulse audio? how can i play mp3 using bluealsa, the only method i know is mpg123 with the device ID, otherwise i need to adjust jack or pulse audio, please correct me if i am mistaken, whereas aplay does not play mp3 files but wave files only.

i have 2 speakers and i am using keepalive but it seems that for somereason they get disconnected

when i connected the first speaker manually using bluetoothctl and pressed on the speaker, and tried the same command it works again.

this is funny, for some reason keepalive is disconnected

borine commented 4 years ago

with mpg123 you need to specify the device with -a option. the -o option specifies a mpg123 module to use.

mpg123 -o bluealsa:DEV=... will always fail because mpg123 does not have a module called bluealsa.

mp123 -o alsa bluealsa:DEV=... fails because it tries to use the alsa "default" device to play the file "bluealsa:DEV=...".

mpg123 -o alsa -a bluealsa:DEV=... should at least have a chance of working

man mpg123 explains all this.

sherifomran commented 4 years ago

i have another problem, when i use mpg123 with any syntax, the terminal freezes up and i don't hear any sound, but when i use aplay it works only with wav files. is there a way to play mp3 using aplay ? any body has an idea where the problem could be? it was working fine, may be i installed a wrong packet for mpg123

borine commented 4 years ago

i have another problem, when i use mpg123 with any syntax, the terminal freezes up and i don't hear any sound

if mpg123 locks up the terminal, that might be the libasound thread locking bug (see "2. ALSA thread-safe API (alsa-lib >= 1.1.2)" on the bluealsa home page https://github.com/Arkq/bluez-alsa. Try:

LIBASOUND_THREAD_SAFE=0 mpg123 -o alsa -a bluealsa:DEV=00:0B:D5:F5:F8:B9 ~/AudioMan/sounds/Azan.mp3

[EDIT] I've just noticed your issue #270 which appears to be a repeat of this one? If you are using pre-2.0.0 bluealsa code, then the same bug that generates the service error message reported there also causes mpg123 to be blocked. So that might be an alternative explanation for the lock-up you report here. In that case just updating bluealsa is all you need to fix things. [END EDIT]

is there a way to play mp3 using aplay ?

aplay cannot play mp3 files.

borine commented 3 years ago

mpg123 is working well with bluealsa for over a year now, so hopefully the issue is now resolved. I am closing this issue as there has been no activity for some. Please feel free to re-open it if the problem persists with latest bluealsa code.