Taron
Posts: 3
Joined: Mon May 16, 2016 4:26 pm

Audio not playing via Pulseaudio

Mon May 16, 2016 4:58 pm

I have a problem with playing sound on my raspberry pi 2 via pulseaudio.

I installed pulseaudio together with pulseaudio-module-bluetooth, pulseaudio-module-x11 and pavucontrol following instructions from this instructables project (http://www.instructables.com/id/Raspber ... /?ALLSTEPS).

However I seem to have a problem with Pulseaudio as I cannot get any sound playing via pulseaudio and the 3.5 mm jack.

When I call pulseaudio I get the following message

Code: Select all

[email protected] ~ $ pulseaudio
W: [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
W: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
E: [pulseaudio] bluez4-util.c: org.bluez.Manager.GetProperties() failed: org.freedesktop.DBus.Error.UnknownMethod: Method "GetProperties" with signature "" on interface "org.bluez.Manager" doesn't exist


Also pavucontrol does not work

Code: Select all

[email protected] ~ $ pavucontrol
Unable to init server: Verbindung ist gescheitert:Verbindungsaufbau abgelehnt
I have already tried to reinstall pulseaudio by purging it and reinstalling via apt-get but this did not help.

I hope anyone can help me to get pulseaudio up and running on my RPI as I want to use it as a Bluetooth Sink for multiple devices.

User avatar
Douglas6
Posts: 4769
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Audio not playing via Pulseaudio

Mon May 16, 2016 5:51 pm

That Instructable is quite out-of-date. I'm not sure what you've done, or what the specified scripts have done, but the error indicates you're trying to run outdated BlueZ 4 code. Frankly, I would re-image the card and follow this tutorial: https://github.com/davidedg/NAS-mod-con ... Audio5.txt

Taron
Posts: 3
Joined: Mon May 16, 2016 4:26 pm

Re: Audio not playing via Pulseaudio

Mon May 16, 2016 6:59 pm

Maybe I should have been more specific.
I did not follow the instructable completely as Pulseaudio and Bluez are available in the raspian repositories now.

Basically what I did was to install a couple of packages via apt-get install:
- espeak
- mplayer
- pulseaudio
- pulseaudio-module-bluetooth
- pulseaudio-module-x11
- pavucontrol
- bluez

Then I ran the following script which :

Code: Select all

#!/bin/bash

read -p "Bluetooth device name: " BT_NAME

#--------------------------------------------------------------------
function tst {
    echo "===> Executing: $*"
    if ! $*; then
        echo "Exiting scrip due to error from: $*"
        exit 1
    fi	
}
#--------------------------------------------------------------------

tst cd `dirname $0`

tst sudo cp init.d/pulseaudio /etc/init.d
tst sudo chmod +x /etc/init.d/pulseaudio
tst sudo update-rc.d pulseaudio defaults

tst sudo cp init.d/bluetooth /etc/init.d
tst sudo chmod +x /etc/init.d/bluetooth
tst sudo update-rc.d bluetooth defaults

tst sudo cp init.d/bluetooth-agent /etc/init.d
tst sudo chmod +x /etc/init.d/bluetooth-agent
tst sudo update-rc.d bluetooth-agent defaults

tst sudo cp usr_local_bin/bluez-udev /usr/local/bin
tst sudo chmod 755 /usr/local/bin/bluez-udev

tst sudo cp usr_local_bin/simple-agent.autotrust /usr/local/bin
tst sudo chmod 755 /usr/local/bin/simple-agent.autotrust

tst sudo cp usr_local_bin/say.sh /usr/local/bin
tst sudo chmod 755 /usr/local/bin/say.sh

tst sudo cp usr_local_bin/bluezutils.py /usr/local/bin


if [ -f /etc/udev/rules.d/99-input.rules ]; then

sudo patch /etc/udev/rules.d/99-input.rules << EOT
***************
*** 1 ****
--- 1,2 ----
  SUBSYSTEM=="input", GROUP="input", MODE="0660"
+ KERNEL=="input[0-9]*", RUN+="/usr/local/bin/bluez-udev"
EOT

else

tst sudo touch /etc/udev/rules.d/99-input.rules
tst sudo chmod 666 /etc/udev/rules.d/99-input.rules
sudo cat  << EOT > /etc/udev/rules.d/99-input.rules
SUBSYSTEM=="input", GROUP="input", MODE="0660"
KERNEL=="input[0-9]*", RUN+="/usr/local/bin/bluez-udev"
EOT

fi

tst sudo chmod 644 /etc/udev/rules.d/99-input.rules

sudo patch /etc/bluetooth/main.conf << EOT
***************
*** 7,8 ****
--- 7,9 ----
  #Name = %h-%d
+ Name = ${BT_NAME}

***************
*** 11,12 ****
--- 12,14 ----
  #Class = 0x000100
+ Class = 0x20041C

***************
*** 15,17 ****
  # 0 = disable timer, i.e. stay discoverable forever
! #DiscoverableTimeout = 0

--- 17,19 ----
  # 0 = disable timer, i.e. stay discoverable forever
! DiscoverableTimeout = 0
EOT

sudo patch /etc/pulse/daemon.conf << EOT
***************
*** 54,57 ****
  ; resample-method = speex-float-1
! ; enable-remixing = yes
! ; enable-lfe-remixing = no

--- 54,58 ----
  ; resample-method = speex-float-1
! resample-method = speex-fixed-2
! enable-remixing = no
! enable-lfe-remixing = no

***************
*** 78,84 ****
  ; alternate-sample-rate = 48000
! ; default-sample-channels = 2
  ; default-channel-map = front-left,front-right

! ; default-fragments = 4
! ; default-fragment-size-msec = 25

--- 79,85 ----
  ; alternate-sample-rate = 48000
! default-sample-channels = 2
  ; default-channel-map = front-left,front-right

! default-fragments = 10
! default-fragment-size-msec = 10
EOT

sudo patch /etc/pulse/system.pa << EOT
***************
*** 23,25 ****
  .ifexists module-udev-detect.so
! load-module module-udev-detect
  .else
--- 23,26 ----
  .ifexists module-udev-detect.so
! #load-module module-udev-detect
! load-module module-udev-detect tsched=0
  .else
***************
*** 57 ****
--- 58,63 ----
  load-module module-position-event-sounds
+
+ ### Automatically load driver modules for Bluetooth hardware
+ .ifexists module-bluetooth-discover.so
+     load-module module-bluetooth-discover
+ .endif
EOT


#sudo service bluetooth start &
#sudo service pulseaudio start &
#sudo service bluetooth-agent start &

sleep 5

echo "Done! You should reboot now"
I would like to avoid going trough the hassle of rebuilding my whole Pi-System.
However if no one can offer any alternative solution I will take the bitter pill and go with your suggestion.

User avatar
Douglas6
Posts: 4769
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Audio not playing via Pulseaudio

Mon May 16, 2016 7:34 pm

Yeah, I'm not sure what that script does exactly, but it's messing with udev rules, which it shouldn't, and running a service called 'bluetooth-agent' whatever that is. I couldn't be sure how to clean up after that.

Taron
Posts: 3
Joined: Mon May 16, 2016 4:26 pm

Re: Audio not playing via Pulseaudio

Mon May 16, 2016 8:23 pm

OK, then I will rebuild my PIs system from scratch and try out the tutorial you are suggesting.
I will let you know if it works or if any other problems occur.

In the meantime thanks for your help.

spl23
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 376
Joined: Fri Dec 26, 2014 11:02 am

Re: Audio not playing via Pulseaudio

Mon May 16, 2016 9:11 pm

Officially, PulseAudio requires X to be running - a standard install of PulseAudio launches the pulseaudio daemon only when the desktop is launched.

If you want to use Pulse from a command-line without launching the desktop, you will need to start the daemon manually before you attempt to connect a Bluetooth device (type "pulseaudio -D" at the CLI prompt).

I'd suggest you just download the latest Jessie image which we released last week - this contains all necessary libraries for Bluetooth audio, already installed.

User avatar
Douglas6
Posts: 4769
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Audio not playing via Pulseaudio

Mon May 16, 2016 9:55 pm

That guide includes a systemd unit to run PulseAudio system-wide as a service; no need for X. That's my preferred way to do it on the Pi. I hope the new Bluetooth GUI doesn't interfere with that.

AlessandroFerri
Posts: 61
Joined: Tue Apr 02, 2013 5:44 pm

Re: Audio not playing via Pulseaudio

Mon May 23, 2016 2:21 pm

Hi everyone,
I think the problem is due to the fact that in the Debian Jessie repository, pulseaudio is still build with bluez4 as an option, not with Bluez5 only, and not finding the corresponding library get the issue. I think that this issue should be fixed in the repository.
What do you think about?

User avatar
Douglas6
Posts: 4769
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Audio not playing via Pulseaudio

Mon May 23, 2016 2:37 pm

I'm not sure what issue you are referring to. I can say that I have a Pi2B A2DP receiver running the current Raspbian software, and it works flawlessly, I use it everyday.

spa46
Posts: 3
Joined: Sat Apr 09, 2016 3:48 am

Re: Audio not playing via Pulseaudio

Fri May 27, 2016 3:33 am

I am having the same problem right now to run bluetooth audio.

I have been solving number of problems but I am consistently facing alternative problems like you mentioned of pulseaudio and bluez4-util.
It seems that the program of pulseaudio still holds the old bluez4-util and I am looking for alternatives or to get rid of a dependency.

broe23
Posts: 903
Joined: Thu Jan 28, 2016 9:35 pm
Location: Central IL
Contact: Website

Re: Audio not playing via Pulseaudio

Fri May 27, 2016 6:45 am

Alsa/Pulse has been an issue for a long time. There is finally a proper post for troubleshooting it. https://help.ubuntu.com/community/Sound ... gProcedure
Ren: Now listen, Cadet. I've got a job for you. See this button? Ren: Don't touch it! It's the History Eraser button, you fool! Stimpy: So what'll happen? Ren: That's just it. We don't know. Maybe something bad, maybe something good.

Return to “Troubleshooting”