2 years ago

#69747

test-img

vinalti

Gstreamer, alsa, bluealsa: bluetooth audio not working in 2 ways audio stream

Context

So I have 2 Gstreamer pipelines, one to send audio up (PC to Pi) to a Raspberry Pi, and another to send audio down (Pi to PC).

The audio down is getting sound from a USB mic and the audio up is outputting sound to a Bluetooth speaker.

The libraries uses are Alsa with Bluez.

Problem

Here is where it gets complicated:

  • [✓] The audio up alone, is working
  • [✓] The audio down alone is working

But:

  • [✗] If the audio down is simultaneous, the audio up is not working

    Somehow, Bluetooth audio-out is not working when listening at the same time to a capture device.

However:

  • [✓] If the audio up is outputting to a non-Bluetooth device (e.g with the jack connector) it is working fine, even simultaneously with audio down.

In other words: the output the the Bluetooth device is working, only if I am not listening to a capture device simultaneously, while if the output device is not Bluetooth, it is working no matter what.

"Not working" means that the audio cannot be heard on the speaker.

Question

How can I get the Bluetooth device to work with GStreamer even when a capture device is listening ?

Code

Audio Down

Send audio down

 import gi
 gi.require_version('Gst', '1.0')

 # gst-launch-1.0
 cmd  =  ' alsasrc device=hw:1,0 ! audio/x-raw ! queue '
 cmd +=  '  ! audioresample ! audioconvert ! avenc_ac3 ! queue '
 cmd += f'  ! rtpac3pay ! udpsink host={ip} port={port} '

Audio Up

Receive audio and output to bluetooth speaker

 # gst-launch-1.0
 cmd =  f'udpsrc port={port} ! decodebin ! audioresample ! audioconvert '
 cmd += f' ! alsasink device=bluealsa:DEV={MAC_ADDRESS} '

Receive audio and output to normal speaker (e.g. jack or USB)

 # gst-launch-1.0
 cmd =  f'udpsrc port={port} ! decodebin ! audioresample ! audioconvert '
 cmd +=  ' ! alsasink device=hw:2,0 '

Notes

I am using the python library for Gstreamer.

audio

bluetooth

raspberry-pi

gstreamer

alsa

0 Answers

Your Answer

Accepted video resources