You are not logged in.

#1 2012-11-11 04:09:42

brenix
Member
From: California
Registered: 2008-03-05
Posts: 182

ALSA output to multiple cards

Hi All,

I've been trying to get audio to output to both my internal sound card and wireless usb headset at the same time. The reason I am trying to do this is because I switch between the two very often and each time I do I have to set the default in /etc/asound.conf. It would be nice to have it output to both so then I would just have to turn the volume down on either when I don't want to use one.

I've read a few articles online about this, but I am still running into issues.. A couple examples are:
http://www.6by9.net/b/2011/12/07/output … -with-alsa
http://slack4dummies.blogspot.com/2012/ … sound.html

I've created a /etc/asound.conf based on these articles, but every time I test it with aplay, I get the following:

$ aplay /usr/share/sounds/alsa/Front_Center.wav 
Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
ALSA lib pcm_params.c:2162:(snd1_pcm_hw_refine_slave) Slave PCM not usable
aplay: set_params:1073: Broken configuration for this PCM: no configurations available

I can run aplay on each device like so: aplay -D plughw:0,0 /usr/share/sounds/alsa/Front_Center.wav
..But not like so: aplay -D hw:0,0 /usr/share/sounds/alsa/Front_Center.wav

aplay -l:

# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: SB [HDA ATI SB], device 0: ALC889 Analog [ALC889 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: SB [HDA ATI SB], device 1: ALC889 Digital [ALC889 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Audio [Wireless Audio], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

aplay -L:

# aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
pulse
    PulseAudio Sound Server
sysdefault:CARD=SB
    HDA ATI SB, ALC889 Analog
    Default Audio Device
front:CARD=SB,DEV=0
    HDA ATI SB, ALC889 Analog
    Front speakers
surround40:CARD=SB,DEV=0
    HDA ATI SB, ALC889 Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=SB,DEV=0
    HDA ATI SB, ALC889 Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=SB,DEV=0
    HDA ATI SB, ALC889 Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=SB,DEV=0
    HDA ATI SB, ALC889 Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=SB,DEV=0
    HDA ATI SB, ALC889 Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=SB,DEV=0
    HDA ATI SB, ALC889 Digital
    IEC958 (S/PDIF) Digital Audio Output
sysdefault:CARD=Audio
    Wireless Audio, USB Audio
    Default Audio Device
front:CARD=Audio,DEV=0
    Wireless Audio, USB Audio
    Front speakers
surround40:CARD=Audio,DEV=0
    Wireless Audio, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Audio,DEV=0
    Wireless Audio, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Audio,DEV=0
    Wireless Audio, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Audio,DEV=0
    Wireless Audio, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Audio,DEV=0
    Wireless Audio, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Audio,DEV=0
    Wireless Audio, USB Audio
    IEC958 (S/PDIF) Digital Audio Output

/etc/asound.conf

# cat /etc/asound.conf
pcm.internal {
    type hw
    card SB
}

ctl.internal {
    type hw
    card SB
}

pcm.wireless {
    type hw
    card Audio
}

ctl.wireless {
    type hw
    card Audio
}

pcm.internalDmixed {
   type dmix
   ipc_key 1024
   ipc_key_add_uid false
   ipc_perm 0666
   slave {
       pcm "internal"
       channels 2
       period_time 0
       period_size 2048
    }
    bindings {
       0 0
       1 1
    }
}

pcm.wirelessDmixed {
   type dmix
   ipc_key 2048
   ipc_key_add_uid false
   ipc_perm 0666
   slave {
       pcm "wireless"
       channels 2
       period_time 0
       period_size 2048
    }
    bindings {
       0 0
       1 1
    }
}

pcm.both {
    type route;
    slave.pcm {
        type multi;
        slaves.a.pcm "wirelessDmixed";
        slaves.b.pcm "internalDmixed";
        slaves.a.channels 2;
        slaves.b.channels 2;
        bindings.0.slave a;
        bindings.0.channel 0;
        bindings.1.slave a;
        bindings.1.channel 1;
       
        bindings.2.slave b;
        bindings.2.channel 0;
        bindings.3.slave b;
        bindings.3.channel 1;
    }
   
    ttable.0.0 1;
    ttable.1.1 1;
   
    ttable.0.2 1; 
    ttable.1.3 1; 
}

pcm.!default {
        type plug
        slave {
                pcm both
        }
}

ctl.!default {
        type hw
        card SB
}

Any help is appreciated..

Offline

#2 2012-11-11 04:17:29

brebs
Member
Registered: 2007-04-03
Posts: 3,425

Re: ALSA output to multiple cards

The "plug:" issue is easily solved, e.g.:

pcm.!surround20 {
    type plug
    slave.pcm "yournewpcmname"
}

Offline

#3 2012-11-11 04:34:58

brenix
Member
From: California
Registered: 2008-03-05
Posts: 182

Re: ALSA output to multiple cards

Interestingly enough, I finally got it working! I took out almost everything (removing the dmix stuff) and changed the slaves.a.pcm and slaves.b.pcm to plughw:0,0 or plughw:1,0 and its working..

Here is what I have now that works:

pcm.both {
    type route;
    slave.pcm {
        type multi;
        slaves.a.pcm "plughw:0,0"
        slaves.b.pcm "plughw:1,0"
        slaves.a.channels 2;
        slaves.b.channels 2;
        bindings.0.slave a;
        bindings.0.channel 0;
        bindings.1.slave a;
        bindings.1.channel 1;
    
        bindings.2.slave b;
        bindings.2.channel 0;
        bindings.3.slave b;
        bindings.3.channel 1;
    }   
   
    ttable.0.0 1;
    ttable.1.1 1;
   
    ttable.0.2 1;  
    ttable.1.3 1;  
}

pcm.!default {
        type plug
        slave.pcm "both"
}

ctl.!default {
        type hw
        card SB
}

Offline

#4 2012-11-11 04:47:43

brenix
Member
From: California
Registered: 2008-03-05
Posts: 182

Re: ALSA output to multiple cards

Ok... well... It looks like I need dmix cause I get device or resouce busy... But if I use plughw on the dmix section, I get this error:

ALSA lib pcm_dmix.c:1023:(snd_pcm_dmix_open) dmix plugin can be only connected to hw plugin

Any workaround for this?

Offline

#5 2012-11-12 10:02:23

brebs
Member
Registered: 2007-04-03
Posts: 3,425

Re: ALSA output to multiple cards

Have you seen Gentoo thread.

Offline

#6 2012-11-12 13:46:48

brenix
Member
From: California
Registered: 2008-03-05
Posts: 182

Re: ALSA output to multiple cards

Yeah... I actually had tried that one too. I really like the way it was more structured, but even after trying that I get the same original error:

ALSA lib pcm_params.c:2162:(snd1_pcm_hw_refine_slave) Slave PCM not usable
aplay: set_params:1073: Broken configuration for this PCM: no configurations available

Offline

#7 2012-11-12 21:27:56

Beemer
Member
Registered: 2012-05-02
Posts: 13

Re: ALSA output to multiple cards

I had the same issue switching between various sound devices with Alsa.  I came up with a perl script that I bind to a key combo to round-robin through my sound outputs.

http://bbs.archbang.org/viewtopic.php?id=3107

Offline

Board footer

Powered by FluxBB