[alsa-devel] Help! Need to switch between normal speaker and BT headset dynamically
Hi,
I am trying to switch the ALSA audio output between default speaker and BT(BlueTooth) headset.
For this, I have used the bluez stack for the BT headset scanning and detection. After this, I have updated the .asoundrc file with the corresponding details(like MAC address of the detected BT headset and the device type as "pcm.bluetooth"). And finally, I used the aplay utility to play the file.
This approach works fine but this needs restart of the playback session to start routing on the BT headset. I am trying for a solution(application/plugin) that can dynamically set the BT headset as the default audio output device and start streaming to it automatically as soon as the BT headset is detected in the middle of audio playback.
Is this possible to do and if yes, is there an ALSA application/plugin already available for this?
Thanks, Pradeep
On Sun, Apr 4, 2010 at 11:50 AM, Pradeep Kumar Jilagam pradeep.jilagam@gmail.com wrote:
Is this possible to do and if yes, is there an ALSA application/plugin already available for this?
e.g., PulseAudio?
Hi Daniel,
Thanks for your response.
I am trying to get this working on a small embedded system with limited memory and processing capabilities. I have also explored in the direction of pulseaudio but I am not sure whether it is small enough to fit into a small system. Aslo, I I came to know that the default output device will again have to be manually changed in the GUI menu fo pulseaudio to start streaming on the BT headset after updating asoundrc with its MAC address.
I am trying to find out whether the streaming can automatically start routing to the BT headset as soon as it is detected without any need for user's intervention. I am trying to find out whether it is possible to do so and also whether there is any plugin/application available for it.
Thanks, Pradeep On Mon, Apr 5, 2010 at 1:06 AM, Daniel Chen seven.steps@gmail.com wrote:
On Sun, Apr 4, 2010 at 11:50 AM, Pradeep Kumar Jilagam pradeep.jilagam@gmail.com wrote:
Is this possible to do and if yes, is there an ALSA application/plugin already available for this?
e.g., PulseAudio?
'Twas brillig, and Pradeep Kumar Jilagam at 06/04/10 06:06 did gyre and gimble:
Hi Daniel,
Thanks for your response.
I am trying to get this working on a small embedded system with limited memory and processing capabilities. I have also explored in the direction of pulseaudio but I am not sure whether it is small enough to fit into a small system.
Most of the linux-based embedded and mobile phone manufacturers are using PA these days (certainly Palm, Nokia and Intel), so I don't see a major headache here. There are specific optimisations for ARM in the PA codebase too.
Aslo, I I came to know that the default output device will again
have to be manually changed in the GUI menu fo pulseaudio to start streaming on the BT headset after updating asoundrc with its MAC address.
Using the ALSA bluetooth support is likely not going to work too well. PA has direct bluetooth support these days. All the upstream (bluez) effort regarding audio on linux is via PA. PA will automatically discover BT devices and once they are paired, they will appear automatically as sinks/sources in PA.
You can use various command line tools to change the device of a running stream. You can also write a program and use the libpulse capabilities to programatically move the streams.
I am trying to find out whether the streaming can automatically start routing to the BT headset as soon as it is detected without any need for user's intervention.
In theory yes, but in practice this is actually quite hard with the current PA routing logic. I personally have some issues with it and want to change things to make this use case easier.
Currently if all audio streams are tagged as "media.role=phone" then they *will* be routed to a bluetooth device automatically if one is present. So that's probably the cleanest approach.
HTHs
Col
participants (3)
-
Colin Guthrie
-
Daniel Chen
-
Pradeep Kumar Jilagam