At first you should obtain MAC for you bluetooth audio device:
hcitool scan
Obtained address you should replace in scripts and configuration below instead of "XX:XX:XX:XX:XX:XX".
Create the following file in home directory to configure alsa plug in:
~/.asoundrc
pcm.bluetooth {
type bluetooth
device XX:XX:XX:XX:XX:XX
profile "auto"
}
pcm.bluetooth {
type bluetooth
device XX:XX:XX:XX:XX:XX
profile "auto"
}
Then create python scripts. The first script turns on headset profile, the second one turns on A2DP profile for stereo streaming.
Headset proifle (headset.py file):
#!/usr/bin/env python
import dbus
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object('org.bluez', '/org/bluez'), 'org.bluez.Manager')
bus_id = manager.ActivateService('audio')
audio = dbus.Interface(bus.get_object(bus_id, '/org/bluez/audio'), 'org.bluez.audio.Manager')
path = audio.CreateHeadset('XX:XX:XX:XX:XX:XX')
#audio.ChangeDefaultHeadset(path) #change the device to be used by default
headset = dbus.Interface (bus.get_object(bus_id, path), 'org.bluez.audio.Headset')
#Connect and Play are not required in PCM mode
headset.Connect()
headset.Play()
A2DP profile (a2dp.py file):
#!/usr/bin/env python
import dbus
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object('org.bluez', '/org/bluez'), 'org.bluez.Manager')
bus_id = manager.ActivateService('audio')
audio = dbus.Interface(bus.get_object(bus_id, '/org/bluez/audio'), 'org.bluez.audio.Manager')
path = audio.CreateDevice('XX:XX:XX:XX:XX:X')
#audio.ChangeDefaultDevice(path) #change the device to be used by default
sink = dbus.Interface (bus.get_object(bus_id, path), 'org.bluez.audio.Sink')
sink.Connect()
Okay. bluetooth-applet should be run. To turn on A2DP profile you should execute a2dp.py and to turn on Headset profile you should execute headset.py. Now you can test sound via audacious: options->preferences->Audio->Current Output Plugin->ALSA
Output Plugin Preferences->Device Settings->audio device: "bluetooth". In other players you should select "bluetooth" device instead of default or any other. See here how to set bluetooth support to another players.
Another way to set bluetooth support is to install Blueman manager.
URLs:
UPD: Audacous writes to console: ALSA lib pcm_bluetooth.c:238:(playback_hw_thread) poll error: Interrupted system call (4). I don't know what it means...
No comments:
Post a Comment