Impossible to stream another sound when mpd is used (Device or resource busy)

Hi,

I use mopidy with jasper like to control my music with my voice.

It’s work but when I start my command and the music start. my jasper like must play a litle song but my jasper like because :

play FAIL formats: can't open output file `default': snd_pcm_open error: Device or resource busy 
ERROR: play command failed

My all log is

pi@raspberrypi:~/jarvis $ ./jarvis.sh 
jarvis: Hi
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jackdmp 1.9.10
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2014 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
Failed to connect to session bus for device reservation Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

Audio device hw:0 cannot be acquired...
Cannot initialize driver
JackServer::Open failed with -1
Failed to open server
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
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

[jack.c:252] error: Failed to open jack client: 0x11
[jack.c:58] warning: FIXME: One needs to wait or write some silence here to prevent the last bits of audio to vanish out of the ringbuffer.
tts_engines/google/main.sh: line 38:  1856 Segmentation fault      mpg123 -q $audio_file
jarvis: Waiting to hear 'jarvis'
Tymoti: play FAIL formats: can't open output file `default': snd_pcm_open error: Device or resource busy
ERROR: play command failed

It’s a alsa problem no ?

pi@raspberrypi:~/jarvis $ sudo fuser -fv /dev/snd/* /dev/dsp*
Specified filename /dev/dsp* does not exist.
                     USER        PID ACCESS COMMAND
/dev/snd/controlC2:  pi          784 F.... lxpanel
/dev/snd/pcmC1D0p:   root        526 F.... mopidy

Here there are maybe a solution with mpd.conf : https://bbs.archlinux.org/viewtopic.php?pid=961638#p961638

But I don’t find a mpd.conf file in my raspberry and in mpd config in Mopidy doesn’t have mixer_type, mixer_device, mixer_control

Thanks

You don’t say what sound system you are using, is it alsa, pulseaudio or Jack(!).

Assuming you are using alsa:
Only one process may grab a hardware alsa device at a time. If mopidy has opened the alsa device (by playing a song) then jarvis cannot then also use the device. And vice versa.

The thread you linked to suggests defining an alsa dmix plugin in /etc/asound.conf which will allow multiple processes to use the audio device at the same time. I would guess this is the way to go, and then just make it the default device.

Mopidy does not have an mpd.conf file as this is a configuration file for mpd. Mopidy configuration is done in mopidy.conf and the location depends on if you are running Mopidy as a service or not. See the docs for more details.

Maybe it’s the same problem I had with AirPlay: Most Mopidy-Interfaces don’t have a Stop Button, only a Pause. And this keeps the output device busy. That’s the reason I use Mopidy-Mobile.

1 Like

Thank you for your answer.
Sorry for my delay.

I use alasa, I configurated mopidy to use alsaink and I edited my asoundrc to add dmix plugin :

pcm.dmixed {
    type dmix
    ipc_key 1024
    ipc_key_add_uid 0
    slave.pcm "hw:1,0"
}
pcm.dsnooped {
    type dsnoop
    ipc_key 1025
    slave.pcm "hw:0,0"
}

pcm.duplex {
    type asym
    playback.pcm "dmixed"
    capture.pcm "dsnooped"
}

# Instruct ALSA to use pcm.duplex as the default device
pcm.!default {
    type plug
    slave.pcm "duplex"
}

ctl.!default {
    type hw
    card 1
}

pcm.mopidy {
    type plug
    slave.pcm "duplex"
}

I configurated /etc/mpd.conf

audio_output {
    type        "alsa"
    name        "doerks ALSA Device"
#    device        "hw:0,0"    # optional
#    format        "44100:16:2"    # optional
    mixer_type      "software"    # optional
    mixer_device    "mopidy"    # optional
    mixer_control    "PCM"        # optional
#    mixer_index    "0"        # optional
}

But I have forever the problem :

ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
play FAIL formats: can't open output file `default': snd_pcm_open error: Device or resource busy
ERROR: play command failed

Thanks

I forget that mopidy doesn’t use mpd.conf

But how I can change the device used by alsasink, cf. doc of alsasink ?

And why I start one music with mpg123 and start my jasper like, there are no problem with two song together.
But when I start mopidy (music launched) and would like to start another song with mpg123. I have a problem ?

mpg123 flume.mp3 
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jackdmp 1.9.10
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2014 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
Failed to connect to session bus for device reservation Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

Audio device hw:0 cannot be acquired...
Cannot initialize driver
JackServer::Open failed with -1
Failed to open server
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel 

I don’t understand, why pcm.!default doesn’t use many times (dmix plugin) with mopidy.
Maybe because one is in daemon and the other no ?

Do you have idea ?

Thanks

Since you have not specified if it’s a daemon or not we cannot know.

For sanity, I would suggest you copy your ~/.asoundrc file to /etc/asound.conf and then remove ~/.asoundrc. Then all users on your system will use the same configuration will sill see the same default audio device.

Thanks for you answer.

I start mopidy since cronjob when I reboot @reboot mopidy;

I tested to copy in /etc/asound.conf but I have already the problem.

I really don’t understand why it doesn’t work.

Did you setup a /root/.asoundrc file?
It seems your jasper/jack configuration tries to grab the alsa hw device. This not possible while other pcm you defined are using the device.

Also you can specify the alsa device mopedy should use in mopedy.conf like so:

[audio]
output = alsasink device=dmixed

Thank you very much is that,

Just copy/paste

cp /home/pi/.asoundrc /root/.asoundrc

thank you very much