[SOLVED] Streaming my Linux sound to a Raspberry Pi over the network - Rpi as audio sink
Linux - Embedded & Single-board computerThis forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Streaming my Linux sound to a Raspberry Pi over the network - Rpi as audio sink
I've found several topics scattered across the net covering this (also one in here, but unresolved) - but instructions in the tutorials diverge from what I find on my RPi OS, and mostly they're several years old, so I dare open a new thread.
Setup: desktop pc is Manjaro Linux, the Raspberry Pi has Raspberry Pi OS Stretch. I reach it using RealVNC Viewer from my desktop. Both are connected to the same router via cable. I have my stereo hooked up to the RPi at the analog audio 3,5mm plug, and I'd like it to play all sound from my desktop.
4. RPi appears as a sound sink in Manjaro, but two duplicates . Selecting either does not make the sound come out the stereo.
EDIT: What's a good CLI command for diagnosing audio devices, network audio? Screenshots are a bit of a pain...
The pulseaudio CLI has a lot of options, this is my best guess:
You guessed it, I'm confused about a couple things:
- The server is Manjaro, the client is RPiOS, right?
- RTP: do I even need it? If yes, how are the correct settings?
- Correct settings for Paprefs on each machine. I've played around a good two hours, no luck. I've verified on RPi that it can output its own sound to speakers alright. It just won't pass on the ones from Manjaro.
Here's a thread on Stack Exchange that provides instructions for my use case, but for example /etc/default/pulseaudio does not exist on my RPiOS, so I'm unsure which are the correct config files on my system. These things do change around a lot as versions progress.
If anyone here is up to speed, all help is greatly appreciated!
EDIT: more info on the RPi situation: The playback stream going on in Manjaro (Spotify) is visible in RPi Pavucontrol (the volume bar is also moving)
Until you get a better reply...client RPi means this is your end user and the source is the server. Eg you are a bank customer...end user and you login to bank which is the server.
Did you expect something different for pulse showing suspended on your pi....check your third link
Until you get a better reply...client RPi means this is your end user and the source is the server. Eg you are a bank customer...end user and you login to bank which is the server.
Did you expect something different for pulse showing suspended on your pi....check your third link
Code:
pulseaudio -vvv
Voila:
Code:
pi@raspberrypi:~ $ pulseaudio -vvv
I: [pulseaudio] main.c: setrlimit(RLIMIT_NICE, (31, 31)) failed: Die Operation ist nicht erlaubt
D: [pulseaudio] core-rtclock.c: Timer slack is set to 50 us.
D: [pulseaudio] core-util.c: RealtimeKit worked.
I: [pulseaudio] core-util.c: Successfully gained nice level -11.
I: [pulseaudio] main.c: This is PulseAudio 12.2
D: [pulseaudio] main.c: Compilation host: arm-unknown-linux-gnueabihf
D: [pulseaudio] main.c: Compilation CFLAGS: -g -O2 -fdebug-prefix-map=/home/pi/new/pulseaudio-12.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -W -Wextra -pipe -Wno-long-long -Wno-overlength-strings -Wunsafe-loop-optimizations -Wundef -Wformat=2 -Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing -Wwrite-strings -Wno-unused-parameter -fno-common -fdiagnostics-show-option -fdiagnostics-color=auto
D: [pulseaudio] main.c: Running on host: Linux armv7l 5.10.63-v7l+ #1459 SMP Wed Oct 6 16:41:57 BST 2021
D: [pulseaudio] main.c: Found 4 CPUs.
I: [pulseaudio] main.c: Page size is 4096 bytes
D: [pulseaudio] main.c: Compiled with Valgrind support: yes
D: [pulseaudio] main.c: Running in valgrind mode: no
D: [pulseaudio] main.c: Running in VM: no
D: [pulseaudio] main.c: Optimized build: yes
D: [pulseaudio] main.c: FASTPATH defined, only fast path asserts disabled.
I: [pulseaudio] main.c: Machine ID is cbf4c75fd4c24dc0a7b80fed787762b0.
I: [pulseaudio] main.c: Session ID is 2.
I: [pulseaudio] main.c: Using runtime directory /run/user/1000/pulse.
I: [pulseaudio] main.c: Using state directory /home/pi/.config/pulse.
I: [pulseaudio] main.c: Using modules directory /usr/lib/pulse-12.2/modules.
I: [pulseaudio] main.c: Running in system mode: no
E: [pulseaudio] pid.c: Daemon already running.
E: [pulseaudio] main.c: pa_pid_file_create() fehlgeschlagen.
I was hoping to find something that gives me all the info on that screenshot as text in my terminal, but this doesn't seem to be it
you appear to have a mismatch of configs....lets see if you agree?
your last post shows line=Running in system mode: no
ditto " Using state directory /home/pi/.config/pulse
2) when you run
Code:
man 5 pulse-client.conf
you will see configs allowed are
~/.config/pulse/client.conf
~/.config/pulse/client.conf.d/*.conf
/etc/pulse/client.conf
/etc/pulse/client.conf.d/*.conf
so have you copied client.conf from etc/pulse to your home .config/pulse?
3) in your top post....it does not appear so....it appears you have used the /etc/pulse dir?
############################
so to follow your link guide....I suggest you use root powers to edit the system files
and....run it as daemon and add those config lines to /etc/pulse/system.pa
you appear to have a mismatch of configs....lets see if you agree?
your last post shows line=Running in system mode: no
ditto " Using state directory /home/pi/.config/pulse
2) when you run
Code:
man 5 pulse-client.conf
you will see configs allowed are
~/.config/pulse/client.conf
~/.config/pulse/client.conf.d/*.conf
/etc/pulse/client.conf
/etc/pulse/client.conf.d/*.conf
so have you copied client.conf from etc/pulse to your home .config/pulse?
3) in your top post....it does not appear so....it appears you have used the /etc/pulse dir?
############################
so to follow your link guide....I suggest you use root powers to edit the system files
and....run it as daemon and add those config lines to /etc/pulse/system.pa
subject to your router ip...it may start 10.something not 192 something etc
3) I do not have /etc/default/pulse ....this appears to be distro specific
but the intent of that file....it to auto start the service at boot.
if you get no hits delete grep enabled and see if you get any pulse hits.
we need pulse starting
Thanks a lot! Before I try all this, I'm just wondering though if, maybe it'd be easier to start from scratch and then tune the default configs?
Right now it's quite the mess at least in that I get 4 instances of the Manjaro audio sink showing up in RPi paprefs. Also, following the Stackexchange tutorial, I think I enabled the audio sharing both ways, which made it even more confusing, and I actually need only one-way (sound goes from Manjaro to Rpi). Disabling the other way again has apparently not worked, because I still see all the audio sinks of both sides on both ends...
If you say just going through your suggestions amount to cleaning up, I'll do that. I just would be happier making things work and understanding them, than just making it work, which your suggestions will probably achieve.
My RPi runs the latest version of Raspberry Pi OS so yes, systemd.
show the results for
Code:
sudo systemctl list-unit-files | grep enabled | grep pulse
if you get no hits delete grep enabled and see if you get any pulse hits.
2) so have you copied client.conf from etc/pulse to your home .config/pulse?
No:
Code:
pi@raspberrypi:~ $ ls ~/.config/pulse
cbf4c75fd4c24dc0a7b80fed787762b0-card-database.tdb
cbf4c75fd4c24dc0a7b80fed787762b0-default-sink
cbf4c75fd4c24dc0a7b80fed787762b0-default-source
cbf4c75fd4c24dc0a7b80fed787762b0-device-volumes.tdb
cbf4c75fd4c24dc0a7b80fed787762b0-stream-volumes.tdb
cookie
Quote:
3) in your top post....it does not appear so....it appears you have used the /etc/pulse dir?
Yes, although I wouldn't say I used it, I guess the installer did.
Code:
pi@raspberrypi:~ $ ls /etc/pulse
client.conf client.conf.d daemon.conf default.pa system.pa
I inserted the recommended module loads:
Code:
pi@raspberrypi:~ $ cat /etc/pulse/system.pa
...
#!/usr/bin/pulseaudio -nF
#
# This startup script is used only if PulseAudio is started in system
# mode.
...
### Enable streaming to remote over network
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.1.1/24
load-module module-zeroconf-publish
Last edited by bennypr0fane; 10-31-2021 at 07:03 PM.
so to follow your link guide....I suggest you use root powers to edit the system files
and....run it as daemon and add those config lines to /etc/pulse/system.pa
...
we need pulse starting
Okay, I got it starting as a service now. I found this thread: https://forums.raspberrypi.com/viewtopic.php?t=156120
They are either making a Systemd service or combining startup scripts with crontabs (albeit this is all back from better times when Rapsberry Pi OS was still called Raspbian) . I went with the former now using those instructions:
Instead of this:
Quote:
2) Make sure PulseAudio starts automatically:
sudo nano /etc/default/pulseaudio
Look for the PULSEAUDIO_SYSTEM_START entry and change it to 1 so that looks like PULSEAUDIO_SYSTEM_START=1
Then ‘systemctl enable pulseaudio’ and ‘systemctl start pulseaudio’
That worked! Was Debian maybe still not using Systemd in 2016?
I now have a working confguration! Even though it reports this authentication problem further down the line:
Code:
pi@raspberrypi:~ $ systemctl -l status pulseaudio.service
● pulseaudio.service - PulseAudio Daemon
Loaded: loaded (/etc/systemd/system/pulseaudio.service; enabled; vendor preset
Active: active (running) since Sun 2021-10-31 23:04:44 CET; 25s ago
Main PID: 398 (pulseaudio)
Tasks: 4 (limit: 4915)
CGroup: /system.slice/pulseaudio.service
└─398 /usr/bin/pulseaudio --system --realtime --disallow-exit --no-cp
...
Okt 31 23:27:31 raspberrypi pulseaudio[393]: W: [pulseaudio] authkey.c: Failed to open cookie file '/var/run/pulse/.config/pulse/cookie': Datei oder Verzeichnis nicht gefunden
Okt 31 23:27:31 raspberrypi pulseaudio[393]: W: [pulseaudio] authkey.c: Failed to load authentication key '/var/run/pulse/.config/pulse/cookie': Datei oder Verzeichnis nicht gefunden
Okt 31 23:27:31 raspberrypi pulseaudio[393]: W: [pulseaudio] authkey.c: Failed to open cookie file '/var/run/pulse/.pulse-cookie': Datei oder Verzeichnis nicht gefunden
Okt 31 23:27:31 raspberrypi pulseaudio[393]: W: [pulseaudio] authkey.c: Failed to load authentication key '/var/run/pulse/.pulse-cookie': Datei oder Verzeichnis nicht gefunden
Okt 31 23:27:31 raspberrypi pulseaudio[393]: W: [pulseaudio] ipacl.c: Host part of ACL entry '192.168.1.1/24' is not zero!
Okt 31 23:27:38 raspberrypi pulseaudio[393]: W: [pulseaudio] protocol-native.c: Denied access to client with invalid authentication data.
I checked "No authentication required" in Paprefs > Network Server, maybe that makes this a non-issue, because:
I've got sound from Manjaro coming out of the speakers hooked up to the RPi!
Last edited by bennypr0fane; 10-31-2021 at 06:51 PM.
I would mark this thread as solved, configuration-wise. It's just that the sound coming from RPi is about half the volume and half the quality of what comes out when I hook the stereo up to the Manjaro box directly. The low volume isn't making me happy at all.
Does anyone have experience with this? Does streaming over the network just degrade the quality that much? On the plus side, there's no noticable lag/offset when playing video, but it's just too quiet...
And there's still this confusing mess of options in Pavucontrol and Pasystray - a dozen of servers, sinks, devices and playback streams to choose from, I managed to guess the right ones apparently.
Last edited by bennypr0fane; 10-31-2021 at 07:06 PM.
its great you have sound from server Manjaro to RPi but I wonder if you have a router that shows the true addresses for each hardware?
eg on Manjaro (server) run
Code:
ip addr show
I do not have RPi set up at the moment so my server shows....with snips
inet 127.0.0.1/8 scope host lo
inet 192.168.1.2/24 brd 192.168.1.255 scope global dynamic enp34s0 (=old eth0)
look at your error message for
Quote:
SNIP entry '192.168.1.1/24' is not zero!
I think that will be resolved when you edit your file system.pa so it reads
[ben@catull-mnj ~]$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:01:2e:79:71:af brd ff:ff:ff:ff:ff:ff
inet 192.168.1.2/24 brd 192.168.1.255 scope global dynamic noprefixroute enp1s0
valid_lft 70839sec preferred_lft 70839sec
inet6 fe80::243f:b047:1eb2:6b7e/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: enp0s31f6: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
link/ether 00:01:2e:79:71:ae brd ff:ff:ff:ff:ff:ff
4: wlp2s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 36:0a:58:ad:a2:1a brd ff:ff:ff:ff:ff:ff permaddr 34:f6:4b:eb:74:0e
Manjaro's IP address should be 192.168.1.2, RPi should be .3
I assigned the Manjaro IP on the router in a "reserved IP addresses list", but this didn't work for the RPi, so there I assigned it in its own OS's config file, Because the one reserved on this crappy router from my ISP failed to take effect.
Last edited by bennypr0fane; 10-31-2021 at 08:39 PM.
I made the edit, so that's the IP of the sound server now. I thought it was supposed to be the router's one.
the error still looks the same though, just with a .2 instead of .1:
Code:
Nov 01 01:40:53 raspberrypi pulseaudio[420]: W: [pulseaudio] ipacl.c: Host part of ACL entry '192.168.1.2/24' is not zero!
Do you think that has anything to do with the bad sound quality?
I found the problem:
Alsa had the volume level at 40% for the analog sound card. Adjusting it to 100% using Alsamixer, I get normal volume from the Pi. I was able to find this by posting in the Pulseaudio Matrix channel.
It's been also discussed over at the Raspberry Pi forums: https://forums.raspberrypi.com/viewt...rt=25#p1799483
Cheers, and thanks a lot!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.