View previous topic :: View next topic |
Author |
Message |
Langest n00b
Joined: 19 Jan 2018 Posts: 48
|
Posted: Sun Mar 04, 2018 4:50 pm Post subject: [ALSA] play sound on two devices |
|
|
Hello! I am trying to configure alsa to play audio on both my external dac and my built in speakers at the same time.
I found a very helpful stack overflow thread https://stackoverflow.com/questions/43939191/alsa-how-to-duplicate-a-stream-on-2-outputs-and-save-system-configs
The config I am using now is:
Code: | pcm.quad {
type multi
slaves.a.pcm "hw:Intel"
slaves.a.channels 2
slaves.b.pcm "dmix:Schiit"
slaves.b.channels 2
bindings.0 { slave a; channel 0; }
bindings.1 { slave a; channel 1; }
bindings.2 { slave b; channel 0; }
bindings.3 { slave b; channel 1; }
}
pcm.stereo2quad {
type route
slave.pcm "quad"
ttable.0.0 1
ttable.1.1 1
ttable.0.2 1
ttable.1.3 1
}
pcm.!default {
type asym
playback.pcm "plug:stereo2quad"
capture.pcm "plug:dsnoop:Intel"
} |
It almost works. The problem is that my intel card doesn't work with dmix. I need to set hw for it to work, see line 3. But this prevents applications from using the sound at the same time.
I would be glad if someone knew what to do or could point me in the right direction.
Thank you! |
|
Back to top |
|
|
audiodef Watchman
Joined: 06 Jul 2005 Posts: 6639 Location: The soundosphere
|
|
Back to top |
|
|
steve_v Guru
Joined: 20 Jun 2004 Posts: 388 Location: New Zealand
|
Posted: Mon Mar 05, 2018 4:16 am Post subject: Re: [ALSA] play sound on two devices |
|
|
Langest wrote: | Hello! I am trying to configure alsa to play audio on both my external dac and my built in speakers at the same time
The problem is that my intel card doesn't work with dmix. |
Doesn't work with dmix at all, or doesn't work with your current config?
Can you use dmix when outputting only to the intel card?
snd_hda_intel, I assume? I have a card using that driver, and dmix works here.
Do I read it right that you are trying to make a 4-channel device from 2 2-channel cards?
I have something vaguely similar, though with only one card, to output to both analog and spdif on my hda_intel chipset:
Code: | pcm.!default {
type plug
slave {
pcm "duplex"
}
}
pcm.duplex {
type asym
playback {
pcm "duplicate"
}
capture {
pcm "dsnoop"
}
}
pcm.duplicate {
type plug
slave.pcm {
type multi
slaves {
a { pcm "dmix:0,0" channels 2 }
b { pcm "spdif_softvol" channels 2 }
}
bindings [
{ slave a channel 0 }
{ slave a channel 1 }
{ slave b channel 0 }
{ slave b channel 1 }
]
}
ttable [
[ 1 0 1 0 ]
[ 0 1 0 1 ]
]
}
pcm.spdif_softvol {
type softvol
slave {
pcm "dmix:0,1"
}
control {
name "SPDIF Playback Volume"
card "0"
}
hint {
show on
description "SPDIF"
}
min_dB -60.0
max_dB -20.0
resolution 200
} |
It is a shot in the dark (as is the poorly documented alsa config file in general), but I notice that you have no plug device to do rate/format conversion - IME this is the bear with dmix, it will only work if all streams are the same format and sample rate. |
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Mon Mar 05, 2018 6:06 pm Post subject: |
|
|
That's not going to work unless your cards have a clock sync cable between them, dmix doesn't do drift compensation here like pulse does. |
|
Back to top |
|
|
Langest n00b
Joined: 19 Jan 2018 Posts: 48
|
Posted: Mon Mar 05, 2018 6:46 pm Post subject: Re: [ALSA] play sound on two devices |
|
|
steve_v wrote: | Doesn't work with dmix at all, or doesn't work with your current config?
Can you use dmix when outputting only to the intel card? | No, but works fine on the other card.
Code: | $ speaker-test -D dmix:Schiit -c 2 #Works fine
$ speaker-test -D dmix:Intel -c 2 #Don't work
$ speaker-test -D hw:Intel -c 2 #Works fine |
steve_v wrote: | snd_hda_intel, I assume? | Yes.
steve_v wrote: | Do I read it right that you are trying to make a 4-channel device from 2 2-channel cards? | I think that is the idea that is suggested in the stack overflow thread I read through. Any working solution is fine. The cards I use both are 2-channels.
I tried the proposed solution without any luck.
Ant P. wrote: | That's not going to work unless your cards have a clock sync cable between them, dmix doesn't do drift compensation here like pulse does. | Do you mean there is no possibility for me to mirror the sounds on both cards at once or that the proposed solution will not be able to work? |
|
Back to top |
|
|
steve_v Guru
Joined: 20 Jun 2004 Posts: 388 Location: New Zealand
|
Posted: Wed Mar 07, 2018 4:37 am Post subject: Re: [ALSA] play sound on two devices |
|
|
Langest wrote: | $ speaker-test -D dmix:Intel -c 2 #Don't work | Curious. What if you explicitly define a dmix pcm in your config? |
|
Back to top |
|
|
Langest n00b
Joined: 19 Jan 2018 Posts: 48
|
Posted: Wed Mar 07, 2018 7:32 am Post subject: Re: [ALSA] play sound on two devices |
|
|
steve_v wrote: | Curious. What if you explicitly define a dmix pcm in your config? |
Code: | $ speaker-test -D dmix:Intel -c 2 | Still does not work.
If I don't put anything in my config it works to play sound through the browser and an media player at the same time but speaker-test says that the device is busy when I try to use it in combination with one of the other two.
Code: | $ speaker-test -D hw:Intel -c 2
speaker-test 1.1.2
Playback device is hw:Intel
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Playback open error: -16,Device or resource busy |
Do I need to do anything besides update my conf to test with the explicitly defined "dmixed" pmc? |
|
Back to top |
|
|
steve_v Guru
Joined: 20 Jun 2004 Posts: 388 Location: New Zealand
|
Posted: Wed Mar 07, 2018 8:25 am Post subject: Re: [ALSA] play sound on two devices |
|
|
Langest wrote: | If I don't put anything in my config it works to play sound through the browser and an media player at the same time but speaker-test says that the device is busy when I try to use it in combination with one of the other two. | You have pulseaudio installed? |
|
Back to top |
|
|
Langest n00b
Joined: 19 Jan 2018 Posts: 48
|
Posted: Wed Mar 07, 2018 9:31 am Post subject: Re: [ALSA] play sound on two devices |
|
|
steve_v wrote: | You have pulseaudio installed? | No, I don't have pulseaudio installed. |
|
Back to top |
|
|
steve_v Guru
Joined: 20 Jun 2004 Posts: 388 Location: New Zealand
|
Posted: Wed Mar 07, 2018 9:40 am Post subject: Re: [ALSA] play sound on two devices |
|
|
Langest wrote: | Do I need to do anything besides update my conf to test with the explicitly defined "dmixed" pmc? | Other than try to play something through it (-D dmixed), no. |
|
Back to top |
|
|
Langest n00b
Joined: 19 Jan 2018 Posts: 48
|
Posted: Wed Mar 07, 2018 4:11 pm Post subject: Re: [ALSA] play sound on two devices |
|
|
steve_v wrote: | Other than try to play something through it (-D dmixed), no. | -D dmixed works. And I am able to run multiple instances of it at the same time. This does not work with -D hw:Intel.
Is it perhaps possible to chain this dmixed in the original config I posted to get it to work? |
|
Back to top |
|
|
Langest n00b
Joined: 19 Jan 2018 Posts: 48
|
Posted: Wed Mar 07, 2018 4:13 pm Post subject: |
|
|
I tried changing slaves.a.pcm "hw:Intel" to slaves.a.pcm "dmixed" and it seems to work.
Edit:
One problem unrelated to the original problem that I noticed is that if the Schiit device is not available (my laptop is not docked), it doesn't work since it cannot find one of the devices specified in the config. Is there a way to only use it if it is available?
Edit2:
Code: | $ speaker-test -c 2
speaker-test 1.1.2
Playback device is default
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.1.2/work/alsa-lib-1.1.2/src/confmisc.c:767:(parse_card) cannot find card 'Schiit'
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.1.2/work/alsa-lib-1.1.2/src/conf.c:4371:(_snd_config_evaluate) function snd_func_card_driver returned error: No such device
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.1.2/work/alsa-lib-1.1.2/src/confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.1.2/work/alsa-lib-1.1.2/src/conf.c:4371:(_snd_config_evaluate) function snd_func_concat returned error: No such device
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.1.2/work/alsa-lib-1.1.2/src/confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.1.2/work/alsa-lib-1.1.2/src/conf.c:4371:(_snd_config_evaluate) function snd_func_refer returned error: No such device
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.1.2/work/alsa-lib-1.1.2/src/conf.c:4850:(snd_config_expand) Evaluate error: No such device
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.1.2/work/alsa-lib-1.1.2/src/pcm/pcm.c:2450:(snd_pcm_open_noupdate) Unknown PCM dmix:Schiit
Playback open error: -19,No such device |
|
|
Back to top |
|
|
steve_v Guru
Joined: 20 Jun 2004 Posts: 388 Location: New Zealand
|
Posted: Thu Mar 08, 2018 4:14 am Post subject: |
|
|
Langest wrote: | Is there a way to only use it if it is available? | None that I am aware of via asound.conf, but I guess one could write a udev rule to modify / swap configs. Going to get a bit kludgy though.
Or just let the client application do it, mplayer & ffmpeg allow specifying more than one audio device and will use the first that works. Dunno about others. |
|
Back to top |
|
|
|