1

I have a Pi0 which I am using to play radio or local music files via a BT speaker (see https://github.com/WhyNine/pi-radio-music for the full source code). The code is written in perl and I am using a library to interface to vlc to play the audio. It starts pulseaudio by calling "pulseaudio --start".

If I run the code from the command line ("perl software/radio.pl"), it works fine. The code connects to the BT speaker and plays the audio.

I have set up a systemd service to run the code after boot. The service file is:

[Unit]
Description=Radio and music player

[Service]
Type=simple
ExecStart=/bin/bash /home/pi/radio_service.sh
Restart=on-abort
User=pi
Group=pi

[Install]
WantedBy=multi-user.target

The radio_service.sh script does some housekeeping then finishes with "perl software/radio.pl 2> log". In this case, the code connects to the speaker ok and vlc reports that it is playing, but no audio can be heard from the speaker.

The output from systemctl status for the service is:

● radio.service - Radio and music player
     Loaded: loaded (/etc/systemd/system/radio.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-03-16 17:13:10 GMT; 24s ago
   Main PID: 1151 (bash)
      Tasks: 7 (limit: 415)
        CPU: 9.718s
     CGroup: /system.slice/radio.service
             ├─1151 /bin/bash /home/pi/radio_service.sh
             ├─1155 perl software/radio.pl
             └─1175 pulseaudio --start

Mar 16 17:13:10 radio systemd[1]: Started Radio and music player.
Mar 16 17:13:10 radio bash[1154]: running
Mar 16 17:13:19 radio pulseaudio[1175]: Failed to find a working profile.
Mar 16 17:13:19 radio pulseaudio[1175]: Failed to load module "module-alsa-card" (argument: "device_id="0" name="platform-20902000.hdmi" card_name="alsa_card.platform-20902000.hdmi" namereg_fail=false tsched=no fixed>
Mar 16 17:13:19 radio pulseaudio[1175]: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Mar 16 17:13:19 radio pulseaudio[1175]: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

Is the failure to load the module significant? If so, how can I fix it?

What is really annoying is that I had this working before, then had to rebuild the system ...

4
  • 1
    @ukBaz I rebuilt the system again starting from full Raspbian OS (with desktop) but I still get the same errors. I then tried adding "export $(dbus-launch)" to my service start-up script and this got rid of the dbus errors. Still no audio though.
    – WhyNine
    Commented Mar 17, 2023 at 18:10
  • What happens if you restart the service?
    – GChuf
    Commented Mar 17, 2023 at 21:07
  • @GChuf On restarting the service, I get the same error.
    – WhyNine
    Commented Mar 18, 2023 at 12:14
  • I tried with both boot to desktop and boot to CLI but neither worked
    – WhyNine
    Commented Mar 19, 2023 at 20:08

3 Answers 3

0

I think the main problem here could be this error here: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11. After some digging, I came across this question here.

I'm not sure if this will help you, but I'd start with export bus address to DBUS_SESSION_BUS_ADDRESS environment variable, like mentioned in the answer to the question in the link above:

export $(dbus-launch)

There's another link mentioned in the answers that explains how to start a D-Bus session when not under X11.

5
  • As per my comment to my OP, I tried this and it did get rid of the dbus errors, but still no audio :-(
    – WhyNine
    Commented Mar 18, 2023 at 22:11
  • Oh, sorry ... What about the "failed to get the working profile" part? Does that happen when you launch it manually as well? It should show up in /var/log/syslog, if not in your terminal
    – GChuf
    Commented Mar 19, 2023 at 16:56
  • Yes, I still get the working profile error.
    – WhyNine
    Commented Mar 19, 2023 at 20:06
  • Did you check bluetooth-related logs?
    – GChuf
    Commented Mar 20, 2023 at 9:04
  • I had a look in syslog and the only thing BT related was "Mar 20 19:34:19 raspberrypi2 bluetoothd[516]: /org/bluez/hci0/dev_00_E0_4C_A9_8D_1C/sep1/fd0: fd(25) ready"
    – WhyNine
    Commented Mar 20, 2023 at 19:42
0

After a bit more trial and error, I have found out that it seems to work reliably if I launch the pulseaudio daemon and then restart the bluetooth daemon. No idea why this has to be the case though.

I still have the fix in there to start d-bus but I'm not sure whether is required now.

0

Please take a look at the following where I ran into the same issue and was able to resolve it.

(Resolved) Audio over bluetooth doesn't work when launch as a systemd service

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Jan 9 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.