ALSA behaviour on stereo mic during process suspend
Goal
- Suspend a Python process listening to
pcm.record_right
(for Google-Assistant) - Continue using
pcm.record_left
in a different python process (for Snowboy hotword detection)
Use Case
- I want to use Snowboy to detect a hotword and then pass further voice interaction over to Google Assistant. Once the conversation finishes, I want to disable Google Assistant until I request it from Snowboy again.
- I'm working with the Google-Assistant Library SDK and want to ensure that it is not listening, unless I permit it! (So using the SDK's mic-mute command isn't enough.)
- I am using a Raspberry Pi 3B+ and an external USB stereo mic (Blue Snowball).
- The reason that I want to suspend and un-suspend the Assistant process is that if I stop and start the program entirely, it takes too long (between when Snowboy detects the hotword and when the Assistant is ready).
What I've Tried
- I've used the
.asoundrc
settings below. When I suspend the Assistant process (accessing the right mic), I runarecord
usingrecord_left
, but get the error below. For testing purposes, I usekill -STOP <pid>
andkill -CONT <pid>
. - I also tried sharing the mic (using dsnoop) without separating the left and right channels, but got the same error.
- I've also tried to trace where Google's SDK disables the mic, but their sample Python code loads a shared object called
libassistant_embedder.so
which is not open-source.
Questions
- Is it possible to suspend a linux process that is using an ALSA device and still leave the device available?
- If not, does anyone know if JACK-Audio might be able to do this?
- Any other approaches that might work?
Error
ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave arecord: main:788: audio open error: Device or resource busy
Contents of ~/.asoundrc
pcm.!default {
type asym
capture.pcm "mic"
playback.pcm "speaker"
}
pcm.mic {
type plug
slave {
pcm "hw:1,0"
}
}
pcm.speaker {
type plug
slave {
pcm "hw:0,0"
}
}
# see: https://alsa.opensrc.org/Dsnoop, section 1.2.3
pcm.record_left {
type dsnoop
ipc_key 234884
slave {
pcm "hw:1,0"
channels 2
rate 48000
}
bindings.0 0 #pick one of the stereo mic channels
}
pcm.record_right {
type dsnoop
ipc_key 2241234
slave {
pcm "hw:1,0"
channels 2
rate 48000
}
bindings.0 1 #pick the other of the stereo mic channels
}
audio alsa
New contributor
add a comment |
Goal
- Suspend a Python process listening to
pcm.record_right
(for Google-Assistant) - Continue using
pcm.record_left
in a different python process (for Snowboy hotword detection)
Use Case
- I want to use Snowboy to detect a hotword and then pass further voice interaction over to Google Assistant. Once the conversation finishes, I want to disable Google Assistant until I request it from Snowboy again.
- I'm working with the Google-Assistant Library SDK and want to ensure that it is not listening, unless I permit it! (So using the SDK's mic-mute command isn't enough.)
- I am using a Raspberry Pi 3B+ and an external USB stereo mic (Blue Snowball).
- The reason that I want to suspend and un-suspend the Assistant process is that if I stop and start the program entirely, it takes too long (between when Snowboy detects the hotword and when the Assistant is ready).
What I've Tried
- I've used the
.asoundrc
settings below. When I suspend the Assistant process (accessing the right mic), I runarecord
usingrecord_left
, but get the error below. For testing purposes, I usekill -STOP <pid>
andkill -CONT <pid>
. - I also tried sharing the mic (using dsnoop) without separating the left and right channels, but got the same error.
- I've also tried to trace where Google's SDK disables the mic, but their sample Python code loads a shared object called
libassistant_embedder.so
which is not open-source.
Questions
- Is it possible to suspend a linux process that is using an ALSA device and still leave the device available?
- If not, does anyone know if JACK-Audio might be able to do this?
- Any other approaches that might work?
Error
ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave arecord: main:788: audio open error: Device or resource busy
Contents of ~/.asoundrc
pcm.!default {
type asym
capture.pcm "mic"
playback.pcm "speaker"
}
pcm.mic {
type plug
slave {
pcm "hw:1,0"
}
}
pcm.speaker {
type plug
slave {
pcm "hw:0,0"
}
}
# see: https://alsa.opensrc.org/Dsnoop, section 1.2.3
pcm.record_left {
type dsnoop
ipc_key 234884
slave {
pcm "hw:1,0"
channels 2
rate 48000
}
bindings.0 0 #pick one of the stereo mic channels
}
pcm.record_right {
type dsnoop
ipc_key 2241234
slave {
pcm "hw:1,0"
channels 2
rate 48000
}
bindings.0 1 #pick the other of the stereo mic channels
}
audio alsa
New contributor
Not sure if ALSA can do that. Is Pulseaudio an option? It decouples transport from the sources/sinks, so use a Pulseaudio module to create two sources for right and left. Then you can suspend applications reading from one source, while applications reading from the other source continue.
– dirkt
Jan 15 at 7:08
Thanks @dirkt, I'm open to all options. Reading up on Pulseaudio now.
– DigitalThor
Jan 16 at 5:01
add a comment |
Goal
- Suspend a Python process listening to
pcm.record_right
(for Google-Assistant) - Continue using
pcm.record_left
in a different python process (for Snowboy hotword detection)
Use Case
- I want to use Snowboy to detect a hotword and then pass further voice interaction over to Google Assistant. Once the conversation finishes, I want to disable Google Assistant until I request it from Snowboy again.
- I'm working with the Google-Assistant Library SDK and want to ensure that it is not listening, unless I permit it! (So using the SDK's mic-mute command isn't enough.)
- I am using a Raspberry Pi 3B+ and an external USB stereo mic (Blue Snowball).
- The reason that I want to suspend and un-suspend the Assistant process is that if I stop and start the program entirely, it takes too long (between when Snowboy detects the hotword and when the Assistant is ready).
What I've Tried
- I've used the
.asoundrc
settings below. When I suspend the Assistant process (accessing the right mic), I runarecord
usingrecord_left
, but get the error below. For testing purposes, I usekill -STOP <pid>
andkill -CONT <pid>
. - I also tried sharing the mic (using dsnoop) without separating the left and right channels, but got the same error.
- I've also tried to trace where Google's SDK disables the mic, but their sample Python code loads a shared object called
libassistant_embedder.so
which is not open-source.
Questions
- Is it possible to suspend a linux process that is using an ALSA device and still leave the device available?
- If not, does anyone know if JACK-Audio might be able to do this?
- Any other approaches that might work?
Error
ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave arecord: main:788: audio open error: Device or resource busy
Contents of ~/.asoundrc
pcm.!default {
type asym
capture.pcm "mic"
playback.pcm "speaker"
}
pcm.mic {
type plug
slave {
pcm "hw:1,0"
}
}
pcm.speaker {
type plug
slave {
pcm "hw:0,0"
}
}
# see: https://alsa.opensrc.org/Dsnoop, section 1.2.3
pcm.record_left {
type dsnoop
ipc_key 234884
slave {
pcm "hw:1,0"
channels 2
rate 48000
}
bindings.0 0 #pick one of the stereo mic channels
}
pcm.record_right {
type dsnoop
ipc_key 2241234
slave {
pcm "hw:1,0"
channels 2
rate 48000
}
bindings.0 1 #pick the other of the stereo mic channels
}
audio alsa
New contributor
Goal
- Suspend a Python process listening to
pcm.record_right
(for Google-Assistant) - Continue using
pcm.record_left
in a different python process (for Snowboy hotword detection)
Use Case
- I want to use Snowboy to detect a hotword and then pass further voice interaction over to Google Assistant. Once the conversation finishes, I want to disable Google Assistant until I request it from Snowboy again.
- I'm working with the Google-Assistant Library SDK and want to ensure that it is not listening, unless I permit it! (So using the SDK's mic-mute command isn't enough.)
- I am using a Raspberry Pi 3B+ and an external USB stereo mic (Blue Snowball).
- The reason that I want to suspend and un-suspend the Assistant process is that if I stop and start the program entirely, it takes too long (between when Snowboy detects the hotword and when the Assistant is ready).
What I've Tried
- I've used the
.asoundrc
settings below. When I suspend the Assistant process (accessing the right mic), I runarecord
usingrecord_left
, but get the error below. For testing purposes, I usekill -STOP <pid>
andkill -CONT <pid>
. - I also tried sharing the mic (using dsnoop) without separating the left and right channels, but got the same error.
- I've also tried to trace where Google's SDK disables the mic, but their sample Python code loads a shared object called
libassistant_embedder.so
which is not open-source.
Questions
- Is it possible to suspend a linux process that is using an ALSA device and still leave the device available?
- If not, does anyone know if JACK-Audio might be able to do this?
- Any other approaches that might work?
Error
ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave arecord: main:788: audio open error: Device or resource busy
Contents of ~/.asoundrc
pcm.!default {
type asym
capture.pcm "mic"
playback.pcm "speaker"
}
pcm.mic {
type plug
slave {
pcm "hw:1,0"
}
}
pcm.speaker {
type plug
slave {
pcm "hw:0,0"
}
}
# see: https://alsa.opensrc.org/Dsnoop, section 1.2.3
pcm.record_left {
type dsnoop
ipc_key 234884
slave {
pcm "hw:1,0"
channels 2
rate 48000
}
bindings.0 0 #pick one of the stereo mic channels
}
pcm.record_right {
type dsnoop
ipc_key 2241234
slave {
pcm "hw:1,0"
channels 2
rate 48000
}
bindings.0 1 #pick the other of the stereo mic channels
}
audio alsa
audio alsa
New contributor
New contributor
edited Jan 14 at 21:25
DigitalThor
New contributor
asked Jan 14 at 20:32
DigitalThorDigitalThor
32
32
New contributor
New contributor
Not sure if ALSA can do that. Is Pulseaudio an option? It decouples transport from the sources/sinks, so use a Pulseaudio module to create two sources for right and left. Then you can suspend applications reading from one source, while applications reading from the other source continue.
– dirkt
Jan 15 at 7:08
Thanks @dirkt, I'm open to all options. Reading up on Pulseaudio now.
– DigitalThor
Jan 16 at 5:01
add a comment |
Not sure if ALSA can do that. Is Pulseaudio an option? It decouples transport from the sources/sinks, so use a Pulseaudio module to create two sources for right and left. Then you can suspend applications reading from one source, while applications reading from the other source continue.
– dirkt
Jan 15 at 7:08
Thanks @dirkt, I'm open to all options. Reading up on Pulseaudio now.
– DigitalThor
Jan 16 at 5:01
Not sure if ALSA can do that. Is Pulseaudio an option? It decouples transport from the sources/sinks, so use a Pulseaudio module to create two sources for right and left. Then you can suspend applications reading from one source, while applications reading from the other source continue.
– dirkt
Jan 15 at 7:08
Not sure if ALSA can do that. Is Pulseaudio an option? It decouples transport from the sources/sinks, so use a Pulseaudio module to create two sources for right and left. Then you can suspend applications reading from one source, while applications reading from the other source continue.
– dirkt
Jan 15 at 7:08
Thanks @dirkt, I'm open to all options. Reading up on Pulseaudio now.
– DigitalThor
Jan 16 at 5:01
Thanks @dirkt, I'm open to all options. Reading up on Pulseaudio now.
– DigitalThor
Jan 16 at 5:01
add a comment |
1 Answer
1
active
oldest
votes
Not sure if ALSA can do that.
Is Pulseaudio an option? It decouples transport from the sources/sinks, so use a Pulseaudio module to create two sources for right and left. Then you can suspend applications reading from one source, while applications reading from the other source continue.
You'll need two module-remap-source. Use pacmd
or pactrl
to make them. Play around until it works (remove them first with unload-module
if you want to change anything), then put it into the Pulseaudio configuration files. Use pavucontrol
to get an idea what sources/sinks you have, and what applications are using them, and to set volumes.
Thanks for the compass headings @dirkt! I got pulseaudio installed and played with a fewpacmd
commands. Slow going since day-job keeps me busy on other things, but I'll keep at PA and report back.
– DigitalThor
Jan 17 at 5:05
1
Hi @dirkt, thanks again. I got this working with pulseaudio. I was able to get two processes to connect to the default pulse-audio mic source using .asoundrc withpcm.!default pulse ctl.!default pulse
I didn't even have to separate the left and right channels nor use themodule-remap-source
since pulseaudio didn't complain when one of the connected processes was suspended.
– DigitalThor
8 hours ago
That's even simpler. :-)
– dirkt
8 hours ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
DigitalThor is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f494492%2falsa-behaviour-on-stereo-mic-during-process-suspend%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Not sure if ALSA can do that.
Is Pulseaudio an option? It decouples transport from the sources/sinks, so use a Pulseaudio module to create two sources for right and left. Then you can suspend applications reading from one source, while applications reading from the other source continue.
You'll need two module-remap-source. Use pacmd
or pactrl
to make them. Play around until it works (remove them first with unload-module
if you want to change anything), then put it into the Pulseaudio configuration files. Use pavucontrol
to get an idea what sources/sinks you have, and what applications are using them, and to set volumes.
Thanks for the compass headings @dirkt! I got pulseaudio installed and played with a fewpacmd
commands. Slow going since day-job keeps me busy on other things, but I'll keep at PA and report back.
– DigitalThor
Jan 17 at 5:05
1
Hi @dirkt, thanks again. I got this working with pulseaudio. I was able to get two processes to connect to the default pulse-audio mic source using .asoundrc withpcm.!default pulse ctl.!default pulse
I didn't even have to separate the left and right channels nor use themodule-remap-source
since pulseaudio didn't complain when one of the connected processes was suspended.
– DigitalThor
8 hours ago
That's even simpler. :-)
– dirkt
8 hours ago
add a comment |
Not sure if ALSA can do that.
Is Pulseaudio an option? It decouples transport from the sources/sinks, so use a Pulseaudio module to create two sources for right and left. Then you can suspend applications reading from one source, while applications reading from the other source continue.
You'll need two module-remap-source. Use pacmd
or pactrl
to make them. Play around until it works (remove them first with unload-module
if you want to change anything), then put it into the Pulseaudio configuration files. Use pavucontrol
to get an idea what sources/sinks you have, and what applications are using them, and to set volumes.
Thanks for the compass headings @dirkt! I got pulseaudio installed and played with a fewpacmd
commands. Slow going since day-job keeps me busy on other things, but I'll keep at PA and report back.
– DigitalThor
Jan 17 at 5:05
1
Hi @dirkt, thanks again. I got this working with pulseaudio. I was able to get two processes to connect to the default pulse-audio mic source using .asoundrc withpcm.!default pulse ctl.!default pulse
I didn't even have to separate the left and right channels nor use themodule-remap-source
since pulseaudio didn't complain when one of the connected processes was suspended.
– DigitalThor
8 hours ago
That's even simpler. :-)
– dirkt
8 hours ago
add a comment |
Not sure if ALSA can do that.
Is Pulseaudio an option? It decouples transport from the sources/sinks, so use a Pulseaudio module to create two sources for right and left. Then you can suspend applications reading from one source, while applications reading from the other source continue.
You'll need two module-remap-source. Use pacmd
or pactrl
to make them. Play around until it works (remove them first with unload-module
if you want to change anything), then put it into the Pulseaudio configuration files. Use pavucontrol
to get an idea what sources/sinks you have, and what applications are using them, and to set volumes.
Not sure if ALSA can do that.
Is Pulseaudio an option? It decouples transport from the sources/sinks, so use a Pulseaudio module to create two sources for right and left. Then you can suspend applications reading from one source, while applications reading from the other source continue.
You'll need two module-remap-source. Use pacmd
or pactrl
to make them. Play around until it works (remove them first with unload-module
if you want to change anything), then put it into the Pulseaudio configuration files. Use pavucontrol
to get an idea what sources/sinks you have, and what applications are using them, and to set volumes.
answered Jan 16 at 6:16
dirktdirkt
16.8k21336
16.8k21336
Thanks for the compass headings @dirkt! I got pulseaudio installed and played with a fewpacmd
commands. Slow going since day-job keeps me busy on other things, but I'll keep at PA and report back.
– DigitalThor
Jan 17 at 5:05
1
Hi @dirkt, thanks again. I got this working with pulseaudio. I was able to get two processes to connect to the default pulse-audio mic source using .asoundrc withpcm.!default pulse ctl.!default pulse
I didn't even have to separate the left and right channels nor use themodule-remap-source
since pulseaudio didn't complain when one of the connected processes was suspended.
– DigitalThor
8 hours ago
That's even simpler. :-)
– dirkt
8 hours ago
add a comment |
Thanks for the compass headings @dirkt! I got pulseaudio installed and played with a fewpacmd
commands. Slow going since day-job keeps me busy on other things, but I'll keep at PA and report back.
– DigitalThor
Jan 17 at 5:05
1
Hi @dirkt, thanks again. I got this working with pulseaudio. I was able to get two processes to connect to the default pulse-audio mic source using .asoundrc withpcm.!default pulse ctl.!default pulse
I didn't even have to separate the left and right channels nor use themodule-remap-source
since pulseaudio didn't complain when one of the connected processes was suspended.
– DigitalThor
8 hours ago
That's even simpler. :-)
– dirkt
8 hours ago
Thanks for the compass headings @dirkt! I got pulseaudio installed and played with a few
pacmd
commands. Slow going since day-job keeps me busy on other things, but I'll keep at PA and report back.– DigitalThor
Jan 17 at 5:05
Thanks for the compass headings @dirkt! I got pulseaudio installed and played with a few
pacmd
commands. Slow going since day-job keeps me busy on other things, but I'll keep at PA and report back.– DigitalThor
Jan 17 at 5:05
1
1
Hi @dirkt, thanks again. I got this working with pulseaudio. I was able to get two processes to connect to the default pulse-audio mic source using .asoundrc with
pcm.!default pulse ctl.!default pulse
I didn't even have to separate the left and right channels nor use the module-remap-source
since pulseaudio didn't complain when one of the connected processes was suspended.– DigitalThor
8 hours ago
Hi @dirkt, thanks again. I got this working with pulseaudio. I was able to get two processes to connect to the default pulse-audio mic source using .asoundrc with
pcm.!default pulse ctl.!default pulse
I didn't even have to separate the left and right channels nor use the module-remap-source
since pulseaudio didn't complain when one of the connected processes was suspended.– DigitalThor
8 hours ago
That's even simpler. :-)
– dirkt
8 hours ago
That's even simpler. :-)
– dirkt
8 hours ago
add a comment |
DigitalThor is a new contributor. Be nice, and check out our Code of Conduct.
DigitalThor is a new contributor. Be nice, and check out our Code of Conduct.
DigitalThor is a new contributor. Be nice, and check out our Code of Conduct.
DigitalThor is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f494492%2falsa-behaviour-on-stereo-mic-during-process-suspend%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Not sure if ALSA can do that. Is Pulseaudio an option? It decouples transport from the sources/sinks, so use a Pulseaudio module to create two sources for right and left. Then you can suspend applications reading from one source, while applications reading from the other source continue.
– dirkt
Jan 15 at 7:08
Thanks @dirkt, I'm open to all options. Reading up on Pulseaudio now.
– DigitalThor
Jan 16 at 5:01