(Diet) Pi zero / radio

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
pakikje
Posts: 124
Joined: Fri Nov 11, 2016 3:04 pm

(Diet) Pi zero / radio

Post by pakikje »

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
User avatar
Fourdee
Site Admin
Posts: 2787
Joined: Tue Feb 06, 2007 1:36 pm

Re: (Diet) Pi zero / radio

Post by Fourdee »

Hi,

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

Code: Select all

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.
Try increasing audio buffer size:

Code: Select all

/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.
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
pakikje
Posts: 124
Joined: Fri Nov 11, 2016 3:04 pm

Re: (Diet) Pi zero / radio

Post by pakikje »

Thnx Fourdee! :D

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