Ruchunteur
Posts: 7
Joined: Mon Mar 27, 2017 10:00 am

Two application using the mic in the same time

Tue Apr 18, 2017 10:27 am

Hello. want to use my mic on two different module of Mich magic mirror. But only one module is able to use the mic at the time.
When one of the module use it, I can't even do an arecord because the mic is busy.

Is there a way to allow multiple application to use the same mic in the same time ?

YCN-
Posts: 246
Joined: Fri Jun 10, 2016 3:18 pm

Re: Two application using the mic in the same time

Tue Apr 18, 2017 12:48 pm

I don't think so, or else you'll need another soundcard (or one that has two audio input) and you'll need to duplicate the signal using analog stuff.
But I don't think there's way to duplicate the signal. Or maybe you'll be able to do something in kernel space.

YCN-

Ruchunteur
Posts: 7
Joined: Mon Mar 27, 2017 10:00 am

Re: Two application using the mic in the same time

Thu Apr 20, 2017 7:33 am

I find a way usind asound.conf file (/etc/asound.conf) as follow :

Code: Select all

pcm.myTest {
    type dsnoop
    ipc_key 2241234
    slave {
        pcm "hw:1,0"
        channels 1
    }
}

pcm.!default {
        type asym
        playback.pcm {
                type plug
                slave.pcm "hw:0,0"
        }
        capture.pcm {
                type plug
                slave.pcm "myTest"
        }
}
I thinks it's for configuring alsa configuration. (using a .asoundrc in the home directory of my user might have been enough, but the /etc/asound.conf make sure all the users have the same configuration. Since some service my use some of my sound devices, I rather have a global configuration)
The pcm/!default {} is for describing what the "default" configuration is (! is for overwriting an already existing "default". Default is just a name, I could have name it anything but most application don't allow to choose which one to use so there take th default one)
The "type asym" mean that the playback and the capturing aren't done with the same sound card.
Then we explicitly say what is the name of the playback device (in my case "hw:0,0" which is the default sound card on my pi. I got the card number by using aplay -l). Then we do the same with the capturing device (aka: my secondary sound card for my microphone) but instead o directly saying that's it's the "hw:1,0" we describe it above in more detail and reefer to that name (myTest in my case)
It look likes the "type dsnoop" thingy is to say that the input device can be use by multiple application at the time.
then we say what was the sound divece ("hw:1,0" in my case) (arecord -l to have the list of the input devices) like before and we are done.

I'm not good at explaining this stuff (because i don't understand how everything works) but hopefully it can help some other people with the same issue as me.

amalkms
Posts: 2
Joined: Fri Sep 29, 2017 6:49 pm

Re: Two application using the mic in the same time

Fri Sep 29, 2017 6:56 pm

Hello ,
Actually, I have the same problem that you have but I could not fix yet, so I think i made something working
because I still get this message.

arecord: main:722: audio open error: Device or resource busy

amalkms
Posts: 2
Joined: Fri Sep 29, 2017 6:49 pm

Re: Two application using the mic in the same time

Thu Oct 05, 2017 8:33 am

this works for me https://github.com/moustaki/raspbaby/tr ... sound-conf
I just change to hw1,0 according to my USB device

and then when i try recording i use

arecord -f cd -c 1 -Dplug:dsnoop1 test.wav

motosx
Posts: 3
Joined: Sun Jun 17, 2018 7:20 pm

Re: Two application using the mic in the same time

Wed Nov 21, 2018 5:58 pm

Hey, I'm facing same problem, I need to access the mic with two different applications. I tried to use the config file provided above, but I get this error:
ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave
arecord: main:788: audio open error: No such file or directory

I'm using a mic connected to a USB audio card, any clue why I get this error?

Return to “Troubleshooting”