Forum
Bluetooth disconnects - Printable Version

+- Forum (http://forum.xbian.org)
+-- Forum: Hardware (/forum-7.html)
+--- Forum: Video and Audio (/forum-28.html)
+--- Thread: Bluetooth disconnects (/thread-4165.html)

Pages: 1 2


Bluetooth disconnects - grandcanyon - 8th Feb, 2023 02:40 PM

I am trying to use onboard BT and Wifi on my RPi3+. I am not sure if this is even possible but I believe I had it working in arch. I have a dongle (0a12:0001) but there was a bug with it at one point.

Anyhow, I have tried three different headphones with onboard BT. One works but when it stops getting any sound from Kodi for 30 seconds it disconnects. The other two I don't get any sound and I have to reboot. I don't see why one headphone would work different then the others.

I used bluetoothctl to pair, connect, trust each headphone. Pulseaudio is running when I connect the headphones. The headphones will connect automatically when turned on.

I added this but I'm not sure if it is needed.

/etc/pulse/default.pa
### Automatically switch to newly-connected devices
load-module module-switch-on-connect

Any pointers?


RE: Bluetooth disconnects - grandcanyon - 9th Feb, 2023 09:27 AM

I was able to get the dongle to work. I had a hard time getting the headphones to connect as I kept getting the HP are unavailable. I deleted the /var/lib/bluetooth directory and then restarted bluetooth and it connected but I couldn't get them trusted. I did this process a couple of times until it worked. I have to connect and then disconnect and then reconnect on reboot in order for Kodi to pipe the sound through the BT HP but they do stay connected.


RE: Bluetooth disconnects - grandcanyon - 9th Feb, 2023 02:04 PM

The dongle also drops the headphones except it takes a minute and a half instead of a 10 seconds of inactivity. If I keep Kodi in ALSA mode, the headphones stay connected once I run them through Kodi they will disconnect. The only thing in the Kodi log file is

Found BT Device - will adjust buffers to larger values

I turned on full debug logs and it says:

CLibInputHandler::DeviceRemoved - keyboard type device removed: Power Q20 Pro (AVRCP) (event1)

I don't have a syslog file so I am no sure where to look.

No comprehendo lol


RE: Bluetooth disconnects - Nachteule - 10th Feb, 2023 12:39 AM

OMG Confused

Haven't you long suspected that something is generally wrong with your system?
The various strange errors you report, that is really not normal

Have you used a different power supply in the meantime?

Kodi has nothing to do with Bluetooth, the message you see in the Kodi log comes from the Pulseaudio sink module.

When I use bluetooth, I always use the onboard module, I don't have an external dongle at all

If you want to see something in the syslog, you have to install a logger daemon additionally. I have rsyslog in use, because I log everything on a central logserver.


RE: Bluetooth disconnects - grandcanyon - 10th Feb, 2023 04:34 AM

I installed rsyslog. If it was a power supply, I would seem to think that the BT HP would disconnect all the time like during playback. Also, if I connect the HPs when the audio output is set to PI:HDMI they don't disconnect. Not sure why the disconnect only when Kodi is set to pulseaudio and the headphones are connected.[/code]

Code:
Feb  9 12:20:19 xbian kernel: [  799.801796] input: Power Q20 Pro (AVRCP) as /devices/virtual/input/input8
Feb  9 12:20:24 xbian bluetoothd[2525]: /org/bluez/hci0/dev_FF_51_08_3C_83_CE/fd7: fd(27) ready
Feb  9 12:20:58 xbian bluetoothd[2525]: Endpoint unregistered: sender=:1.312 path=/MediaEndpoint/A2DPSink/sbc
Feb  9 12:20:58 xbian bluetoothd[2525]: Endpoint unregistered: sender=:1.312 path=/MediaEndpoint/A2DPSource/sbc
Feb  9 12:21:07 xbian ntpd[3150]: 185.144.161.170 local addr 10.10.6.10 -> <null>
Feb  9 12:23:10 xbian pulseaudio[5508]: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Feb  9 12:23:10 xbian pulseaudio[5508]: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Feb  9 12:23:10 xbian bluetoothd[2525]: Endpoint registered: sender=:1.339 path=/MediaEndpoint/A2DPSink/sbc
Feb  9 12:23:10 xbian bluetoothd[2525]: Endpoint registered: sender=:1.339 path=/MediaEndpoint/A2DPSource/sbc
Feb  9 12:23:10 xbian bluetoothd[2525]: src/profile.c:ext_start_servers() RFCOMM server failed for Headset Voice gateway: rfcomm_bind: Address already in use (98)
Feb  9 12:23:10 xbian bluetoothd[2525]: src/profile.c:ext_start_servers() RFCOMM server failed for Headset unit: rfcomm_bind: Address already in use (98)



RE: Bluetooth disconnects - Nachteule - 10th Feb, 2023 06:49 AM

My first thought here was that this might have something to do with BT autosuspend. Two different BT adapters -> two different times until the connection is cut

I found this for example

https://bugzilla.redhat.com/show_bug.cgi?id=1589548

BTW, I also have a bt keyboard that goes offline and then the whole BT stack goes crazy. since I don't really need this keyboard, it's been lying around for years without me having dealt with this problem any further.

Maybe you have a similar problem.


RE: Bluetooth disconnects - grandcanyon - 10th Feb, 2023 10:21 AM

Thanks per the links, I looked at the bus and for the BT dongle the power control was set to on. I went ahead and wrote a udev but this didn't help. I also edited the command line and added btusb.enable_autosuspend=0 and this didn't fix the issue either. I disabled CEC as I was starting to think CEC was sending a signal to disconnect the BT dvice. Didn't fix it.

These are set to auto. I edited the files and changed them to on but it didn't help. I tried with and without restarting bluetooth.

./1-1/1-1.1/1-1.1.3/1-1.1.3:1.0/bluetooth/hci0/power/control
./1-1/1-1.1/1-1.1.3/1-1.1.3:1.0/bluetooth/hci0/rfkill1/power/control

I have tried three different headphones. Only set of HPs get passed sound. The other two don't get any sound but I can use the controls to pause and start video. These two do not disconnect. I set up the default.pa to switch to BT HPs when present.


RE: Bluetooth disconnects - grandcanyon - 10th Feb, 2023 01:36 PM

The problem is that it creates two instance of pulseaudio. The first one won't pipe through kodi so when I go to PI:HDMI and back to Pulse it creates a second socket with a new PID that works through Kodi but it crashes when idle and naturally this disconnects my headphones.


RE: Bluetooth disconnects - grandcanyon - 10th Feb, 2023 03:29 PM

I'm guessing I have to wait for something else to start (pulse or bluetooth) before kodi starts?


RE: Bluetooth disconnects - Nachteule - 10th Feb, 2023 10:13 PM

Honestly: you confuse me more and more, this all sounds extremely strange

How do you start Pulseaudio?

Kodi only initializes Pulseaudio at startup and then never again. do you have any addon installed that is going crazy? You mentioned once in the Kodi forum the Audio Profiles addon ...


RE: Bluetooth disconnects - Nachteule - 10th Feb, 2023 10:14 PM

(10th Feb, 2023 01:36 PM)grandcanyon Wrote:  The problem is that it creates two instance of pulseaudio. The first one won't pipe through kodi so when I go to PI:HDMI and back to Pulse it creates a second socket with a new PID that works through Kodi but it crashes when idle and naturally this disconnects my headphones.

How nice that you mention such important things once in a while


RE: Bluetooth disconnects - grandcanyon - 11th Feb, 2023 02:25 AM

(10th Feb, 2023 10:13 PM)Nachteule Wrote:  Honestly: you confuse me more and more, this all sounds extremely strange

How do you start Pulseaudio?

Kodi only initializes Pulseaudio at startup and then never again. do you have any addon installed that is going crazy? You mentioned once in the Kodi forum the Audio Profiles addon ...

It starts on boot. I don't know how it starts as I didn't write the code to start it as I'm sure someone wrote an upstart to start pulse which looks like it is in the xbmc.conf

The Audio Profiles switches between PI: HDMI and Pulse like you would through the menus. I don't have any other weird addons unless Youtube is weird.

(10th Feb, 2023 10:14 PM)Nachteule Wrote:  
(10th Feb, 2023 01:36 PM)grandcanyon Wrote:  The problem is that it creates two instance of pulseaudio. The first one won't pipe through kodi so when I go to PI:HDMI and back to Pulse it creates a second socket with a new PID that works through Kodi but it crashes when idle and naturally this disconnects my headphones.

How nice that you mention such important things once in a while

Well yeah. If I would have seen that up front, I would have mentioned it. It would have saved me countless reboots and writing udev rules.


RE: Bluetooth disconnects - Nachteule - 12th Feb, 2023 04:40 AM

Not that I don't believe you, but I have now tested once with the Audio Profiles. After I finally understood how to handle this, I tested the following configuration back and forth:

Profile 1: switches to PI:HDMI and is automatically activated when I watch a PVR Livestream
Profile 3: switches to the analog output of the Raspberry Pi via Pulseaudio and is activated on GUI
Profile 4: switches automatically to my Hifiberry AMP via Pulseaudio for videos that are not in the database

All this works fine as far as I can tell, there is only one Pulseaudio instance running, nothing stutters and the sound is flawless.
And this on a slower Pi3 (not the + variant) where the root filesystem is on the network, which from the theory is slower than an sd card
In the next few days, maybe tomorrow, I still connect my bluetooth speaker and see how it behaves with that

Currently running Kodi 21 Alpha and 5.4.150 kernel, as this kernel is the last one that allows smooth playback of HEVC videos.

So the first thing to do is to find out why 2 pulseaudio instances are started on your system


RE: Bluetooth disconnects - grandcanyon - 17th Feb, 2023 07:18 PM

The problem is that bluetooth creates a new pulseaudio socket every time it connects since I am seeing a

rfcomm_bind: Address already in use

so bluetooth won't bind to the existing pulseaudio socket


RE: Bluetooth disconnects - Nachteule - 18th Feb, 2023 05:28 AM

(17th Feb, 2023 07:18 PM)grandcanyon Wrote:  The problem is that bluetooth creates a new pulseaudio socket every time it connects since I am seeing a

rfcomm_bind: Address already in use

so bluetooth won't bind to the existing pulseaudio socket

I have the feeling you have completely screwed up your pulseaudio/bluetooth by now

My recommendation: remove everything that has to do with pulseaudio (apt-get purge ...) and start again from scratch
Make sure that the directory /home/xbian/.config/pulse and /etc/pulse do not exist anymore before you reinstall the packages

After reinstall, run the following script as root:
Code:
#!/bin/sh
su xbian -c "mkdir -p -m 0700 /home/xbian/.config/pulse && sed 's/; autospawn = yes/autospawn = yes/g' /etc/pulse/client.conf > /home/xbian/.config/pulse/client.conf
su xbian -c "mkdir -p -m 0700 /home/xbian/.config/pulse && cp /etc/pulse/daemon.conf /home/xbian/.config/pulse"
echo -e "If you need to modify client.conf or daemon.conf, please use\nthe files in folder /home/xbian/.config/pulse" > /etc/pulse/README.XBian
find /etc/rc?.d/ -name S??pulseaudio-enable-autospawn -delete

This will copy daemon.conf and client.conf to the xbian user area and changes have to be made there. Making changes in the orginal conf files I don't think is a very good idea