Problem: Bluetooth Audio output (Transmitter)
|
1st Jun, 2021, 03:20 AM
Post: #61
|
|||
|
|||
RE: Bluetooth Audio output (Transmitter)
Ah, now we are getting closer
You are missing the link from /dev/serial1 -> /dev/ttyAM0, which is made by an udev rule, namely by the rule /etc/udev/rules.d/99-com.rules It is present on all my systems (they all based on stone old XBian installations), but strangely not associated with any package. I can only imagine that this file has fallen under the table by mistake at some point. And with the rework of /etc/init/rpi-bluetooth.conf from 12 days ago it stupidly refers to this link again Must now consider how this can be solved sensibly As a workaround to get further you can create the file manually as /etc/udev/rules.d/99-com.rules: Code: SUBSYSTEM=="input", GROUP="input", MODE="0660" |
|||
1st Jun, 2021, 03:38 AM
Post: #62
|
|||
|
|||
RE: Bluetooth Audio output (Transmitter)
About the delayed start of Kodi:
Please have a look at the file /etc/default/xbmc, parameter WAITFOR= Here you can specify which services must be running before Kodi is started So the entry WAITFOR="bluetoothd" might help in your case |
|||
1st Jun, 2021, 07:41 PM
Post: #63
|
|||
|
|||
RE: Bluetooth Audio output (Transmitter)
(1st Jun, 2021 03:20 AM)Nachteule Wrote: As a workaround to get further you can create the file manually as /etc/udev/rules.d/99-com.rules... You were right: I've manually created /etc/udev/rules.d/99-com.rules file and restored the original /etc/init/bluetooth.conf script (with the new one it was not working, but I don't know why...) and now I can get BT connection using 5.4.122, so currently I have the same behaviour with 5.4.114 and 5.4.122, and I can use my BT headphones with Kodi in both cases. Should you need it, here's the current logging from /var/log/upstart/rpi-bluetooth.log file running 5.4.122 (and it looks much better, doesn't it?): Code: using /dev/serial1@460800 Later on, I'll do a few more testing using the WAITFOR parameter in xbmc defaults and let you know. Many thanks for now! |
|||
1st Jun, 2021, 09:05 PM
Post: #64
|
|||
|
|||
RE: Bluetooth Audio output (Transmitter)
Yes indeed, looks better
But I am irritated that the speed is only set to 460800 bit/s. on my 3B and 4B it is 3000000 Maybe you changed something in the /boot/config.txt? Here is the code-snipped from /etc/init/rpi-bluetooth.conf that sets the speed Code: uart0="`cat /proc/device-tree/aliases/uart0`" |
|||
1st Jun, 2021, 11:36 PM
Post: #65
|
|||
|
|||
RE: Bluetooth Audio output (Transmitter)
(1st Jun, 2021 09:05 PM)Nachteule Wrote: Maybe you changed something in the /boot/config.txt? I did many tests and tried some changes on /boot/config.txt to have my BT HPs working, so it could be, but no change that now I'm aware of (every time I restored the default values if the BT issue was still present...). Anyway, from the snippet you sent, it seems in my case uart0 and serial1 are different (and I guess this is unexpected on your side, right?) and thus the speed is set to 460800: Code: xbian@xbian ~ $ cat /proc/device-tree/aliases/uart0; echo"" I've also tried the WAITFOR="bluetoothd" option, letting the xbmc service to autostart, but it's not working, I'm getting the very first scenario: thanks to the "sudo -u xbian bluetoothctl connect <dev>" command inside /etc/rc.local, my BT HPs always get connected, but then I can hear sounds only from Kodi's GUI, not from videos or addons. From what I've seen while testing this, I get the "connection active" prompt from my HPs during the Kodi starting splash and for some reason (no idea why, sorry...) this leads to sound OK from GUI, but no suond from videos or addons (same log entries from my first post). It seems that the BT device MUST be already connected BEFORE Kodi starts, so I believe that waiting for bluetoothd running is not enough: what do you think? Anyway, now I'm pretty OK with the current version of my /etc/rc.local running on 5.4.122 (maybe not very elegant, but working): Code: printf "\n\n" > /dev/tty1 As you can see, I've forked the BT device connection command, so Kodi will start even if I'm not using my BT headphones (otherwise, the "bluetoothctl connect" command hangs out for ever and Kodi never starts...) Many thanks! |
|||
2nd Jun, 2021, 04:47 AM
(This post was last modified: 2nd Jun, 2021 04:50 AM by Nachteule.)
Post: #66
|
|||
|
|||
RE: Bluetooth Audio output (Transmitter)
I already suspected before that this does not work via the WAITFOR variable, because rc.local is probably called much too late.
A better alternative than rc.local offers in my opinion the specification of a script in variable USERRUN=, there I have installed the connect with me. The following example might work for you: Code: #!/bin/sh Because of the speed, you probably have the variable dtoverlay=pi3-miniuart-bt activated in /boot/config |
|||
3rd Jun, 2021, 12:30 AM
Post: #67
|
|||
|
|||
RE: Bluetooth Audio output (Transmitter)
(2nd Jun, 2021 04:47 AM)Nachteule Wrote: Because of the speed, you probably have the variable dtoverlay=pi3-miniuart-bt activated in /boot/configOnce more you were right: I disabled that option and now my serial1 too gets connected @3000000: Code: using /dev/serial1@3000000 (2nd Jun, 2021 04:47 AM)Nachteule Wrote: A better alternative than rc.local offers in my opinion the specification of a script in variable USERRUN=, there I have installed the connect with me. I had many tries, but I was never able to have it working as expected with a USERRUN script. Let me add that I also had to run "pulseaudio" manually as xbian user (that was not inside your example script), otherwise it never starts automatically and it seems that the "bluetoothctl connect" command must be run as xbian user as well, otherwise my BT HPs never get connected again (because they were paired&trusted by xbian user, I guess). Anyway, when the USERRUN script is executed at "xbmc start" step, it actually makes xbmc to immediately stop (from the script header, I can see the same script executed as "xbmc stop", curiously even before I can see it executed as "xbmc start"...). I also tried to execute it at "preload start" step and in this case I get the usual "half-working mode": sounds from GUI are OK, but no sound from videos or addons. I may be wrong, but in the end I'm afraid this approach can't be applied, as it seems that nothing can be executed in advance of "preload start" phase. What still puzzles me is what's causing the "half-working" mode, as the "default" PulseAudio sink works fine for the GUI and not for videos or addons, but honestly, with my pretty limited knowledge of Xbian/Kodi, I don't know how to further investigate this... |
|||
3rd Jun, 2021, 04:16 AM
(This post was last modified: 3rd Jun, 2021 04:52 AM by Nachteule.)
Post: #68
|
|||
|
|||
RE: Bluetooth Audio output (Transmitter)
Yes, I was a bit irritated why you start pulseaudio manually, with my configurations it goes by itself
So I went to the bottom of the matter on a nearly unmodified XBian There is the file /etc/pulse/client.d/00-disable-autospawn.conf, which prevents the autospawn Strangely I don't have this file, but I have a file 01-enable-autospawn.conf -> /run/pulseaudio-enable-autospawn in that directory. but I'm sure I never changed anything in there. Probably comes from earlier Debian versions Anyway if you delete the 00-disable-autospawn.conf or set autospawn=yes pulseaudio starts automatically when Kodi is started What is also strange is that bluetoothctl on the orginal XBian as user xbian tells me that there are no controllers. so I HAVE to run bluetoothctl as root. Funny again that this works fine on my development system. To change this I have to extend the file /etc/dbus-1/system.d/bluetooth.conf, adding Code: <policy user="xbian"> does the job. Might be a good idea to add this automatically in the future EDIT: I'll answer this myself. currently (up to Debian Buster) the user must belong to the group lp or bluetooth so that bluetoothctl can be called as user. From Debian Bullseye on the user only has to belong to the group bluetooth, which makes more sense. I noticed that in the default installation the user xbian does not belong to the group bluetooth nor to the group lp. On my development systems the user xbian is a member of lp as well as bluetooth. Why this is the case I can't say anymore for the life of me |
|||
5th Jun, 2021, 12:06 AM
Post: #69
|
|||
|
|||
RE: Bluetooth Audio output (Transmitter)
(3rd Jun, 2021 04:16 AM)Nachteule Wrote: Anyway if you delete the 00-disable-autospawn.conf or set autospawn=yes pulseaudio starts automatically when Kodi is started OK, I was able to have pulseaudio started automatically with Kodi, but in this case I was never able to have my BT HPs working fine. From all the testing I've made, in order to have Kodi's GUI and videos&addons sounds on my BT HPs, it seems there are 2 strict conditions that must be met:
I guess I can sort of explain the second point (I suspect that a 'pulseaudio' sink MUST already exist in order to successfully connect a BT output device) and I easily tested it on my 'rc.local approach': swapping the execution order, with "bluetooth connect <dev>" command before "pulseaudio --start", no way I can get sounds from my HPs, while the other way around always works fine. I'm not sure of the second point, but I've tested it in 2 different ways:
The point is that when pulseaudio is automatically started with kodi, it's actually started AFTER kodi (pulseaudio pid always higher than kodi pid) and that's why I'm supposing pulseaudio MUST be already running when kodi starts to have it working fine, even if I can't explain why. Does this make any sense to you? Many thanks! EDIT I've added one more test:
In this case, my HPs never get connected, Kodi crashes immediately and I never see the GUI... This seems quite a confirmation of the first condition, but once more I can't explain why. |
|||
7th Jun, 2021, 02:20 AM
Post: #70
|
|||
|
|||
RE: Bluetooth Audio output (Transmitter)
This is all really quite strange.
In my development system (but only there) it also happens very rarely that Kodi crashes at startup with segfault and restarts when a BT connect is performed via the userrun script. But since this happens with Kodi 20 Alpha and Debian Bullseye and Kodi also otherwise sporadically crashes at startup I'm not worried yet. Anyway, with Kodi 19 and Debian Buster the BD connect via the userrun script always works without Kodi crashing, and the output to the BT speakers is also always given, although pulseaudio is always started automatically only after the start of Kodi. Tested with all Raspberry Pi's available to me (Pi3, Pi3B+, Pi4). This weekend I modified the BT start scripts again, because I obviously had some errors in thinking how the thing should work. But this has nothing to do with your general problem. |
|||
8th Jun, 2021, 01:03 AM
Post: #71
|
|||
|
|||
RE: Bluetooth Audio output (Transmitter)
I've made a few more testing with your "standard" approach (xbmc service autostarted, pulseaudio automatically started by Kodi and USERRUN script to connect the BT device) with a slightly modified script, collecting the script output to a log file (otherwise, it won't be collected on any file, right?), like this:
Code: #!/bin/sh This is the script log after a reboot: Code: ----------------------------------- First of all, is it expected that the USERRUN script is firstly run as "xbmc stop" and then as "xbmc start"? I didn't expect "stop" first, if not at all... Then, it seems that pulseaudio is not running yet when the script is executed: I've also try to wait inside the script for pulseaudio to start, but it seems it's always started AT THE END of the script, no matter how long it takes: is this expected too? So, in the end, this seems to be the real issue cause: pulseaudio not running yet when trying to connect the BT device. If so, given this should be the normal behaviour of the USERRUN script, I'm wondering how the BT connection works fine on your systems: maybe you're using something different from pulseaudio? |
|||
20th Jun, 2021, 03:55 AM
Post: #72
|
|||
|
|||
RE: Bluetooth Audio output (Transmitter)
(8th Jun, 2021 01:03 AM)ppianigiani Wrote: First of all, is it expected that the USERRUN script is firstly run as "xbmc stop" and then as "xbmc start"? I didn't expect "stop" first, if not at all... I had checked this immediately with me, there does not occur, but does what it should Quote:Then, it seems that pulseaudio is not running yet when the script is executed: I've also try to wait inside the script for pulseaudio to start, but it seems it's always started AT THE END of the script, no matter how long it takes: is this expected too? That is correct. pulseaudio is only started when an application (Kodi) wants to access it. Quote:So, in the end, this seems to be the real issue cause: pulseaudio not running yet when trying to connect the BT device. Actually I don't understand why it doesn't work for you. pulseaudio doesn't care which audio sinks are already present at startup. It always takes the default sink first, which can also be a dummy sink. And if another sink with a higher priority is added later (in your case a bt headset) it will use it. At least this is how it works with my installations Of course you should use the pulseaudio default device in Kodi and not explicitly your headset. I just checked this again: - System started - In Kodi Audio set to Pulseaudio (default) -> sound is routed to the TV - BT speakers turned on (were miraculously connected automatically) -> sound now arrives on the BT speakers As it should be |
|||
28th Nov, 2022, 04:40 AM
Post: #73
|
|||
|
|||
RE: Bluetooth Audio output (Transmitter)
This thread has been quite an adventure.
I'm expecting my Black Friday treat of a bluetooth earbud set to arrive and was wondering what I may need to do to be able to watch TV late at night without disturbing light sleepers... has anything changed in the 1y+ since the last post, or will I be a beta tester? (will Pipewire be a help or a hindrance?) |
|||
28th Nov, 2022, 05:05 AM
(This post was last modified: 28th Nov, 2022 05:08 AM by Nachteule.)
Post: #74
|
|||
|
|||
RE: Bluetooth Audio output (Transmitter)
For me Bluetooth has always been PITA
In my opinion there are 2 sticking points: 1) Is Pulseaudio already running before Kodi start? 2) Can you connect the headphones successfully? I don't know what should have changed since the last post. but I just remembered, at that time Debian Buster was still in use. I should still have the old configuration. I can test it in the next days. |
|||
4th Dec, 2022, 04:19 AM
Post: #75
|
|||
|
|||
RE: Bluetooth Audio output (Transmitter)
(28th Nov, 2022 05:05 AM)Nachteule Wrote: For me Bluetooth has always been PITA Thank you. my earbuds have arrived and I'm eager to test them (bluetooth has gotten better, but it is still a PITA, I agree) a2dp installation calls for alsa dependencies - I thought linux generally has evolved to PulseAudio...PipeWire seems to work with both from what I can tell (and has taken video into account from inception as I understand things)...bluez is also in there somewhere/somehow... to your 2nd point - it would be nice to have a dialog somewhere, but I'm ok with command line activities to a degree. I'd assume that would be a one-time pairing procedure (is this more for the kodi dev community than here specifically?- https://forum.kodi.tv/showthread.php?tid=366533&highlight=bluetooth+headset )(has kodi v20 addressed this?) |
|||
« Next Oldest | Next Newest »
|