TristonL
TristonL

Reputation: 21

ALSA: Playing and Outputting to multiple Bluetooth Devices simultaneously?

How do I configure ALSA's asoundrc file to input and output audio data to two Bluetooth devices? I have tried using the dmix and dsnoop plugins to go about doing this similar to what is shown in the following post: ALSA Api: How to play two wave files simultaneously?. And have looked at the following sources: https://www.alsa-project.org/main/index.php/Asoundrc#Software_mixing, and https://github.com/Arkq/bluez-alsa/wiki/Using-the-bluealsa-ALSA-pcm-plugin. All I want to do is use the arecord and aplay commands to output to these two Bluetooth devices. Any suggestions would truly be appreciated.

When I ran: aplay -D mix_stream /home/pi/Desktop/noise.wav

Error: ALSA lib pcm_direct.c:1809:(_snd_pcm_direct_get_slave_ipc_offset) Invalid type 'bluealsa' for slave PCM

aplay: main:828: audio open error: Invalid argument

Edit: I learned that dmix and dsnoop only work with hardware devices so I'm using the multi plugin instead. However, I'm still experiencing issues with the following command: arecord -D bth-multi -c 2 -r 44100 -f s16_le test.wav. It outputs the following error: ALSA lib bluealsa-pcm.c:763:(_snd_pcm_bluealsa_open) Couldn't get BlueALSA PCM: PCM not found arecord: main:828: audio open error: No such device.

Here is my current asoundrc file which I referenced off of @Arkq on the bluez-alsa github page. Here is the offical link: https://github.com/Arkq/bluez-alsa/issues/379#issuecomment-707309026

pcm.bth-1 {
    type plug
    slave.pcm {
        type bluealsa
        device "FA:D8:78:FB:57:36"
        profile "a2dp"
    }
}

pcm.bth-2 {
    type plug
    slave.pcm {
        type bluealsa
        device "5C:44:3E:54:E0:01"
        profile "a2dp"
    }
}

pcm.bth-multi {
   type plug;
   slave.pcm {
       type multi;
       slaves.a.pcm "bth-1";
       slaves.a.channels 2;
       slaves.b.pcm "bth-2";
       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; }
       master 1
   }
   ttable.0.0 1
   ttable.1.1 1
   ttable.0.2 1
   ttable.1.3 1
}

Upvotes: 1

Views: 2353

Answers (1)

fildaw
fildaw

Reputation: 11

I think that you missed closing brace (}) of slave.pcm block in pcm.y30. It should look like this:

pcm.y30 {
    type plug
    slave.pcm {
        type bluealsa
        device "FA:D8:78:FB:57:36"
        profile "a2dp"
    }
}

Upvotes: 0

Related Questions