rPi Plexamp stuttering when playing 192/24 flacs

I wanted to echo the reports in the closed Future of Plexamp thread of stuttering when playing high fidelity files. Stutter does not happen every time, and when it does, playback usually tends to start rough and smooth out as the song goes on.
Pi is a 4 Model B 2GB. Both Pi and plex server are connected via ethernet directly to the router.

3 Likes

I notice the same (FLAC)

Can confirm this as well on Rpi3 connected via ethernet. top shows node using 120% cpu.

If anyone wants to play around: “the audio player will attempt to set the output threads to real-time priority, but Linux appears not to permit normal users to have control over the priority of their threads. So unless you’re running as “root” (or you have “rtprio” enabled in limits.conf), it is possible for the output threads to be starved of CPU.”

Might be worth trying


Thanks for the suggestion. I enabled rtprio and cpu load has decreased quite a bit.

$ cat /etc/security/limits.d/audio.conf  
@audio   -  rtprio     95
@audio   -  memlock    unlimited

Also, I have set the sample rate matching to ‘Strict’.

hw_params does not show my hw:2 device which is Allo Boss2 hat. Instead it shows hw:0 only.

$ ./hw_params
PLAYBACK
        Device: hw:0 (type: HW)
        Access types: MMAP_INTERLEAVED RW_INTERLEAVED
        Formats: U8 S16_LE
        Channels: 1 2 3 4 5 6 7 8
        Sample rates: 8000-192000
        Interrupt interval: 10000-16384000 us
        Buffer time: 416-16384000 us

CAPTURE

Can you explain what you did to enable it? Just add that file?

another pi4 data point related to occasional stuttering

have a pi4 with allo digione hat (spdif coax out)
successfully playing up to and including 24/192 with little/no stuttering (rebooting pi in between runs to make sure the files weren’t already cached)

only once did I hear some minor stuttering during the first ~ minute of a track (and this was while playing back a 24/96 file)

looking at my network connections and streaming data rates 


streaming via wifi from server to plexamp on pi seems to be limited to ~ 46 Mbps 
 looks like I could probably work on getting a better wifi connection to the pi

40 Mbps+ seems like it should be good enough for high bitrate files (and it almost always is in my case) 
 but with a busy network or wireless dropouts, it might cause stuttering more often (and because plexamp fully caches at least the next track, it seems like this type of stuttering would only happen at the start of a playlist, or when directly switching to a new track that’s not already cached)

Correct.

This might imply the stuttering can be caused by high quality resampling leading to CPU overload.

after few more tracks, face stuttering after changing to a new album on the first track, then nothing
really strange, my cpu seems really ok while playing a-ha 24/192

swapping to another album in 24/96 :

stuttering happens after 1 min, then CPU decreases

letting plexamp moving to next track

i then disabled loudness leveling and sweet fades with no visible impact
i then set the rtprio as suggested

@audio   -  rtprio     95
@audio   -  memlock    unlimited

with no visible impact neither

Really strange those cpu usage up and down from 120% (first track of an album) to 15% / 20% letting the other tracks play

Interesting
 when you switch tracks the pre-caching is running, but I wouldn’t have expected that to take up much CPU.

that’s also when I see the highest CPU usage on the pi4 (it just peaks at a lower number than on a pi3)

1 Like

Hi guys; is the issue found or do you want the community to make further testing ? :slight_smile:

Have you tried beta 5? It should have less CPU usage now. If it still stutters, not sure what to suggest at the moment.

you are right. I am now at above 25% CPU playing 24/192 for a first track. I will monitor to see if shuttering happens again. Great job !!!

it stutters again on the second song i play on the same album, i m 115% / 120 CPU

I think it’d be interesting to see how a faster USB-connected storage behaves in comparison to the SD card.
I’ve seen massive differences in benchmarks, with the Pi 4 in particular.

can’t it be possible to have plexamp running 100% in memory only like picoreplayer ?

Plexamp was built from the ground up to be usable with the patchy internet connections of mobile devices. Which means aggressive precaching of all files is a basic working principle. And since hi-res files can get quite large, these cached files won’t fit into RAM either.
So Plexamp has to write relatively large files to storage at every playback start and after track changes. Which is what I suspect is overwhelming the CPU, because the SD slot is not exactly optimized to write and read large amounts data at the same time. (I could be wrong here, but SD slots might produce higher CPU load when accessing them.)

Have you set restrictions on the number of precached tracks and the buffer size?
Try setting these as low as possible.

4 Likes

you re a genius man.
limitating the cache to next track, playing a new album 24/192, the first track plays at 15/20% cpu, the second rise to 120% but really few times, then maintains at 15% :D. It may be the source of the issue, you were right. Allowing to cache on USB drive would be great