Jump to content

Pulseaudio status in Armbian, H3


Christos

Recommended Posts

I just have installed pulseaudio on my nanopi air. It took me a whole day to browse Internet, sort the moronic advices and have something that could work. But now I am stuck. I always avoided like the plague that piece of crap : the great and famous Poet (well loved from Linus himself) consider that it is not his job to write manuals and that bugs are our faults ... If I give a try at this, it is because a non less great genius decided that Bluetooth audio could only work with pulseaudio in new "modern" version of linux.

 

And now, I have an apparently working server (but without USB or audio out, I cannot test it). The sound stream flow if I redirect it threw the null sink, but get stuck if I redirect it threw an a2dp sink.

 

So, before I waste another day, can someone tell me if he manage to have BT audio with pulseaudio working on armbian with a 3.4.113 kernel and bluez5.

Link to comment
Share on other sites

@Christos

Pulseaudio is installed by default only on desktop images

 

Ok, thanks for the info!

That explains quite a bit since I'm currently trying on a headless NanoPi NEO.

Got a desktop with the OPi PCPlus so I'll give it a try there.

Link to comment
Share on other sites

@Christos

Pulseaudio is installed by default only on desktop images

 

Perhaps it would be nice to present things as they are : nobody can provide support for non desktop environment because of the behavior of the developer. (Which is the same as for systemd ...)

Link to comment
Share on other sites

Perhaps it would be nice to present things as they are : nobody can provide support for non desktop environment because of the behavior of the developer. (Which is the same as for systemd ...)

No, it's just that Pulseaudio is a multimedia feature and CLI images are more oriented on server usage where ALSA is enough if you need sound.

As I said previously, end users (aka "Raspberry Pi target audience") don't care about Pulseaudio, systemd or NetworkManager as long as it works well enough by default in their distribution.

Link to comment
Share on other sites

No, it's just that Pulseaudio is a multimedia feature and CLI images are more oriented on server usage where ALSA is enough if you need sound.

As I said previously, end users (aka "Raspberry Pi target audience") don't care about Pulseaudio, systemd or NetworkManager as long as it works well enough by default in their distribution.

 

As I said above, you cannot (no more) use BT audio without pulseaudio. I want to make an a2dp server, so I need an headless config without X11. That suppose to have pulseaudio working in system mode that the developer refuse to support.

 

I already have my sound server working on an RPI since 3 years with Bluez4 and alsa. I reinstalled it with Blusez4 with a gentoo using armbian good kernel and uboot on a nanopi air. The fact is that bluez4 is badly designed and badly handle race conditions in reconnecting profiles and I can handle these cases without having bluetoothd or the kernel crashing.

 

So without pulseaudio working you cannot use your BT speaker or headset that are working with any other system.

Link to comment
Share on other sites

As I said above, you cannot (no more) use BT audio without pulseaudio. I want to make an a2dp server, so I need an headless config without X11.

Yes, I saw this change in bluez5 (they removed ALSA sink) and unfortunately bluez has too much dependencies so installing bluez4 even on Jessie is a mess and I'm not sure if it is possible at all.

 

That suppose to have pulseaudio working in system mode that the developer refuse to support.

So this doesn't work? https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/SystemWide/

Link to comment
Share on other sites

 

THIS doesn't work :

 

"If the system-wide mode is enabled it is advisable to disable module loading during runtime by passing --disallow-module-loading to the daemon"

 

Because the BT sinks needs module module-bluez5-device dynamic loading to be passed the interface path. So you need to enforce module auto-loading.

 

If you follow the link near the end of the page, you will read :

 

"When in system mode you also lose a lot of further functionality, like the bridging to jack, to rygel (upnp), to X11, to ckit, and so on And, most importantly: it is explicitly not designed for it, you are on your own if you use it. The maintainer's interest in making sure system mode is well supported is rather minimal."

 

Pulseaudio use X11 authentication facility. So if you want to use it on a headless server without installing a pseudo/minimal or full Xserver, you also need to go in system mode and disable authentication.

 

In /etc/pulse/daemon.conf :

 

allow-module-loading = yes

 

In /etc/pulse/system.pa

 

load-module module-native-protocol-unix auth-anonymous=1

load-module module-native-protocol-tcp auth-ip-acl=<your subnet>/<your mask>

 

For BT

 

load-module module-switch-on-connect

load-module module-bluetooth-policy

load-module module-bluez5-discover

 

You also need to create a file for dbus : /etc/dbus-1/system.d/pulse.conf

 

<!DOCTYPE busconfig PUBLIC

 "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"

 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">

<busconfig>

        <policy user="root">

                <allow own="org.pulseaudio.Server"/>

                <allow send_destination="org.bluez"/>

                <allow send_interface="org.bluez.Manager"/>

        </policy>

        <policy user="pulse">

                <allow own="org.pulseaudio.Server"/>

                <allow send_destination="org.bluez"/>

                <allow send_interface="org.bluez.Manager"/>

        </policy>

        <policy context="default">

                <deny own="org.pulseaudio.Server"/>

                <deny send_destination="org.bluez"/>

                <deny send_interface="org.bluez.Manager"/>

        </policy>

</busconfig>

 

