Page 1 of 1

MPD & RPi: gaps in music playback

Posted: Sun Nov 25, 2018 7:03 pm
by peter_b
[PROBLEM]
On a home music player (Raspberry Pi v1, "Music Player Daemon" (MPD)) the playback sometimes stops in the middle of a song/stream/whatever MPD is playing.
These gaps might be from one second up to almost 10 seconds.
Happens arbitrarily, but seems like some buffer ain't happy.

Setup background information:
The music files are stored on a fileserver in the LAN (Debian), served over SMB/CIFS (Samba) to the RPi.
Due to workaround-reasons, the RPi is using a Ethernet-over-Power-Outlet adapter to connect to the server, which also ain't the best setup for having reliable network/streaming conditions.

[SOLUTION]
I've increased the following 2 buffer options in /etc/mpd.conf:
  • audio_buffer_size: 8192 (default: 2048)
  • buffer_before_play: "100%"
It worked! :D
No more playback gaps since then. Even works when playing online streams (online radio) URIs.

Optional information:
I've also tried increasing the ALSA setting "buffer_time" time to a higher value, but ended up reverting to its default, because it had no effect (in my case).

In case you want to adjust ALSA buffer settings, you must do it inside the "audio_output" block for alsa.

For example:

Code: Select all

audio_output {
    type        "alsa"
    name        "ALSA (bcm2835)"
    device      "hw:0,0"
    #auto_resample   "no"
    #auto_format     "no"
    #enabled     "yes"
    buffer_time     "900000"
}
With these values, the playback gaps are greatly reduced, but not fully gone yet. I suspect an unreliable network, but still have hopes to find and tune some buffer to handle even that :)

References:
https://linux.die.net/man/5/mpd.conf