(Diet) Pi zero / radio

Hello y’all,

I use a Pi Zero as a wifi-radio-device. (dietpi V6 + mpg123 + textfile with radio-stream-url’s). I am tinkering with it to get a smooth radio-output but usually the radio-stream will stop/continue (at some point/time) or just stop. I have the processor governor on performance. Swapfile auto. I even niced mpg123 but still the audio stream is interrupted from time to time. (sometimes mpg123 will also lose the alsa-device)

Parameters (tested) for mpg123: --smooth --no-gapless -T --aggressive

Any tips ?

ps: below the script i use to change to a diffent radio-url-stream


#!/bin/bash

#Stop the radio if it is running
pidof mpg123 >/dev/null
if [ $? -eq 0 ] ;
then
killall mpg123
sleep 2
fi
#Get the next radio-stream-url (just the line number, textfile contains 7 stream-url’s)
var="$(cat /root/count.txt)"

if [ $var -eq 7 ];
then
var2=1
else
var2=$((var + 1))

fi
#get the next stream-url
VARI="$(sed -n “$var2"p < /root/radiolijst.txt)”
#play the url
/usr/bin/mpg123 --smooth --no-gapless $VARI &
#store the line number that is being played
echo $var2 > /root/count.txt

Hi,

Try using killall (wait), waits for process to finish before continuing, sleep section no longer required after it:

killall -w mpg123



but still the audio stream is interrupted from time to time. (sometimes mpg123 will also lose the alsa-device)

Most likely due to underbuffer. Check dmesg for more info.

http://derpi.tuwien.ac.at/cgi-bin/man/man2html?1+mpg123

Try increasing audio buffer size:

/usr/bin/mpg123 -b 4096 --smooth --no-gapless -T --aggressive

Will increase latency, but should reduce issues.

If problems persist, try reducing the audio sample rate (-2).

Failing that, you could try a realtime kernel, but if the issue is consistently occurring, even that may not be enough. Faster CPU then required.

Thnx Fourdee! :smiley:

And, yep, far more stable now (no interruptions detected so far)