So (if I haven't forgotten something), you can :

 

- apt-get install pulseaudio pulseaudio-module-bluetooth pulseaudio-utils

- start it with "pulseaudio --system [-D for daemonize]" and ignore any  insults and error messages that are in fact irrelevant provided the daemon does not end.

- manage it with pactl

- pair your BT headsink WHILE pulseaudio is running

 

But until now, I wasn't able to hear anything : "mplayer -ao pulse" is stuck as soon as I redirect on a BT sink, and without any message. I think that the daemon is working apart of a2dp, but I cannot even test sinks other than the null sink on nanopi air without soldering something (no USB to check on my usb dac)

 

So I would like to know if someone had manage to have pulseaudio and bluez5 working in normal or system mode ?

 

 

Link to comment
Share on other sites

 

So (if I haven't forgotten something), ...

 

I think that you also need to add root to groups : pulse and pulse-access

 

But as the daemon will remind you :

 

W: [pulseaudio] main.c: OK, so you are running PA in system mode. Please note that you most likely shouldn't be doing that.

W: [pulseaudio] main.c: If you do it nonetheless then it's your own fault if things don't work as expected.

Link to comment
Share on other sites

 

So I would like to know if someone had manage to have pulseaudio and bluez5 working in normal or system mode ?

 

 

Well, I eventually got it working :

 

- first I also forgot to signal I had change : "ControllerMode = bredr" in /etc/bluetooth/main.conf (not sure it is necessary)

- second in /etc/init.d/ap6212-bluetooth, in hciattach command the serial speed is at 115200 and fex/uboot param don't seem to be relevant. I had to put it at 1500000, otherwise the daemon drops furiously samples.

- and the major problem :

 

The sink is by default connected to the headset profile at 8KHz mono (and it seems it doesn't work). You need to change it :

 

- pactl set-card-profile <num> a2dp_sink

 

<num> has to be retrieve with : pactl list cards (and it changes constantly !)

 

But there is there also a bug : the next time the daemon will fail to reconnect the (recorded) profile and you will need to reset the "headset" profile, reconnect and reset a2dp : pactl set-card-profile <num> headset_head_unit + stop/start the device + pactl set-card-profile <num> a2dp_sink

 

(The web is full of advises on people that explain that in normal mode with graphical interface, they need to alternate between profiles and restart the device before they can connect a2dp)

 

I will now look if I manage to get the AVRCP profile connected threw uinput in order to read next/back commands.

 

I end my comments here as it seems nobody is interested in BT on armbian.

 

PS: second device, other problem ...

 

It seems this one does not have his audio profile automatically connected. So if the device fail to be recognized by pulse or if it refuses to switch profile (with set-card-profile), try a connect <addr> with bluetoothctl ...

 

PS2: workaround

 

It seems profile selection bug is well knows (but not corrected in pulseaudio 8). After many tests, I think that the better solution is to NOT load the "module-card-restore" module. Otherwise, this module will reset the ad2p profile and bluez module fall in bugs and race conditions. So the workaround become :

- disable module module-card-restore

- monitor dbus events

- on base [device] connection event, force connection by bluetoothctl connect, in order to connect audio profile (if device does not do that itself)

- on audio [media] connection event, switch profile to a2dp

- on [transport active] event start playback

 

There are other bug that may need to be handled, but with the method described above, I can get a fast clean working server.

 

Of course I think that this is only relevant for one version of (pulse, bluetooth, dbus)

Link to comment
Share on other sites

Here is my personal doc for configuring pulseaudio in system mode. For a2dp usage, be aware that can work but it is buggy, and bugs depends on kernel version, bluez version, dbus version, pulseaudio version ... I use it with

3.4.113-sun8i kernel, bluez 5.37, pulse 8.0, dbus ?.?

You will also need to boost serial speed if you use AP6212 (need to hack startup script somewhat like : hciattach /dev/ttyS3 bcm43xx 1500000 flow bdaddr 42:29:B1:55:01:01)

And in order to use it "unattended", you need a server to start playback, switch profile on connection - and optionally handle AVRCP commands.

 

Tips :

- pair your devices while pulseaudio is running

- use /usr/share/doc/bluez-tests/examples/monitor-bluetooth to monitor/automate

- use pactl to switch/reset profile (you need a2dp)

 

1 Package

  • apt-get install pulseaudio pulseaudio-module-bluetooth pulseaudio-utils

2 Config

  • /etc/pulse/daemon.conf : allow-module-loading = yes
  • /etc/pulse/system.pa :
    • load-module module-native-protocol-unix auth-anonymous=1
    • load-module module-native-protocol-tcp auth-ip-acl=<your subnet>/<your mask>
    • load-module module-switch-on-connect
    • load-module module-bluetooth-policy
    • load-module module-bluez5-discover
  • create : /etc/dbus-1/system.d/pulse.conf
<!DOCTYPE busconfig PUBLIC
 "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
 "http://www.freedeskt...busconfig.dtd">
<busconfig>
        <policy user="root">
                <allow own="org.pulseaudio.Server"/>
                <allow send_destination="org.bluez"/>
                <allow send_interface="org.bluez.Manager"/>
        </policy>
        <policy user="pulse">
                <allow own="org.pulseaudio.Server"/>
                <allow send_destination="org.bluez"/>
                <allow send_interface="org.bluez.Manager"/>
        </policy>
        <policy context="default">
                <deny own="org.pulseaudio.Server"/>
                <deny send_destination="org.bluez"/>
                <deny send_interface="org.bluez.Manager"/>
        </policy>
</busconfig>

  • add root to groups : pulse and pulse-access
  • change : "ControllerMode = bredr" in /etc/bluetooth/main.conf

3 Start pulse audio :

  • pulseaudio --system [-D for daemonize]
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines