Pulseaudio is not spawned(automatically) when connecting to bluetooth audio device in rpi 3b+
I am trying to include bluetooth and pulseaudio module in yocto build that will run on rpi-3 b+.
/etc/pulse/default.pa contains:
module-bluetooth-policy
module-bluez5-device
module-bluez5-discover
Here is what I am able to achieve:
Run:
pulseaudio --system
pulseaudio --start
In bluetoothctl:
power on
default-agent
pair 30:C0:1B:31:ED:5D
{pair successful}
connect 30:C0:1B:31:ED:5D
{connection is successful}
If I DONT run pulseaudio --system && pulseaudio --start; In bluetoothctl, pair is succesful but connect failed with error:
connect 30:C0:1B:31:ED:5D
Attempting to connect to 30:C0:1B:31:ED:5D
Failed to connect: org.bluez.Error.Failed
/var/log/message:
a2dp-sink profile connect failed for 30:C0:1B:31:ED:5D: Protocol not available
According to "https://wiki.archlinux.org/index.php/Bluetooth_headset" :
"It can also be due to permission, especially if starting pulseaudio as root allows you to connect. Add your user to the lp group, then restart pulseaudio. See /etc/dbus-1/system.d/bluetooth.conf for reference."
Further steps:
a. Added root and pulse to "lp" group : Connect failed again with same error
b. Ran command: pactl load-module module-bluetooth-discover: The device connected and disconnected after few seconds. journalct l:
pulseaudio[1837]: We are idle, quitting...
systemd-journald[92]: Forwarding to syslog missed 1064 messages.
pulseaudio[1837]: Daemon shutdown initiated.
c. set exit-idle-time = -1 in /etc/pulse/daemon.conf
d. Ran command: pactl load-module module-bluetooth-discover.
In bluetoothctl:
connect 30:C0:1B:31:ED:5D
Attempting to connect to 30:C0:1B:31:ED:5D
Device 30:C0:1B:31:ED:5D Connected: yes
Connection successful
Device 30:C0:1B:31:ED:5D ServicesResolved: yes
Connection was successful and no disconnects.
Is there anyway I can avoid running manual commands (pulseaudio --system, pulseaudio --start, pactl load-module module-bluetooth-discover)to invoke pulseaudio? Since everything runs in root, it there any mismatch of user/group between pulsaudio and bluetooth?