668b2f3cfbdafdb3bd17ec7b569404edbc628820
[AGL/documentation.git] / docs / 4_APIs_and_Services / 4.6_Audio_Framework / 4.6.3_Bluetooth.md
1 ---
2 edit_link: ''
3 title: Bluetooth
4 origin_url: >-
5   https://raw.githubusercontent.com/automotive-grade-linux/docs-sources/master/docs/audio/bluez-alsa.md
6 ---
7
8 <!-- WARNING: This file is generated by fetch_docs.js using /home/boron/Documents/AGL/docs-webtemplate/site/_data/tocs/apis_services/master/audio-developer-guides-audio-book.yml -->
9
10 # bluez-alsa
11
12 ## Introduction
13
14 Bluetooth Audio ALSA Backend allow bluetooth audio without PulseAudio.
15
16 This project is a rebirth of a direct integration between Bluez and ALSA. Since Bluez >= 5, the build-in integration has been removed in favor of 3rd party audio applications. From now on, Bluez acts as a middleware between an audio application, which implements Bluetooth audio profile, and a Bluetooth audio device.
17
18 github source : [bluez-alsa](https://github.com/Arkq/bluez-alsa)
19
20 ## Add bluez-alsa to an AGL image
21
22 You can add bluez-alsa to your image
23
24 ```yocto
25 IMAGE_INSTALL_append = "bluez-alsa"
26 ```
27
28 ## Check bluez-alsa status
29
30 You can check the bluez-alsa status by running:
31
32 ```bash
33 systemctl status bluez-alsa.service
34 ```
35
36 ## Stop pulseaudio
37
38 You must disable pulseaudio if you want to use bluez-alsa
39
40 ```bash
41 systemctl --user stop pulseaudio
42 ```
43
44 or disable pulseaudio bluetooth support
45
46 ```bash
47 vi /etc/pulse/default.pa
48 #.ifexists module-bluetooth-policy.so
49 #load-module module-bluetooth-policy
50 #.endif
51
52 #.ifexists module-bluetooth-discover.so
53 #load-module module-bluetooth-discover
54 #.endif
55 ```
56
57 ## Connect your Bluetooth device
58
59 You need to connect a bluetooth device
60
61 ```bash
62 $ bluetoothctl
63 [bluetooth]# pair ${BT_ADDR}
64 [bluetooth]# connect ${BT_ADDR}
65 [bluetooth]# info ${BT_ADDR}
66 ```
67
68 Here somes documentation links:
69
70 * [Bluetooth headset from archlinux](https://wiki.archlinux.org/index.php/Bluetooth_headset)
71 * [Bluetooth Headset from gentoo](https://wiki.gentoo.org/wiki/Bluetooth_Headset)
72 * [Bluez A2DP AudioSink for ALSA](http://www.lightofdawn.org/blog/?viewDetailed=00032)
73 * [Bluez A2DP](http://www.lightofdawn.org/wiki/wiki.cgi/BluezA2DP)
74
75 ## Test bluez-alsa speacker
76
77 ```bash
78 wget http://www.kozco.com/tech/piano2.wav
79
80 aplay -D bluealsa:HCI=hci0,DEV=${BT_ADDR},PROFILE=a2dp ./piano2.wav
81 ```
82
83 ## Add bluez-alsa pcm config to alsa
84
85 ```bash
86 vi /etc/asound.conf
87 # Bluetooth headset
88 pcm.btheadset {
89         type plug
90         slave.pcm {
91                 type bluealsa
92                 device "${BT_ADDR}"
93                 profile "a2dp"
94         }
95         hint {
96                 show on
97                 description "Bluetooth Audio ALSA Backend"
98         }
99 }
100 ```
101
102 Doc [asoundrc](https://alsa.opensrc.org/Asoundrc)
103
104 Test bluez-alsa pcm
105
106 ```bash
107 aplay -D btheadset ./piano2.wav
108 ```
109
110 ## Test gstreamer player
111
112 ```bash
113 gst-launch-1.0 uridecodebin uri=file:///mnt/Holy-Mountain.mp3  ! alsasink device=btheadset
114 ```
115
116 ## Test bluez-alsa phone
117
118 After connected your phone with bluez:
119
120 ```bash
121 bluealsa-aplay ${BT_ADDR}
122 ```