broms
Posts: 1
Joined: Tue May 04, 2021 8:23 pm

Choppy/laggy RTP Streaming with Raspberry Pi Model B Rev 2

Fri May 07, 2021 9:10 pm

I've got a pi set up to receive a rtp stream in pulseaudio, but the sound is all laggy and choppy.

Are there configuration options I can apply to improve this? Or is this model not capable of handling this kind of audio streaming? I'll copy some system info and output below. Let me know if there is other output that would help diagnose problems, or improve my setup. Thanks!

I believe it's a 700mhz processor. Here is the output of cpu info:

Code: Select all

[alarm@alarmpi ~]$ cat /proc/cpuinfo
processor       : 0
model name      : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS        : 697.95
Features        : half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xb76
CPU revision    : 7

Hardware        : BCM2835
Revision        : 000e
Serial          : 000000007b1611f1
Model           : Raspberry Pi Model B Rev 2
cpu load during idle

Code: Select all

[alarm@alarmpi ~]$ w
 16:44:56 up  4:42,  1 user,  load average: 0.60, 0.79, 0.81
USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
alarm    pts/0     15:35    0.00s  1.00s  0.06s w
during pulseaudio stream playback the system comes basically to a standstill and is unresponsive until the stream stops. But doesn't seem overloaded:

Code: Select all

top - 16:58:36 up  4:56,  1 user,  load average: 0.95, 1.16, 1.01
Tasks: 107 total,   1 running, 106 sleeping,   0 stopped,   0 zombie
%Cpu(s):  5.0 us,  4.3 sy,  0.0 ni, 89.7 id,  0.0 wa,  0.0 hi,  1.1 si,  0.0 st
MiB Mem :    424.0 total,    193.1 free,     55.2 used,    175.6 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.    347.3 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
  838 alarm     20   0   93332  11236   9236 S   6.8   2.6   0:09.27 pulseaudio
It's connected over wifi to an Asus RT-N66U router. Ping/speed to the gateway seems good:

Code: Select all

[alarm@alarmpi ~]$ ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=237 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.74 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=1.72 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=2.80 ms
64 bytes from 192.168.1.1: icmp_seq=5 ttl=64 time=1.48 ms
64 bytes from 192.168.1.1: icmp_seq=6 ttl=64 time=1.88 ms
64 bytes from 192.168.1.1: icmp_seq=7 ttl=64 time=1.45 ms
64 bytes from 192.168.1.1: icmp_seq=8 ttl=64 time=2.80 ms
64 bytes from 192.168.1.1: icmp_seq=9 ttl=64 time=5.39 ms
64 bytes from 192.168.1.1: icmp_seq=10 ttl=64 time=1.38 ms
64 bytes from 192.168.1.1: icmp_seq=11 ttl=64 time=1.69 ms
^C
--- 192.168.1.1 ping statistics ---
11 packets transmitted, 11 received, 0% packet loss, time 10015ms
rtt min/avg/max/mdev = 1.378/23.619/237.490/67.640 ms
output of iwconfig:

Code: Select all

wlan0     IEEE 802.11  ESSID:"my network"
          Mode:Managed  Frequency:2.457 GHz  Access Point: 60:A4:4C:D4:33:70
          Bit Rate=72.2 Mb/s   Tx-Power=20 dBm
          Retry short limit:7   RTS thr=2347 B   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality=48/70  Signal level=-62 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:95   Missed beacon:0
Speed test is showing WAN bandwidth that should be fine for streaming (so I'd imagine LAN bandwidth wouldn't be a problem)

Code: Select all

Testing download speed................................................................................
Download: 11.78 Mbit/s
Testing upload speed......................................................................................................
Upload: 6.78 Mbit/s
pulseaudio daemon.conf

Code: Select all

 log-level = notice

 avoid-resampling = yes

 default-sample-format = s16le
 default-sample-rate = 44100
 default-sample-channels = 2

 default-fragments = 2
 default-fragment-size-msec = 130
I set the buffer size and default fragment based on:

Code: Select all

I: [pulseaudio] sink.c:     device.buffering.buffer_size = "384000"
I: [pulseaudio] sink.c:     device.buffering.fragment_size = "192000"

default.pa (I'm using load-module module-rtp-recv latency_msec=4000 to load rtp-recv):

Code: Select all

#!/usr/bin/pulseaudio -nF
#
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.

# This startup script is used only if PulseAudio is started per-user
# (i.e. not in system mode)

.fail

### Automatically restore the volume of streams and devices
load-module module-device-restore
load-module module-stream-restore
load-module module-card-restore

### Automatically augment property information from .desktop files
### stored in /usr/share/application
load-module module-augment-properties

### Should be after module-*-restore but before module-*-detect
load-module module-switch-on-port-available

### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
load-module module-udev-detect
.else
### Use the static hardware detection module (for systems that lack udev support)
load-module module-detect
.endif

### Automatically connect sink and source if JACK server is present
.ifexists module-jackdbus-detect.so
.nofail
load-module module-jackdbus-detect channels=2
.fail
.endif

### Automatically load driver modules for Bluetooth hardware
.ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy
.endif

.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
.endif

### Load several protocols
load-module module-dbus-protocol
.ifexists module-esound-protocol-unix.so
load-module module-esound-protocol-unix
.endif
load-module module-native-protocol-unix

### Load the RTP receiver module (also configured via paprefs, see above)
load-module module-rtp-recv latency_msec=4000


### Load additional modules from GSettings. This can be configured with the paprefs tool.
### Please keep in mind that the modules configured by paprefs might conflict with manually
### loaded modules.
.ifexists module-gsettings.so
.nofail
load-module module-gsettings
.fail
.endif

### Automatically restore the default sink/source when changed by the user
### during runtime
### NOTE: This should be loaded as early as possible so that subsequent modules
### that look up the default sink/source get the right value
load-module module-default-device-restore

### Make sure we always have a sink around, even if it is a null sink.
load-module module-always-sink

### Honour intended role device property
load-module module-intended-roles

### Automatically suspend sinks/sources that become idle for too long
load-module module-suspend-on-idle

### If autoexit on idle is enabled we want to make sure we only quit
### when no local session needs us anymore.
.ifexists module-console-kit.so
load-module module-console-kit
.endif
.ifexists module-systemd-login.so
load-module module-systemd-login
.endif

### Enable positioned event sounds
load-module module-position-event-sounds

### Cork music/video streams when a phone stream is active
load-module module-role-cork

### Modules to allow autoloading of filters (such as echo cancellation)
### on demand. module-filter-heuristics tries to determine what filters
### make sense, and module-filter-apply does the heavy-lifting of
### loading modules and rerouting streams.
load-module module-filter-heuristics
load-module module-filter-apply

### Make some devices default
set-default-sink alsa_output.platform-soc_sound.stereo-fallback

epoch1970
Posts: 6511
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Choppy/laggy RTP Streaming with Raspberry Pi Model B Rev 2

Sun May 09, 2021 9:09 am

If the stream breaks up over Ethernet, you have a problem with PA or the OS or the CPU load (actually in the sender or the receiver sides)
If it is solid, your WiFi link isn’t as good and quality not as consistent as you think it is.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Graphics, sound and multimedia”