3

On my laptop, I have an onboard sound card, and also a connected bluetooth headset. I have configured the bluetooth device in /etc/asound.conf:

# cat /etc/asound.conf

pcm.bluetooth {
    type bluetooth
    device 12:34:56:78:9a:bc
    profile "auto"
}

ctl.bluetooth {
    type bluetooth
}

Now I can play audio to my headset by specifying the new audio device, such as:

mplayer -ao alsa:device=bluetooth file.mp3

If I want to play to my default device, I simply omit the device:

mplayer file.mp3

However, I need to configure ALSA, so that all sound is sent to both devices by default, without having to explicitly set this per application.

ie:

mplayer file.mp3

should play both on the laptop soundcard, as well as in the bluetooth headset.

How can I do that ?

  • Do you exclusively need to do that for some scripts or something, I mean like calling mplayer from bash, like in your examples? or is it something you need to transparently happen the entire time you listen to audio? – forgotstackxpassword Jul 4 '16 at 20:57
  • @forgotstackxpassword - I need this globally, system-wide. Not for specific application. – Martin Vegter Jul 5 '16 at 7:40
2

Here's one way to do it from ~/.asoundrc ; example shows an on-board and soundblaster live card united under the default PCM.

# duplicate audio to both devices
pcm.!default plug:both

ctl.!default {
  type hw
  card SB
}

pcm.both {
  type route;
  slave.pcm {
      type multi;
      slaves.a.pcm "sblive";
      slaves.b.pcm "onboard";
      slaves.a.channels 2;
      slaves.b.channels 4;
      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;
      bindings.4.slave b;
      bindings.4.channel 2;
      bindings.5.slave b;
      bindings.5.channel 3;
  }

  ttable.0.0 1;
  ttable.1.1 1;

  ttable.0.2 1; # front left
  ttable.1.3 1; # front right
  ttable.0.4 1; # copy front left to rear left
  ttable.1.5 1; # copy front right to rear right
}

ctl.both {
  type hw;
  card Live;
}

pcm.onboard {
   type dmix
   ipc_key 1024
   slave {
       pcm "hw:0,1"
       period_time 0
       period_size 2048
       buffer_size 65536
       buffer_time 0
       periods 128
       rate 48000
       channels 4
    }
    bindings {
       0 0
       1 1
       2 2
       3 3
    }
}

pcm.sblive {
   type dmix
   ipc_key 2048
   slave {
       pcm "hw:1,0"
       period_time 0
       period_size 2048
       buffer_size 65536
       buffer_time 0
       periods 128
       rate 48000
       channels 2
    }
    bindings {
       0 0
       1 1
    }
}

ctl.onboard {
   type hw
   card "SB"
}

ctl.sblive {
   type hw
   card "Live"
}

(Source)

2
+50

You want to use the multi-plugin.

Several well documented examples of its use exist:

From the alsa people: https://alsa.opensrc.org/TwoCardsAsOne

From somebody with a similar question here: https://unix.stackexchange.com/a/194631/127903

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.