Dropouts with snapclient v0.23 and ALSA backend
I'm running snapserver on a small Intel server and snapclient on various Raspberry PI (2,3,4). Last weekend I started to upgrade the server and clients from snapcast v.0.19. to snapcast v.0.23. On the server I'm using pulse audio with the following snapserver configuration: **source = pipe:///tmp/snapfifo?name=snapcast&mode=read The linux clients use the alsa audio interface and don't have pulse installed. I can't remember any problem with snapclient v.0.19, but with snapclient v.0.23 I was faced with terrible dropouts (see logs). Downgrading the client to v.0.19 fixed the issue. Unfortunately I'm not deep enough in technical details to provide more information. Here is my OS configuration:
Server: Linux cms 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u2 (2019-05-13) x86_64 GNU/Linux --- snapserver & snapclient v.0.23 => no issues Client: Linux amadeus 5.4.83-v7+ #1379 SMP Mon Dec 14 13:08:57 GMT 2020 armv7l GNU/Linux --- snapclient v.0.23 (alsa, no pulse installed) => dropouts, downgrade to snapclient v.0.19 fixed the problem
snapclient v0.23.0: DROPOUTS
Jan 18 15:23:32 amadeus systemd[1]: Started Snapcast client.
Jan 18 15:23:32 amadeus snapclient[929]: Resolving host IP for: cms
Jan 18 15:23:32 amadeus snapclient[929]: Connecting
Jan 18 15:23:32 amadeus snapclient[929]: Connected to 192.168.1.37
Jan 18 15:23:32 amadeus snapclient[929]: My MAC: "b8:27:eb:4c:0b:d0", socket: 9
Jan 18 15:23:33 amadeus snapclient[929]: ServerSettings - buffer: 1000, latency: 0, volume: 0, muted: 1
Jan 18 15:23:33 amadeus snapclient[929]: metadata:{"STREAM":"snapcast"}
Jan 18 15:23:33 amadeus snapclient[929]: Codec: flac, sampleformat: 48000:16:2
Jan 18 15:23:33 amadeus snapclient[929]: Player name: alsa, device: default, description: <none>, idx: 3, sharing mode: unspecified, parameters: <non
Jan 18 15:23:33 amadeus snapclient[929]: Mixer mode: software, parameters: <none>
Jan 18 15:23:33 amadeus snapclient[929]: Sampleformat: 48000:16:2, stream: 48000:16:2
Jan 18 15:23:33 amadeus snapclient[929]: Using buffer_time: 80 ms, fragments: 4
Jan 18 15:23:33 amadeus snapclient[929]: PCM name: default, sample rate: 48000 Hz, channels: 2, buffer time: 250020 us, periods: 2, period time: 1250
Jan 18 15:23:33 amadeus snapclient[929]: No chunks available
Jan 18 15:23:33 amadeus snapclient[929]: Failed to get chunk
Jan 18 15:23:33 amadeus snapclient[929]: diff to server [ms]: 5.73622e+07
Jan 18 15:23:38 amadeus snapclient[929]: No chunk received for 5000ms. Closing ALSA.
Jan 18 15:24:12 amadeus snapclient[929]: ServerSettings - buffer: 1000, latency: 0, volume: 100, muted: 0
Jan 18 15:24:12 amadeus snapclient[929]: PCM name: default, sample rate: 48000 Hz, channels: 2, buffer time: 250020 us, periods: 2, period time: 1250
Jan 18 15:24:17 amadeus snapclient[929]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 5981, delay: 6020, using snd_pcm_avail amd snd_pcm_del
Jan 18 15:24:17 amadeus snapclient[929]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 6020
Jan 18 15:24:18 amadeus snapclient[929]: XRUN while writing to PCM: Broken pipe
Jan 18 15:24:18 amadeus snapclient[929]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 5906, delay: 6095, using snd_pcm_avail amd snd_pcm_del
Jan 18 15:24:18 amadeus snapclient[929]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 6095
Jan 18 15:24:19 amadeus snapclient[929]: pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -102804
Jan 18 15:24:20 amadeus snapclient[929]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 5955, delay: 6037, using snd_pcm_avail amd snd_pcm_del
Jan 18 15:24:20 amadeus snapclient[929]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 6037
Jan 18 15:24:22 amadeus snapclient[929]: pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -100639
Jan 18 15:24:22 amadeus snapclient[929]: XRUN while writing to PCM: Broken pipe
Jan 18 15:24:25 amadeus snapclient[929]: XRUN while writing to PCM: Broken pipe
Jan 18 15:24:26 amadeus snapclient[929]: pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -242589
Jan 18 15:24:27 amadeus snapclient[929]: XRUN while writing to PCM: Broken pipe
Jan 18 15:24:29 amadeus snapclient[929]: pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -243876
Jan 18 15:24:30 amadeus snapclient[929]: XRUN while writing to PCM: Broken pipe
Jan 18 15:24:32 amadeus snapclient[929]: pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -243456
snapclient v0.19.0
2021-01-18 15-31-21 [Info] (browse_callback) (Browser) CACHE_EXHAUSTED
2021-01-18 15-31-21 [Info] (resolve_callback) Service 'Snapcast' of type '_snapcast._tcp' in domain 'local':
2021-01-18 15-31-21 [Info] (resolve_callback) cms.local:1704 (192.168.1.37)
2021-01-18 15-31-21 [Info] (main) Found server 192.168.1.37:1704
2021-01-18 15-31-21 [Info] (main) Latency: 0
2021-01-18 15-31-21 [Notice] (start) Connected to 192.168.1.37
2021-01-18 15-31-21 [Info] (getMacAddress) My MAC: "b8:27:eb:4c:0b:d0", socket: 6
2021-01-18 15-31-21 [Info] (onMessageReceived) ServerSettings - buffer: 1000, latency: 0, volume: 100, muted: 0
metadata:{"STREAM":"snapcast"}
2021-01-18 15-31-21 [Info] (onMessageReceived) Codec: flac
2021-01-18 15-31-21 [Notice] (state) sampleformat: 48000:16:2
2021-01-18 15-31-21 [Info] (Alsa) frames: 6000
2021-01-18 15-31-21 [Info] (Alsa) Resizing buffer from 0 to 48004
2021-01-18 15-31-21 [Info] (Stream) no chunks available
2021-01-18 15-31-21 [Info] (Alsa) Failed to get chunk
2021-01-18 15-31-22 [Info] (worker) diff to server [ms]: 5.73622e+07
2021-01-18 15-31-22 [Info] (Stream) Chunk: -1 -1 -1 -1 1 124 0
2021-01-18 15-31-23 [Info] (Stream) Chunk: -1 -1 -1 -1 4 124 0
2021-01-18 15-31-24 [Info] (Stream) Chunk: 0 0 0 0 12 125 0
2021-01-18 15-31-25 [Info] (Stream) Chunk: 0 0 0 0 20 125 0
2021-01-18 15-31-26 [Info] (Stream) Chunk: -1 0 0 0 28 124 0
2021-01-18 15-31-27 [Info] (Stream) Chunk: 3 0 0 0 36 125 0
2021-01-18 15-31-28 [Info] (Stream) Chunk: 3 2 0 0 44 125 0
2021-01-18 15-31-29 [Info] (Stream) Chunk: 4 3 0 0 52 124 0
2021-01-18 15-31-30 [Info] (Stream) Chunk: 4 3 1 1 60 125 0
From which device are the 0.23 logs? Raspberry Pi 1, 2, 3? What audio device was used? Onboard sound? What OS? (is Linux amadeus an OS?) Can you try the 0.22? There are some changes in 0.23, trying to fix #727 and #722. I was never able to reproduce it and the original issue reporters stopped responding.
You can also try to change the player parameters (buffer_time and fragments):
snapclient --logfilter *:debug --player alsa:?
Options are a comma separated list of:
"buffer_time=<total buffer size [ms]>" - default 80, min 10
"fragments=<number of buffers>" - default 4, min 2
E.g. snapclient --logfilter *:debug --player alsa:buffer_time=50,fragments=2
Hi badaix, thanks for your fast reply! First the answers to your questions:
amadeus is the hostname of the player running snapclient. It's a Raspberry Pi 3 Model B, 1 GB RAM (a02082) No LSB modules are available. Distributor ID: Raspbian Description: Raspbian GNU/Linux 10 (buster) Release: 10 Codename: buster
All reported logs were created on that Raspberry Pi 3. My audio device is a HifiBerry DAC. aplay -l **** List of PLAYBACK Hardware Devices **** card 0: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 [HifiBerry DAC HiFi pcm5102a-hifi-0] Subdevices: 1/1 Subdevice #0: subdevice #0
Trying snapclient v.0.23 or v.0.22 with a smaller 'buffer_time' still produce dropouts:
snapclient --logfilter *:debug --player alsa:buffer_time=50,fragments=2 -h cms
pi@amadeus:~/downloads $ snapclient --logfilter *:debug --player alsa:buffer_time=50,fragments=2 -h cms
2021-01-19 13-36-11.797 [Info] (Connection) Resolving host IP for: cms
2021-01-19 13-36-11.861 [Info] (Connection) Connecting
2021-01-19 13-36-11.865 [Notice] (Connection) Connected to 192.168.1.37
2021-01-19 13-36-11.865 [Info] (Connection) My MAC: "b8:27:eb:4c:0b:d0", socket: 8
2021-01-19 13-36-12.073 [Debug] (Connection) outstanding async_write
2021-01-19 13-36-12.078 [Info] (Controller) ServerSettings - buffer: 1000, latency: 0, volume: 100, muted: 0
metadata:{"STREAM":"snapcast"}
2021-01-19 13-36-12.079 [Info] (Controller) Codec: flac, sampleformat: 44100:16:2
2021-01-19 13-36-12.079 [Info] (Player) Player name: alsa, device: default, description: <none>, idx: 3, sharing mode: unspecified, parameters: buffer_time=50,fragments=2
2021-01-19 13-36-12.079 [Info] (Player) Mixer mode: software, parameters: <none>
2021-01-19 13-36-12.079 [Info] (Player) Sampleformat: 44100:16:2, stream: 44100:16:2
2021-01-19 13-36-12.083 [Debug] (Alsa) PCM name: default
2021-01-19 13-36-12.083 [Debug] (Alsa) PCM state: PREPARED
2021-01-19 13-36-12.083 [Debug] (Alsa) channels: 2
2021-01-19 13-36-12.083 [Debug] (Alsa) rate: 44100 bps
2021-01-19 13-36-12.083 [Debug] (Alsa) frames: 5512
2021-01-19 13-36-12.083 [Debug] (Alsa) period time: 125000
2021-01-19 13-36-12.083 [Debug] (Alsa) setVolume exp with base 10: 1 => 1
2021-01-19 13-36-12.083 [Debug] (Alsa) Resizing buffer from 0 to 44100
2021-01-19 13-36-12.084 [Info] (Stream) no chunks available
2021-01-19 13-36-12.084 [Info] (Alsa) Failed to get chunk
2021-01-19 13-36-12.343 [Info] (Controller) diff to server [ms]: 6.789e+07
2021-01-19 13-36-12.888 [Debug] (Stream) Silent frames: 3003, frames: 5512, age: -68.114
2021-01-19 13-36-13.013 [Debug] (Stats) Chunk: 0 0 0 0 1 124 0
2021-01-19 13-36-14.013 [Debug] (Stats) Chunk: 0 0 0 0 9 125 0
2021-01-19 13-36-15.013 [Debug] (Stats) Chunk: 1 0 0 0 17 125 0
2021-01-19 13-36-16.013 [Debug] (Stats) Chunk: 2 1 1 1 25 125 0
2021-01-19 13-36-17.013 [Debug] (Stats) Chunk: 3 2 1 1 33 125 0
2021-01-19 13-36-18.013 [Debug] (Stats) Chunk: 4 3 2 2 41 125 0
2021-01-19 13-36-19.013 [Debug] (Stats) Chunk: 4 4 2 2 49 124 0
2021-01-19 13-36-20.023 [Debug] (Stats) Chunk: 5 4 2 2 57 124 0
2021-01-19 13-36-21.044 [Debug] (Stats) Chunk: 5 5 3 3 65 124 0
2021-01-19 13-36-22.064 [Debug] (Stats) Chunk: 8 6 3 3 73 125 0
2021-01-19 13-36-23.095 [Debug] (Stats) Chunk: 7 7 4 4 81 124 0
2021-01-19 13-36-23.869 [Error] (Alsa) XRUN: Broken pipe
2021-01-19 13-36-24.013 [Debug] (Stats) Chunk: -2427 8 4 4 89 111 0
2021-01-19 13-36-25.014 [Debug] (Stats) Chunk: -2426 7 4 4 97 124 0
2021-01-19 13-36-25.273 [Info] (Stream) pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -242576
2021-01-19 13-36-25.523 [Debug] (Stream) Silent frames: 5183, frames: 5512, age: -117.55
2021-01-19 13-36-26.023 [Debug] (Stats) Chunk: 0 0 0 0 4 125 0
2021-01-19 13-36-27.034 [Debug] (Stats) Chunk: 0 0 0 0 12 124 0
2021-01-19 13-36-28.054 [Debug] (Stats) Chunk: 0 0 0 0 20 124 0
2021-01-19 13-36-29.094 [Debug] (Stats) Chunk: 1 0 0 0 28 115 0
2021-01-19 13-36-29.875 [Warn] (Alsa) snd_pcm_avail_delay failed: Broken pipe, avail: 5504, delay: 5513, retrying.
2021-01-19 13-36-29.885 [Warn] (Alsa) snd_pcm_avail_delay failed again: Broken pipe, avail: 5504, delay: 5513, using snd_pcm_avail and snd_pcm_delay.
2021-01-19 13-36-29.885 [Warn] (Alsa) snd_pcm_avail and snd_pcm_delay failed: Broken pipe, avail: -32, delay: 5513
2021-01-19 13-36-30.138 [Debug] (Stats) Chunk: -895 1 0 0 35 12 0
2021-01-19 13-36-31.013 [Debug] (Stats) Chunk: -894 0 0 0 42 125 0
2021-01-19 13-36-31.388 [Info] (Stream) pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -89439
2021-01-19 13-36-31.513 [Debug] (Stream) Silent frames: 3943, frames: 5512, age: -89.427
2021-01-19 13-36-32.013 [Debug] (Stats) Chunk: 0 0 0 0 4 125 0
I tested also snapclient v.0.21. This version is running fine, witout any dropouts. So, it seem´s that the cause is related to a change in Version v.0.22.
thanks, but I don't think that sticking to an older version is a solution to this problem.
There are three parameters involved for alsa:
- fragment time
- fragments
- buffer time
where
buffer timeis the total audio buffer "size" (= time from passing audio to the PCM device, until it's audible).- the
buffer timeis split intofragments*fragment time
There is always one fragment rendered, while another fragment is filled with new data that will be rendered later. For smooth playback without dropouts you will need at least two fragments, which actually seems not enough, so 3 or 4 are recommended. I can reproduce dropouts if I configure two fragments, but I cannot reproduce your problem with my HiFiBerry DAC+ devices, nor with the integrated RPi PCM devices.
Your issue seems to be that Snapclient requests 4 fragments and 80ms buffer time (and expects to get 20ms fragments, but that's left to alsa and the hardware):
Jan 18 15:23:33 amadeus snapclient[929]: Using buffer_time: 80 ms, fragments: 4
Jan 18 15:23:33 amadeus snapclient[929]: PCM name: default, sample rate: 48000 Hz, channels: 2, buffer time: 250020 us, periods: 2, period time: 1250
What you get is 250ms buffer and 2 fragments (= periods), 125ms each.
The differences between Snapclient versions are:
- 0.21: Requested 4 fragments with a fragment size of 30ms => buffer time = 120ms
- 0.22: Requested 4 fragments with a fragment size of 15ms => buffer time = 60ms
- 0.23: Requests X fragments (default 4) and buffer time Y (default 80) => fragment size 20ms
A request is just a request and alsa will try to apply them or use values close to the configured ones.
Can you test the 0.23 with buffer_time=120,fragments=4? This should result in 30ms fragments as they were used in 0.21
Using buffer_time=120,fragments=4 leads to a reduction of dropouts, but there are still scattered dropouts.
snapclient --logfilter *:debug --player alsa:buffer_time=120,fragments=4 -h cms
pi@amadeus:~/downloads $ snapclient --logfilter *:debug --player alsa:buffer_time=120,fragments=4 -h cms
2021-01-20 07-30-48.556 [Info] (Connection) Resolving host IP for: cms
2021-01-20 07-30-48.584 [Info] (Connection) Connecting
2021-01-20 07-30-48.588 [Notice] (Connection) Connected to 192.168.1.37
2021-01-20 07-30-48.588 [Info] (Connection) My MAC: "b8:27:eb:4c:0b:d0", socket: 8
2021-01-20 07-30-48.802 [Debug] (Connection) outstanding async_write
2021-01-20 07-30-48.806 [Info] (Controller) ServerSettings - buffer: 1000, latency: 0, volume: 100, muted: 0
metadata:{"STREAM":"snapcast"}
2021-01-20 07-30-48.808 [Info] (Controller) Codec: flac, sampleformat: 44100:16:2
2021-01-20 07-30-48.808 [Info] (Player) Player name: alsa, device: default, description: <none>, idx: 3, sharing mode: unspecified, parameters: buffer_time=120,fragments=4
2021-01-20 07-30-48.808 [Info] (Player) Mixer mode: software, parameters: <none>
2021-01-20 07-30-48.808 [Info] (Player) Sampleformat: 44100:16:2, stream: 44100:16:2
2021-01-20 07-30-48.808 [Info] (Alsa) Using buffer_time: 120 ms, fragments: 4
2021-01-20 07-30-48.812 [Info] (Alsa) PCM name: default, sample rate: 44100 Hz, channels: 2, buffer time: 250000 us, periods: 2, period time: 125000 us, period frames: 5512
2021-01-20 07-30-48.813 [Debug] (Alsa) setVolume exp with base 10: 1 => 1
2021-01-20 07-30-48.813 [Debug] (Alsa) Resizing buffer from 0 to 44100
2021-01-20 07-30-48.813 [Info] (Stream) No chunks available
2021-01-20 07-30-48.813 [Info] (Alsa) Failed to get chunk
2021-01-20 07-30-48.966 [Info] (Controller) diff to server [ms]: 1.32083e+08
2021-01-20 07-30-49.559 [Debug] (Stream) Silent frames: 4128, frames: 5512, age: -93.626
2021-01-20 07-30-49.685 [Debug] (Stats) Chunk: 0 0 0 0 1 125 0
2021-01-20 07-30-50.060 [Debug] (Stats) Chunk: 0 0 0 0 4 125 0
2021-01-20 07-30-51.060 [Debug] (Stats) Chunk: 0 0 0 0 12 125 0
2021-01-20 07-30-52.060 [Debug] (Stats) Chunk: 1 0 0 0 20 125 0
2021-01-20 07-30-53.060 [Debug] (Stats) Chunk: 2 1 1 1 28 125 0
2021-01-20 07-30-54.060 [Debug] (Stats) Chunk: 3 2 1 1 36 125 0
2021-01-20 07-30-55.060 [Debug] (Stats) Chunk: 4 3 2 2 44 125 0
2021-01-20 07-30-56.060 [Debug] (Stats) Chunk: 5 4 2 2 52 125 0
2021-01-20 07-30-57.059 [Debug] (Stats) Chunk: 5 4 2 2 60 125 0
2021-01-20 07-30-58.060 [Debug] (Stats) Chunk: 6 5 3 3 68 125 0
2021-01-20 07-30-59.059 [Debug] (Stats) Chunk: 7 6 3 3 76 125 0
2021-01-20 07-31-00.059 [Debug] (Stats) Chunk: 8 7 4 4 84 125 0
2021-01-20 07-31-01.060 [Debug] (Stats) Chunk: 9 8 4 4 92 125 0
2021-01-20 07-31-02.059 [Debug] (Stats) Chunk: 10 9 4 4 100 125 0
2021-01-20 07-31-03.059 [Debug] (Stats) Chunk: 9 9 5 5 108 125 -7
2021-01-20 07-31-04.059 [Debug] (Stats) Chunk: 7 9 6 5 116 125 -11
2021-01-20 07-31-05.059 [Debug] (Stats) Chunk: 5 8 6 5 124 125 -13
2021-01-20 07-31-06.059 [Debug] (Stats) Chunk: 3 6 6 5 132 125 -13
2021-01-20 07-31-07.059 [Debug] (Stats) Chunk: 1 4 6 5 140 125 -14
2021-01-20 07-31-08.059 [Debug] (Stats) Chunk: 0 2 6 5 148 125 -8
2021-01-20 07-31-09.059 [Debug] (Stats) Chunk: 0 0 6 4 156 125 -2
2021-01-20 07-31-10.059 [Debug] (Stats) Chunk: 0 0 6 4 164 125 -3
2021-01-20 07-31-11.059 [Debug] (Stats) Chunk: 1 0 6 4 172 125 -1
2021-01-20 07-31-12.059 [Debug] (Stats) Chunk: 0 0 4 4 180 125 -7
2021-01-20 07-31-13.059 [Debug] (Stats) Chunk: 0 0 2 3 188 125 -4
2021-01-20 07-31-14.059 [Debug] (Stats) Chunk: 0 0 1 3 196 125 -2
2021-01-20 07-31-15.059 [Debug] (Stats) Chunk: 1 0 1 3 204 125 -1
2021-01-20 07-31-16.059 [Debug] (Stats) Chunk: 1 1 1 2 212 125 -2
2021-01-20 07-31-17.059 [Debug] (Stats) Chunk: 2 1 1 2 220 125 -3
2021-01-20 07-31-18.059 [Debug] (Stats) Chunk: 2 2 1 2 228 125 -2
2021-01-20 07-31-19.059 [Debug] (Stats) Chunk: 2 2 1 2 236 125 -2
2021-01-20 07-31-20.059 [Debug] (Stats) Chunk: 2 2 1 2 244 125 -2
2021-01-20 07-31-21.059 [Debug] (Stats) Chunk: 3 2 1 2 252 125 -2
2021-01-20 07-31-22.059 [Debug] (Stats) Chunk: 3 3 1 2 260 125 -3
2021-01-20 07-31-23.059 [Debug] (Stats) Chunk: 3 3 2 2 268 125 -2
2021-01-20 07-31-24.059 [Debug] (Stats) Chunk: 3 3 2 2 276 125 -4
2021-01-20 07-31-25.059 [Debug] (Stats) Chunk: 3 3 2 3 284 125 -5
2021-01-20 07-31-26.059 [Debug] (Stats) Chunk: 3 3 2 3 292 125 -4
2021-01-20 07-31-26.941 [Error] (Alsa) XRUN while writing to PCM: Broken pipe
2021-01-20 07-31-27.184 [Debug] (Stats) Chunk: -2424 3 3 3 301 12 -5
2021-01-20 07-31-28.059 [Debug] (Stats) Chunk: -2424 2 3 3 308 125 0
2021-01-20 07-31-28.434 [Info] (Stream) pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -242389
2021-01-20 07-31-28.684 [Debug] (Stream) Silent frames: 5175, frames: 5512, age: -117.357
2021-01-20 07-31-29.059 [Debug] (Stats) Chunk: 0 0 0 0 3 125 0
2021-01-20 07-31-30.059 [Debug] (Stats) Chunk: 0 0 0 0 11 125 0
2021-01-20 07-31-31.059 [Debug] (Stats) Chunk: 1 0 0 0 19 125 0
2021-01-20 07-31-32.059 [Debug] (Stats) Chunk: 2 1 0 0 27 125 0
2021-01-20 07-31-33.059 [Debug] (Stats) Chunk: 3 2 1 1 35 125 0
2021-01-20 07-31-34.064 [Debug] (Stats) Chunk: 3 2 1 1 43 125 0
2021-01-20 07-31-35.064 [Debug] (Stats) Chunk: 4 3 2 2 51 125 0
2021-01-20 07-31-36.064 [Debug] (Stats) Chunk: 5 4 2 2 59 125 0
2021-01-20 07-31-37.064 [Debug] (Stats) Chunk: 6 5 2 2 67 125 0
2021-01-20 07-31-38.064 [Debug] (Stats) Chunk: 7 6 3 3 75 125 0
2021-01-20 07-31-39.064 [Debug] (Stats) Chunk: 8 7 3 3 83 125 0
2021-01-20 07-31-39.449 [Warn] (Alsa) snd_pcm_avail_delay failed: Broken pipe (-32), avail: 5482, delay: 5543, using snd_pcm_avail amd snd_pcm_delay.
2021-01-20 07-31-39.450 [Warn] (Alsa) snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 5543
2021-01-20 07-31-40.059 [Debug] (Stats) Chunk: -1036 7 3 3 90 125 0
2021-01-20 07-31-40.934 [Info] (Stream) pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -103546
2021-01-20 07-31-41.059 [Debug] (Stream) Silent frames: 4566, frames: 5512, age: -103.55
2021-01-20 07-31-41.184 [Debug] (Stats) Chunk: 0 0 0 0 1 125 0
2021-01-20 07-31-42.059 [Debug] (Stats) Chunk: 0 0 0 0 8 125 0
2021-01-20 07-31-43.059 [Debug] (Stats) Chunk: 1 0 0 0 16 125 0
2021-01-20 07-31-44.059 [Debug] (Stats) Chunk: 2 1 1 1 24 125 0
Thanks for testing this. It seems that alsa is still applying the same settings, especially 2 fragments (periods):
2021-01-20 07-30-48.812 [Info] (Alsa) PCM name: default, sample rate: 44100 Hz, channels: 2, buffer time: 250000 us, periods: 2, period time: 125000 us, period frames: 5512
I've now changed d03a9eae684eac10ec3cf8035cc1d9867361c5a5 the alsa player to set the period time instead of the buffer time, as it was done in v0.21, you can find a snapshot debian package in actions
Dear Johannes,
GREAT WORK!
Running the pached version, I can't hear anymore dropouts and the log also don't show any hicups. Thanks a lot! For the case that you are looking for support in testing, feel free to send me a request. I'm willing to spend time for support as far as possible.
pi@amadeus:~/downloads $ snapclient -v snapclient v0.23.0 Copyright (C) 2014-2020 BadAix ([email protected]). License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
Written by Johannes M. Pohl.
pi@amadeus:~ $ snapclient --logfilter *:debug -h cms --latency=3 --player=alsa
2021-01-21 10-51-49.481 [Info] (Connection) Resolving host IP for: cms
2021-01-21 10-51-49.508 [Info] (Connection) Connecting
2021-01-21 10-51-49.514 [Notice] (Connection) Connected to 192.168.1.37
2021-01-21 10-51-49.514 [Info] (Connection) My MAC: "b8:27:eb:4c:0b:d0", socket: 8
2021-01-21 10-51-49.724 [Debug] (Connection) outstanding async_write
2021-01-21 10-51-50.034 [Info] (Controller) ServerSettings - buffer: 1000, latency: 0, volume: 100, muted: 0
metadata:{"STREAM":"snapcast"}
2021-01-21 10-51-50.034 [Info] (Controller) Codec: flac, sampleformat: 44100:16:2
2021-01-21 10-51-50.035 [Info] (Player) Player name: alsa, device: default, description: <none>, idx: 3, sharing mode: unspecified, parameters: <none>
2021-01-21 10-51-50.035 [Info] (Player) Mixer mode: software, parameters: <none>
2021-01-21 10-51-50.035 [Info] (Player) Sampleformat: 44100:16:2, stream: 44100:16:2
2021-01-21 10-51-50.035 [Info] (Alsa) Using buffer_time: 80 ms, fragments: 4
2021-01-21 10-51-50.038 [Info] (Alsa) Period time too small, changing from 20000 to 125000
2021-01-21 10-51-50.039 [Info] (Alsa) PCM name: default, sample rate: 44100 Hz, channels: 2, buffer time: 374988 us, periods: 3, period time: 125000 us, period frames: 5512
2021-01-21 10-51-50.040 [Debug] (Alsa) setVolume exp with base 10: 1 => 1
2021-01-21 10-51-50.040 [Debug] (Alsa) Resizing buffer from 0 to 66148
2021-01-21 10-51-50.040 [Info] (Stream) No chunks available
2021-01-21 10-51-50.040 [Info] (Alsa) Failed to get chunk
2021-01-21 10-51-50.536 [Debug] (Stream) Silent frames: 1684, frames: 5512, age: -38.189
2021-01-21 10-51-51.037 [Debug] (Stats) Chunk: 16 16 16 16 4 249 0
2021-01-21 10-51-51.604 [Info] (Controller) diff to server [ms]: 2.31431e+08
2021-01-21 10-51-52.036 [Debug] (Stats) Chunk: 1 1 1 1 11 250 0
2021-01-21 10-51-53.036 [Debug] (Stats) Chunk: 2 2 2 2 19 249 0
2021-01-21 10-51-54.036 [Debug] (Stats) Chunk: 3 2 2 2 27 249 0
2021-01-21 10-51-55.036 [Debug] (Stats) Chunk: 4 3 3 3 34 250 0
2021-01-21 10-51-56.036 [Debug] (Stats) Chunk: -10 4 3 3 42 249 0
2021-01-21 10-51-57.161 [Debug] (Stats) Chunk: -8 4 2 2 50 133 0
2021-01-21 10-51-58.036 [Debug] (Stats) Chunk: -7 -8 2 2 57 250 0
2021-01-21 10-51-59.036 [Debug] (Stats) Chunk: -6 -7 1 1 64 250 0
2021-01-21 10-52-00.036 [Debug] (Stats) Chunk: 9 -6 2 2 71 135 0
2021-01-21 10-52-01.036 [Debug] (Stats) Chunk: 9 8 2 2 79 250 0
2021-01-21 10-52-02.036 [Debug] (Stats) Chunk: 10 9 3 3 86 249 0
2021-01-21 10-52-03.036 [Debug] (Stats) Chunk: 11 10 3 3 94 249 0
2021-01-21 10-52-04.036 [Debug] (Stats) Chunk: 12 11 4 4 101 250 0
2021-01-21 10-52-05.036 [Debug] (Stats) Chunk: 12 12 4 4 109 250 -8
2021-01-21 10-52-06.036 [Debug] (Stats) Chunk: 11 12 8 4 117 250 -9
2021-01-21 10-52-07.037 [Debug] (Stats) Chunk: 8 11 9 8 125 249 -17
2021-01-21 10-52-08.036 [Debug] (Stats) Chunk: 20 10 9 8 132 250 -20
2021-01-21 10-52-09.036 [Debug] (Stats) Chunk: 16 16 10 8 140 250 -20
2021-01-21 10-52-10.036 [Debug] (Stats) Chunk: 12 16 11 9 148 250 -22
2021-01-21 10-52-11.036 [Debug] (Stats) Chunk: 8 14 11 9 155 250 -22
2021-01-21 10-52-12.036 [Debug] (Stats) Chunk: 4 9 11 9 163 250 -22
2021-01-21 10-52-13.036 [Debug] (Stats) Chunk: 32 8 11 9 171 250 -22
2021-01-21 10-52-14.036 [Debug] (Stats) Chunk: 28 30 12 9 179 250 -22
2021-01-21 10-52-15.036 [Debug] (Stats) Chunk: 27 29 12 9 187 250 -22
2021-01-21 10-52-16.036 [Debug] (Stats) Chunk: 23 27 13 10 195 250 -22
2021-01-21 10-52-17.036 [Debug] (Stats) Chunk: 21 24 16 10 203 250 -22
2021-01-21 10-52-18.036 [Debug] (Stats) Chunk: 17 21 18 10 211 250 -22
2021-01-21 10-52-19.036 [Debug] (Stats) Chunk: 18 18 18 11 219 250 -22
2021-01-21 10-52-20.036 [Debug] (Stats) Chunk: 14 16 18 11 227 250 -22
2021-01-21 10-52-21.036 [Debug] (Stats) Chunk: 10 14 17 11 235 250 -22
2021-01-21 10-52-22.036 [Debug] (Stats) Chunk: 7 11 17 11 243 250 -22
2021-01-21 10-52-23.036 [Debug] (Stats) Chunk: 3 9 17 11 251 250 -22
2021-01-21 10-52-24.036 [Debug] (Stats) Chunk: 0 5 17 10 258 250 -20
2021-01-21 10-52-25.036 [Debug] (Stats) Chunk: 0 0 16 10 266 250 0
2021-01-21 10-52-26.036 [Debug] (Stats) Chunk: 0 0 14 10 274 250 -5
2021-01-21 10-52-27.036 [Debug] (Stats) Chunk: 0 0 12 10 282 250 0
2021-01-21 10-52-28.036 [Debug] (Stats) Chunk: 1 0 9 9 290 250 0
2021-01-21 10-52-29.036 [Debug] (Stats) Chunk: 1 0 5 9 298 250 -8
2021-01-21 10-52-30.036 [Debug] (Stats) Chunk: 1 1 1 9 306 250 -5
2021-01-21 10-52-31.036 [Debug] (Stats) Chunk: 0 0 1 9 314 250 -2
2021-01-21 10-52-32.036 [Debug] (Stats) Chunk: 2 0 1 8 322 250 -1
2021-01-21 10-52-33.036 [Debug] (Stats) Chunk: 2 2 1 8 330 250 0
2021-01-21 10-52-34.036 [Debug] (Stats) Chunk: 6 2 1 8 338 250 0
2021-01-21 10-52-35.036 [Debug] (Stats) Chunk: 7 3 1 7 346 250 0
2021-01-21 10-52-36.036 [Debug] (Stats) Chunk: 7 6 1 7 354 250 0
2021-01-21 10-52-37.036 [Debug] (Stats) Chunk: 9 7 1 7 362 250 0
2021-01-21 10-52-38.036 [Debug] (Stats) Chunk: 9 9 2 8 370 250 -2
2021-01-21 10-52-39.036 [Debug] (Stats) Chunk: 9 9 2 8 378 250 -4
2021-01-21 10-52-40.036 [Debug] (Stats) Chunk: 9 9 3 8 386 250 -5
2021-01-21 10-52-41.036 [Debug] (Stats) Chunk: 8 9 6 8 394 250 -6
Sounds good (literally) :)
There is still a difference between v0.19 and v0.23.dev: the number next to the end is 125 vs 250. This number is the playout time [ms] for the currently requested audio chunk, which will be a multiple of the fragment size (in your case the fragment size seems to be fixed to 125ms (period time: 125000). So it seems that the v0.19 uses one fragment less than the 0.23:
v0.19:
2021-01-18 15-31-27 [Info] (Stream) Chunk: 3 0 0 0 36 125 0
v0.23.dev:
2021-01-21 10-52-34.036 [Debug] (Stats) Chunk: 6 2 1 8 338 250 0
I want to accept your offer to test one more development version (in actions with the commit message Set buffer time instead of periods). This version dumps the raw parameters of the audio device to the debug log (such as min and max fragment size) and will work like the 0.19 (requesting fragment size and buffer size, instead of fragment size and number of fragments from alsa). I will probably revert this change, but would like to see the debug log output of this version with the default settings buffer_time=80,fragments=4 and with the v0.19 settings buffer_time=120,fragments=4
Thanks in advance
PS: the version number of this snapshot is set to 0.23.100
Ok, here we are ...
pi@amadeus:~/downloads $ snapclient -v snapclient v0.23.100, built Jan 9 2021
pi@amadeus:~/downloads $ snapclient --user snapclient:snapclient --logfilter *:debug -h cms --player alsa
2021-01-22 06-50-45.650 [Info] (Connection) Resolving host IP for: cms
2021-01-22 06-50-45.656 [Info] (Connection) Connecting
2021-01-22 06-50-45.674 [Notice] (Connection) Connected to 192.168.1.37
2021-01-22 06-50-45.675 [Info] (Connection) My MAC: "80:1f:02:8a:4f:26", socket: 8
2021-01-22 06-50-45.880 [Debug] (Connection) outstanding async_write
2021-01-22 06-50-45.885 [Info] (Controller) ServerSettings - buffer: 1000, latency: 0, volume: 100, muted: 0
metadata:{"STREAM":"snapcast"}
2021-01-22 06-50-45.885 [Info] (Controller) Codec: flac, sampleformat: 44100:16:2
2021-01-22 06-50-45.885 [Info] (Player) Player name: alsa, device: default, description: <none>, idx: 3, sharing mode: unspecified, parameters: <none>
2021-01-22 06-50-45.885 [Info] (Player) Mixer mode: software, parameters: <none>
2021-01-22 06-50-45.885 [Info] (Player) Sampleformat: 44100:16:2, stream: 44100:16:2
2021-01-22 06-50-45.885 [Info] (Alsa) Using buffer_time: 80 ms, fragments: 4
2021-01-22 06-50-45.888 [Debug] (Alsa) ACCESS: MMAP_INTERLEAVED MMAP_NONINTERLEAVED MMAP_COMPLEX RW_INTERLEAVED RW_NONINTERLEAVED
2021-01-22 06-50-45.888 [Debug] (Alsa) FORMAT: S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE MU_LAW A_LAW IMA_ADPCM S20_LE S20_BE U20_LE U20_BE S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE U18_3BE
2021-01-22 06-50-45.888 [Debug] (Alsa) SUBFORMAT: STD
2021-01-22 06-50-45.888 [Debug] (Alsa) SAMPLE_BITS: [4 64]
2021-01-22 06-50-45.888 [Debug] (Alsa) FRAME_BITS: [4 640000]
2021-01-22 06-50-45.888 [Debug] (Alsa) CHANNELS: [1 10000]
2021-01-22 06-50-45.888 [Debug] (Alsa) RATE: [4000 4294967295)
2021-01-22 06-50-45.888 [Debug] (Alsa) PERIOD_TIME: 125000
2021-01-22 06-50-45.888 [Debug] (Alsa) PERIOD_SIZE: [500 536870912)
2021-01-22 06-50-45.888 [Debug] (Alsa) PERIOD_BYTES: [250 4294967295)
2021-01-22 06-50-45.888 [Debug] (Alsa) PERIODS: (0 3221226)
2021-01-22 06-50-45.888 [Debug] (Alsa) BUFFER_TIME: [1 4294967295]
2021-01-22 06-50-45.888 [Debug] (Alsa) BUFFER_SIZE: [1000 1610612735]
2021-01-22 06-50-45.888 [Debug] (Alsa) BUFFER_BYTES: [500 4294967295]
2021-01-22 06-50-45.888 [Debug] (Alsa) TICK_TIME: ALL
2021-01-22 06-50-45.891 [Info] (Alsa) PCM name: default, sample rate: 44100 Hz, channels: 2, buffer time: 250000 us, periods: 2, period time: 125000 us, period frames: 5512
2021-01-22 06-50-45.891 [Debug] (Alsa) setVolume exp with base 10: 1 => 1
2021-01-22 06-50-45.891 [Debug] (Alsa) Resizing buffer from 0 to 44100
2021-01-22 06-50-45.892 [Info] (Stream) No chunks available
2021-01-22 06-50-45.892 [Info] (Alsa) Failed to get chunk
2021-01-22 06-50-46.637 [Debug] (Stream) Silent frames: 3713, frames: 5512, age: -84.204
2021-01-22 06-50-46.645 [Info] (Controller) diff to server [ms]: 3.02419e+08
2021-01-22 06-50-46.762 [Debug] (Stats) Chunk: -3 -3 -3 -3 1 125 0
2021-01-22 06-50-47.012 [Debug] (Stats) Chunk: -2 -2 -2 -2 3 125 0
2021-01-22 06-50-48.012 [Debug] (Stats) Chunk: -1 -2 -2 -2 11 125 0
2021-01-22 06-50-49.012 [Debug] (Stats) Chunk: 0 -1 -1 -1 19 125 0
2021-01-22 06-50-50.012 [Debug] (Stats) Chunk: 0 0 -1 -1 27 125 0
2021-01-22 06-50-51.012 [Debug] (Stats) Chunk: 0 0 0 0 35 125 0
2021-01-22 06-50-52.012 [Debug] (Stats) Chunk: 1 0 0 0 43 125 0
2021-01-22 06-50-53.012 [Debug] (Stats) Chunk: -1 1 0 0 51 125 0
2021-01-22 06-50-54.012 [Debug] (Stats) Chunk: -1 0 0 0 59 125 0
2021-01-22 06-50-55.012 [Debug] (Stats) Chunk: -2 -1 0 0 67 125 0
2021-01-22 06-50-56.012 [Debug] (Stats) Chunk: 0 -1 0 0 75 125 0
2021-01-22 06-50-57.012 [Debug] (Stats) Chunk: -1 0 0 0 83 125 0
2021-01-22 06-50-58.012 [Debug] (Stats) Chunk: 0 0 0 0 91 125 0
2021-01-22 06-50-59.012 [Debug] (Stats) Chunk: -1 0 0 0 99 125 0
2021-01-22 06-51-00.012 [Debug] (Stats) Chunk: 1 0 0 0 107 125 0
2021-01-22 06-51-01.012 [Debug] (Stats) Chunk: 2 0 0 0 115 125 0
2021-01-22 06-51-01.519 [Error] (Alsa) XRUN while writing to PCM: Broken pipe
2021-01-22 06-51-02.012 [Debug] (Stats) Chunk: -2426 1 0 0 123 125 0
2021-01-22 06-51-03.012 [Info] (Stream) pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -242579
2021-01-22 06-51-03.012 [Debug] (Stats) Chunk: -2426 -2426 0 0 131 125 0
2021-01-22 06-51-03.262 [Debug] (Stream) Silent frames: 5185, frames: 5512, age: -117.59
2021-01-22 06-51-04.012 [Debug] (Stats) Chunk: 0 0 0 0 6 125 0
2021-01-22 06-51-05.012 [Debug] (Stats) Chunk: 1 0 0 0 14 125 0
2021-01-22 06-51-06.012 [Debug] (Stats) Chunk: 0 0 0 0 22 125 0
2021-01-22 06-51-07.012 [Debug] (Stats) Chunk: 3 1 0 0 30 125 0
2021-01-22 06-51-08.012 [Debug] (Stats) Chunk: 1 1 0 0 38 125 0
2021-01-22 06-51-09.012 [Debug] (Stats) Chunk: 2 1 1 1 46 125 0
2021-01-22 06-51-10.012 [Debug] (Stats) Chunk: 1 1 1 1 54 125 0
2021-01-22 06-51-11.012 [Debug] (Stats) Chunk: 2 2 1 1 62 125 0
2021-01-22 06-51-12.012 [Debug] (Stats) Chunk: 3 2 1 1 70 125 0
2021-01-22 06-51-13.012 [Debug] (Stats) Chunk: 4 3 1 1 78 125 0
2021-01-22 06-51-14.012 [Debug] (Stats) Chunk: 4 3 2 2 86 125 0
2021-01-22 06-51-15.012 [Debug] (Stats) Chunk: 5 4 2 2 94 125 0
2021-01-22 06-51-16.012 [Debug] (Stats) Chunk: 6 5 2 2 102 125 0
2021-01-22 06-51-17.012 [Debug] (Stats) Chunk: 5 5 2 2 110 125 -4
2021-01-22 06-51-18.017 [Debug] (Stats) Chunk: 5 5 3 2 118 125 -5
2021-01-22 06-51-18.651 [Warn] (Alsa) snd_pcm_avail_delay failed: Broken pipe (-32), avail: 5453, delay: 5564, using snd_pcm_avail amd snd_pcm_delay.
2021-01-22 06-51-18.652 [Warn] (Alsa) snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 5564
2021-01-22 06-51-19.012 [Debug] (Stats) Chunk: -1044 5 3 2 125 125 -5
2021-01-22 06-51-20.022 [Debug] (Stats) Chunk: -1043 -1043 3 2 133 120 0
2021-01-22 06-51-20.147 [Info] (Stream) pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -104389
2021-01-22 06-51-20.272 [Debug] (Stream) Silent frames: 4602, frames: 5512, age: -104.376
2021-01-22 06-51-21.032 [Debug] (Stats) Chunk: 0 0 0 0 6 120 0
pi@amadeus:~/downloads $ snapclient -v snapclient v0.19.0
pi@amadeus:~/downloads $ snapclient --user snapclient:snapclient --logfilter *:debug -h cms
2021-01-22 06-59-38 [Info] (main) Latency: 0
2021-01-22 06-59-38 [Notice] (start) Connected to 192.168.1.37
2021-01-22 06-59-38 [Info] (getMacAddress) My MAC: "80:1f:02:8a:4f:26", socket: 6
2021-01-22 06-59-38 [Info] (onMessageReceived) ServerSettings - buffer: 1000, latency: 0, volume: 100, muted: 0
metadata:{"STREAM":"snapcast"}
2021-01-22 06-59-38 [Info] (onMessageReceived) Codec: flac
2021-01-22 06-59-38 [Notice] (state) sampleformat: 44100:16:2
2021-01-22 06-59-38 [Info] (Alsa) frames: 5512
2021-01-22 06-59-38 [Info] (Alsa) Resizing buffer from 0 to 44100
2021-01-22 06-59-38 [Info] (Stream) no chunks available
2021-01-22 06-59-38 [Info] (Alsa) Failed to get chunk
2021-01-22 06-59-39 [Info] (Stream) Chunk: 0 0 0 0 1 125 0
2021-01-22 06-59-39 [Info] (worker) diff to server [ms]: 3.02419e+08
2021-01-22 06-59-40 [Info] (Stream) Chunk: 0 0 0 0 5 125 0
2021-01-22 06-59-41 [Info] (Stream) Chunk: 0 0 0 0 13 125 0
2021-01-22 06-59-42 [Info] (Stream) Chunk: 1 0 0 0 21 125 0
2021-01-22 06-59-43 [Info] (Stream) Chunk: 2 1 0 0 29 125 0
2021-01-22 06-59-44 [Info] (Stream) Chunk: 3 2 1 1 37 125 0
2021-01-22 06-59-45 [Info] (Stream) Chunk: 4 3 1 1 45 125 0
2021-01-22 06-59-46 [Info] (Stream) Chunk: 5 4 2 2 53 125 0
2021-01-22 06-59-47 [Info] (Stream) Chunk: 6 5 2 2 61 125 0
2021-01-22 06-59-48 [Info] (Stream) Chunk: 7 6 3 3 69 125 0
2021-01-22 06-59-49 [Info] (Stream) Chunk: 8 7 3 3 77 125 0
2021-01-22 06-59-50 [Info] (Stream) Chunk: 9 8 3 3 85 125 0
2021-01-22 06-59-51 [Info] (Stream) Chunk: 10 9 4 4 93 125 0
2021-01-22 06-59-52 [Info] (Stream) Chunk: 11 10 5 5 101 125 0
2021-01-22 06-59-53 [Info] (Stream) Chunk: 10 10 6 5 109 125 -10
2021-01-22 06-59-54 [Info] (Stream) Chunk: 7 10 7 6 117 125 -13
2021-01-22 06-59-55 [Info] (Stream) Chunk: 5 8 7 6 125 125 -15
2021-01-22 06-59-56 [Info] (Stream) Chunk: 2 5 7 5 133 125 -16
2021-01-22 06-59-57 [Info] (Stream) Chunk: 0 3 7 5 141 125 -13
2021-01-22 06-59-58 [Info] (Stream) Chunk: 0 0 7 5 149 125 -4
2021-01-22 06-59-59 [Info] (Stream) Chunk: 1 0 7 4 157 125 0
2021-01-22 07-00-00 [Info] (Stream) Chunk: 1 0 7 4 165 125 -6
2021-01-22 07-00-01 [Info] (Stream) Chunk: 0 0 5 3 173 125 -6
2021-01-22 07-00-02 [Info] (Stream) Chunk: 0 0 3 3 181 125 -4
Thanks :)
with the v0.19 settings buffer_time=120,fragments=4
Sorry, what I meant is to run the 0.23.100 with --player alsa:buffer_time=120,fragments=4, which reflects the defaults that were used in 0.19
Edit: the 0.23.100 log looks already as expected, the default is to use buffer_time 80 with 4 fragments, so Snapclient requests a fragment time of 20 (= 80 / 4) and gets 125 (the only fragment time supported by your DAC (or driver)), then Snapclient requests a buffer time "near to 80" and gets 250, because alsa decides to use at least two fragments (which is perfectly reasonable, one fragment will not work without audible drops).
Now I'm still curious what you will get with buffer_time=120,fragments=4, I would expect the same.
FYI: The 0.23.100 heuristic is the same that the alsa tool aplay applies: It chooses a default buffer_time of 500ms with 4 fragments. It first requests the fragment_time (125ms), followed by the buffer time. Because Snapclient is interested in lowering the latency, I think it makes more sense to configure the desired latency (i.e. buffer_time) and request a fragment_time the device is capable of and then configure the number of fragments to lower the risk of getting dropouts.
First the good news, version 0.23.100 with parameter buffer_time=120,fragments=4 is running without any errors on player amadeus. The bad news, and that is really strange, I tested v0.23.100 on a another client a Rapberry Pi Zero. This client has no issues with snapclient v.0.19, but with version v.0.23.100 this client shows up with dropouts (see attached log).
Here are the logs from client amadeus (Raspberry Pi 3 with audio device driver sndrpihifiberry ) and client ludwig a Raspberry Pi Zero with the same audio device driver as client amadeus.
pi@amadeus:~/downloads $ snapclient --user snapclient:snapclient --logfilter *:debug -h cms --player alsa:buffer_time=120,fragments=4
2021-01-22 16-00-26.249 [Info] (Connection) Resolving host IP for: cms
2021-01-22 16-00-26.254 [Info] (Connection) Connecting
2021-01-22 16-00-26.274 [Notice] (Connection) Connected to 192.168.1.37
2021-01-22 16-00-26.275 [Info] (Connection) My MAC: "80:1f:02:8a:4f:26", socket: 8
2021-01-22 16-00-26.478 [Debug] (Connection) outstanding async_write
2021-01-22 16-00-26.482 [Info] (Controller) ServerSettings - buffer: 1000, latency: 0, volume: 100, muted: 0
metadata:{"STREAM":"snapcast"}
2021-01-22 16-00-26.483 [Info] (Controller) Codec: flac, sampleformat: 44100:16:2
2021-01-22 16-00-26.483 [Info] (Player) Player name: alsa, device: default, description: <none>, idx: 3, sharing mode: unspecified, parameters: buffer_time=120,fragments=4
2021-01-22 16-00-26.483 [Info] (Player) Mixer mode: software, parameters: <none>
2021-01-22 16-00-26.483 [Info] (Player) Sampleformat: 44100:16:2, stream: 44100:16:2
2021-01-22 16-00-26.483 [Info] (Alsa) Using buffer_time: 120 ms, fragments: 4
2021-01-22 16-00-26.487 [Info] (Alsa) Period time too small, changing from 30000 to 125000
2021-01-22 16-00-26.488 [Info] (Alsa) PCM name: default, sample rate: 44100 Hz, channels: 2, buffer time: 374988 us, periods: 3, period time: 125000 us, period frames: 5512
2021-01-22 16-00-26.488 [Debug] (Alsa) setVolume exp with base 10: 1 => 1
2021-01-22 16-00-26.488 [Debug] (Alsa) Resizing buffer from 0 to 66148
2021-01-22 16-00-26.488 [Info] (Stream) No chunks available
2021-01-22 16-00-26.488 [Info] (Alsa) Failed to get chunk
2021-01-22 16-00-27.109 [Debug] (Stream) Silent frames: 4841, frames: 5512, age: -109.783
2021-01-22 16-00-27.144 [Info] (Controller) diff to server [ms]: 3.34453e+08
2021-01-22 16-00-27.234 [Debug] (Stats) Chunk: -3 -3 -3 -3 1 250 0
2021-01-22 16-00-28.109 [Debug] (Stats) Chunk: -2 -2 -2 -2 8 250 0
2021-01-22 16-00-29.109 [Debug] (Stats) Chunk: -1 -2 -2 -2 16 250 0
2021-01-22 16-00-30.109 [Debug] (Stats) Chunk: -1 -2 -2 -2 24 250 0
2021-01-22 16-00-31.109 [Debug] (Stats) Chunk: 0 -1 -2 -2 32 250 0
2021-01-22 16-00-32.109 [Debug] (Stats) Chunk: 0 0 -1 -1 39 250 0
2021-01-22 16-00-33.109 [Debug] (Stats) Chunk: 1 0 -1 -1 47 250 0
2021-01-22 16-00-34.109 [Debug] (Stats) Chunk: 2 1 0 0 55 250 0
2021-01-22 16-00-35.109 [Debug] (Stats) Chunk: 3 1 0 0 62 250 0
2021-01-22 16-00-36.109 [Debug] (Stats) Chunk: 3 2 0 0 70 250 0
2021-01-22 16-00-37.109 [Debug] (Stats) Chunk: 4 3 0 0 78 250 0
2021-01-22 16-00-38.109 [Debug] (Stats) Chunk: 4 3 0 0 85 250 0
2021-01-22 16-00-39.109 [Debug] (Stats) Chunk: 5 4 1 1 93 250 0
2021-01-22 16-00-40.109 [Debug] (Stats) Chunk: 4 4 1 1 101 250 0
2021-01-22 16-00-41.109 [Debug] (Stats) Chunk: 6 5 2 2 108 250 -2
2021-01-22 16-00-42.109 [Debug] (Stats) Chunk: 4 4 3 2 116 250 -4
2021-01-22 16-00-43.109 [Debug] (Stats) Chunk: 5 6 3 2 124 250 -7
2021-01-22 16-00-44.109 [Debug] (Stats) Chunk: 5 5 3 3 131 250 -6
2021-01-22 16-00-45.109 [Debug] (Stats) Chunk: 4 5 4 3 139 250 -7
2021-01-22 16-00-46.109 [Debug] (Stats) Chunk: 1 4 4 3 147 250 -9
2021-01-22 16-00-47.109 [Debug] (Stats) Chunk: 0 2 4 2 154 250 -9
2021-01-22 16-00-48.109 [Debug] (Stats) Chunk: 0 0 4 2 162 250 -1
2021-01-22 16-00-49.109 [Debug] (Stats) Chunk: 0 0 4 2 170 250 0
2021-01-22 16-00-50.109 [Debug] (Stats) Chunk: 0 0 4 2 177 250 0
2021-01-22 16-00-51.109 [Debug] (Stats) Chunk: 1 0 4 1 185 250 -6
2021-01-22 16-00-52.109 [Debug] (Stats) Chunk: 0 1 2 1 193 250 -5
2021-01-22 16-00-53.109 [Debug] (Stats) Chunk: 1 1 1 1 200 250 -2
2021-01-22 16-00-54.109 [Debug] (Stats) Chunk: 1 1 1 1 208 250 -2
2021-01-22 16-00-55.109 [Debug] (Stats) Chunk: 2 1 1 1 216 250 -2
2021-01-22 16-00-56.109 [Debug] (Stats) Chunk: 3 2 1 1 223 250 -2
2021-01-22 16-00-57.109 [Debug] (Stats) Chunk: 5 3 1 1 231 250 -2
2021-01-22 16-00-58.109 [Debug] (Stats) Chunk: 3 3 1 2 239 250 -3
2021-01-22 16-00-59.109 [Debug] (Stats) Chunk: 4 4 1 2 246 250 -2
2021-01-22 16-01-00.109 [Debug] (Stats) Chunk: 3 4 1 2 254 250 -2
2021-01-22 16-01-01.109 [Debug] (Stats) Chunk: 4 4 2 2 262 250 -2
Now, the test on the Raspberry Pi Zero pi@ludwig:~/install $ cat /sys/firmware/devicetree/base/model Rapberry Pi Zero W Rev 1.1
pi@ludwig:~ $ aplay -l **** Liste der Hardware-Geräte (PLAYBACK) **** Karte 0: sndrpihifiberry [snd_rpi_hifiberry_dac], Gerät 0: HifiBerry DAC HiFi pcm5102a-hifi-0 [HifiBerry DAC HiFi pcm5102a-hifi-0]
pi@ludwig:~/downloads $ snapclient --logfilter *:debug -h cms --player alsa
2021-01-22 19-36-00.972 [Info] (Connection) Resolving host IP for: cms
2021-01-22 19-36-00.988 [Info] (Connection) Connecting
2021-01-22 19-36-00.992 [Notice] (Connection) Connected to 192.168.1.37
2021-01-22 19-36-00.995 [Info] (Connection) My MAC: "80:1f:02:b3:46:c1", socket: 8
2021-01-22 19-36-02.360 [Debug] (Connection) outstanding async_write
2021-01-22 19-36-02.410 [Info] (Controller) ServerSettings - buffer: 1000, latency: 0, volume: 100, muted: 0
metadata:{"STREAM":"snapcast"}
2021-01-22 19-36-02.416 [Info] (Controller) Codec: flac, sampleformat: 44100:16:2
2021-01-22 19-36-02.418 [Info] (Player) Player name: alsa, device: default, description: <none>, idx: 3, sharing mode: unspecified, parameters: <none>
2021-01-22 19-36-02.421 [Info] (Player) Mixer mode: software, parameters: <none>
2021-01-22 19-36-02.422 [Info] (Player) Sampleformat: 44100:16:2, stream: 44100:16:2
2021-01-22 19-36-02.427 [Info] (Alsa) Using buffer_time: 80 ms, fragments: 4
2021-01-22 19-36-02.435 [Debug] (Alsa) ACCESS: MMAP_INTERLEAVED MMAP_NONINTERLEAVED MMAP_COMPLEX RW_INTERLEAVED RW_NONINTERLEAVED
2021-01-22 19-36-02.435 [Debug] (Alsa) FORMAT: S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE MU_LAW A_LAW IMA_ADPCM S20_LE S20_BE U20_LE U20_BE S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE U18_3BE
2021-01-22 19-36-02.435 [Debug] (Alsa) SUBFORMAT: STD
2021-01-22 19-36-02.435 [Debug] (Alsa) SAMPLE_BITS: [4 64]
2021-01-22 19-36-02.435 [Debug] (Alsa) FRAME_BITS: [4 640000]
2021-01-22 19-36-02.435 [Debug] (Alsa) CHANNELS: [1 10000]
2021-01-22 19-36-02.435 [Debug] (Alsa) RATE: [4000 4294967295)
2021-01-22 19-36-02.435 [Debug] (Alsa) PERIOD_TIME: 125000
2021-01-22 19-36-02.435 [Debug] (Alsa) PERIOD_SIZE: [500 536870912)
2021-01-22 19-36-02.435 [Debug] (Alsa) PERIOD_BYTES: [250 4294967295)
2021-01-22 19-36-02.435 [Debug] (Alsa) PERIODS: (0 3221226)
2021-01-22 19-36-02.435 [Debug] (Alsa) BUFFER_TIME: [1 4294967295]
2021-01-22 19-36-02.435 [Debug] (Alsa) BUFFER_SIZE: [1000 1610612735]
2021-01-22 19-36-02.435 [Debug] (Alsa) BUFFER_BYTES: [500 4294967295]
2021-01-22 19-36-02.435 [Debug] (Alsa) TICK_TIME: ALL
2021-01-22 19-36-02.457 [Info] (Alsa) PCM name: default, sample rate: 44100 Hz, channels: 2, buffer time: 250000 us, periods: 2, period time: 125000 us, period frames: 5512
2021-01-22 19-36-02.460 [Debug] (Player) setVolume exp with base 10: 1 => 1
2021-01-22 19-36-02.469 [Debug] (Alsa) Resizing buffer from 0 to 44100
2021-01-22 19-36-02.668 [Info] (Controller) diff to server [ms]: -1.62166e+07
2021-01-22 19-36-03.120 [Debug] (Stream) Silent frames: 5036, frames: 5527, age: -114.197
2021-01-22 19-36-03.250 [Debug] (Stats) Chunk: 0 0 0 0 1 119 0
2021-01-22 19-36-04.020 [Debug] (Stats) Chunk: 0 0 0 0 7 120 0
2021-01-22 19-36-05.041 [Debug] (Stats) Chunk: 1 0 0 0 15 124 0
2021-01-22 19-36-06.073 [Debug] (Stats) Chunk: 2 1 1 1 23 123 0
2021-01-22 19-36-07.088 [Debug] (Stats) Chunk: 3 2 1 1 31 120 0
2021-01-22 19-36-07.475 [Error] (Alsa) XRUN while writing to PCM: Broken pipe
2021-01-22 19-36-08.126 [Debug] (Stats) Chunk: -2398 2 1 1 40 120 0
2021-01-22 19-36-08.892 [Info] (Stream) pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -239807
2021-01-22 19-36-09.148 [Debug] (Stream) Silent frames: 5031, frames: 5726, age: -114.099
2021-01-22 19-36-09.273 [Debug] (Stats) Chunk: 1 1 1 1 1 124 0
2021-01-22 19-36-10.035 [Debug] (Stats) Chunk: 0 0 0 0 7 123 0
2021-01-22 19-36-11.066 [Debug] (Stats) Chunk: 2 1 1 1 15 117 0
2021-01-22 19-36-12.087 [Debug] (Stats) Chunk: 3 2 2 2 23 122 0
2021-01-22 19-36-13.107 [Debug] (Stats) Chunk: 3 3 2 2 31 117 0
2021-01-22 19-36-13.113 [Error] (Alsa) XRUN while writing to PCM: Broken pipe
2021-01-22 19-36-13.621 [Warn] (Alsa) snd_pcm_avail_delay failed: Broken pipe (-32), avail: 5703, delay: 5315, using snd_pcm_avail amd snd_pcm_delay.
2021-01-22 19-36-13.629 [Warn] (Alsa) snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 5315
2021-01-22 19-36-14.110 [Debug] (Stats) Chunk: -3264 3 2 2 38 124 0
2021-01-22 19-36-14.746 [Info] (Stream) pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -234543
2021-01-22 19-36-15.130 [Debug] (Stream) Silent frames: 3141, frames: 5688, age: -71.234
2021-01-22 19-36-15.256 [Debug] (Stats) Chunk: 0 0 0 0 1 124 0
2021-01-22 19-36-15.898 [Error] (Alsa) XRUN while writing to PCM: Broken pipe
2021-01-22 19-36-16.110 [Debug] (Stats) Chunk: -2331 0 0 0 8 51 0
2021-01-22 19-36-17.120 [Debug] (Stats) Chunk: -2330 -2330 -2330 -2330 16 124 0
If I switch back to snapclient v.0.19, everything is ok:
pi@ludwig:~/downloads $ snapclient --logfilter *:debug -h cms
2021-01-22 20-04-44 [Info] (main) Latency: 0
2021-01-22 20-04-44 [Notice] (start) Connected to 192.168.1.37
2021-01-22 20-04-44 [Info] (getMacAddress) My MAC: "80:1f:02:b3:46:c1", socket: 6
2021-01-22 20-04-45 [Info] (onMessageReceived) ServerSettings - buffer: 1000, latency: 0, volume: 100, muted: 0
metadata:{"STREAM":"snapcast"}
2021-01-22 20-04-45 [Info] (onMessageReceived) Codec: flac
2021-01-22 20-04-45 [Notice] (state) sampleformat: 44100:16:2
2021-01-22 20-04-45 [Info] (Alsa) frames: 5512
2021-01-22 20-04-45 [Info] (Alsa) Resizing buffer from 0 to 44100
2021-01-22 20-04-45 [Info] (worker) diff to server [ms]: -1.62166e+07
2021-01-22 20-04-46 [Info] (Stream) Chunk: 0 0 0 0 1 129 0
2021-01-22 20-04-47 [Info] (Stream) Chunk: 0 0 0 0 7 123 0
2021-01-22 20-04-48 [Info] (Stream) Chunk: 1 0 0 0 15 123 0
2021-01-22 20-04-49 [Info] (Stream) Chunk: 1 0 0 0 23 124 0
2021-01-22 20-04-50 [Info] (Stream) Chunk: 2 1 1 1 31 127 0
2021-01-22 20-04-51 [Info] (Stream) Chunk: 2 2 1 1 39 129 0
2021-01-22 20-04-52 [Info] (Stream) Chunk: 4 2 1 1 47 124 0
2021-01-22 20-04-53 [Info] (Stream) Chunk: 4 4 2 2 55 124 0
2021-01-22 20-04-54 [Info] (Stream) Chunk: 6 4 2 2 63 127 0
2021-01-22 20-04-55 [Info] (Stream) Chunk: 7 6 2 2 71 120 0
2021-01-22 20-04-56 [Info] (Stream) Chunk: 8 6 3 3 79 127 0
2021-01-22 20-04-57 [Info] (Stream) Chunk: 7 7 3 3 87 123 0
2021-01-22 20-04-58 [Info] (Stream) Chunk: 9 8 4 4 95 124 0
2021-01-22 20-04-59 [Info] (Stream) Chunk: 10 9 4 4 103 124 -2
2021-01-22 20-05-00 [Info] (Stream) Chunk: 9 9 6 5 111 124 -9
2021-01-22 20-05-01 [Info] (Stream) Chunk: 7 9 6 5 119 125 -12
2021-01-22 20-05-02 [Info] (Stream) Chunk: 5 7 6 5 127 124 -13
2021-01-22 20-05-03 [Info] (Stream) Chunk: 2 5 6 5 135 124 -14
2021-01-22 20-05-04 [Info] (Stream) Chunk: 1 3 6 5 143 124 -11
2021-01-22 20-05-05 [Info] (Stream) Chunk: 0 1 6 4 151 125 -7
2021-01-22 20-05-06 [Info] (Stream) Chunk: 0 0 6 4 159 124 -3
2021-01-22 20-05-07 [Info] (Stream) Chunk: 0 0 6 4 167 124 0
2021-01-22 20-05-08 [Info] (Stream) Chunk: 0 0 5 3 175 124 -7
2021-01-22 20-05-09 [Info] (Stream) Chunk: 0 0 3 3 183 123 -4
Thanks again for testing. I think the problem with the pi zero is that you didn't configure alsa:buffer_time=120,fragments=4 (on amadeus you did).
I'm still wondering about the 250 in 0.23.100 vs 125 in 0.19:
2021-01-22 16-00-36.109 [Debug] (Stats) Chunk: 3 2 0 0 70 250 0
2021-01-22 20-04-47 [Info] (Stream) Chunk: 0 0 0 0 7 123 0
One last favor: I've built the 0.23.101 Backport alsa_player from v0.19 that uses the alsa_player class from 0.19 with additional logging of the alsa parameters. Can you please post a debug log from this 0.23.101 version? It is using fixed settings and cannot be configured (regarding buffer time and fragments), because it is the original 0.19 player code.
Ok, I tested snapclient v.0.23.101 on player amadeus (RPI 3) as well as on player ludwig (RPI Zero). Using this version , both clients are playing fine, without any dropouts.
pi@amadeus:~/downloads $ snapclient -v snapclient v0.23.101, built Jan 9 2021
pi@amadeus:~/downloads $ snapclient --user snapclient:snapclient -h cms --logfilter *:debug
2021-01-23 06-38-03.249 [Info] (Connection) Resolving host IP for: cms
2021-01-23 06-38-03.253 [Info] (Connection) Connecting
2021-01-23 06-38-03.271 [Notice] (Connection) Connected to 192.168.1.37
2021-01-23 06-38-03.271 [Info] (Connection) My MAC: "80:1f:02:8a:4f:26", socket: 8
2021-01-23 06-38-03.487 [Debug] (Connection) outstanding async_write
2021-01-23 06-38-03.495 [Info] (Controller) ServerSettings - buffer: 1000, latency: 0, volume: 100, muted: 0
metadata:{"STREAM":"snapcast"}
2021-01-23 06-38-03.495 [Info] (Controller) Codec: flac, sampleformat: 44100:16:2
2021-01-23 06-38-03.495 [Info] (Player) Player name: alsa, device: default, description: <none>, idx: 3, sharing mode: unspecified, parameters: <none>
2021-01-23 06-38-03.495 [Info] (Player) Mixer mode: software, parameters: <none>
2021-01-23 06-38-03.496 [Info] (Player) Sampleformat: 44100:16:2, stream: 44100:16:2
2021-01-23 06-38-03.498 [Debug] (Alsa) ACCESS: MMAP_INTERLEAVED MMAP_NONINTERLEAVED MMAP_COMPLEX RW_INTERLEAVED RW_NONINTERLEAVED
2021-01-23 06-38-03.498 [Debug] (Alsa) FORMAT: S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE MU_LAW A_LAW IMA_ADPCM S20_LE S20_BE U20_LE U20_BE S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE U18_3BE
2021-01-23 06-38-03.498 [Debug] (Alsa) SUBFORMAT: STD
2021-01-23 06-38-03.498 [Debug] (Alsa) SAMPLE_BITS: [4 64]
2021-01-23 06-38-03.498 [Debug] (Alsa) FRAME_BITS: [4 640000]
2021-01-23 06-38-03.498 [Debug] (Alsa) CHANNELS: [1 10000]
2021-01-23 06-38-03.498 [Debug] (Alsa) RATE: [4000 4294967295)
2021-01-23 06-38-03.498 [Debug] (Alsa) PERIOD_TIME: 125000
2021-01-23 06-38-03.498 [Debug] (Alsa) PERIOD_SIZE: [500 536870912)
2021-01-23 06-38-03.498 [Debug] (Alsa) PERIOD_BYTES: [250 4294967295)
2021-01-23 06-38-03.498 [Debug] (Alsa) PERIODS: (0 3221226)
2021-01-23 06-38-03.498 [Debug] (Alsa) BUFFER_TIME: [1 4294967295]
2021-01-23 06-38-03.498 [Debug] (Alsa) BUFFER_SIZE: [1000 1610612735]
2021-01-23 06-38-03.498 [Debug] (Alsa) BUFFER_BYTES: [500 4294967295]
2021-01-23 06-38-03.498 [Debug] (Alsa) TICK_TIME: ALL
2021-01-23 06-38-03.500 [Info] (Alsa) PCM name: default, sample rate: 44100 Hz, channels: 2, buffer time: 250000 us, periods: 2, period time: 125000 us, period frames: 5512
2021-01-23 06-38-03.501 [Debug] (Alsa) PCM name: default
2021-01-23 06-38-03.501 [Debug] (Alsa) PCM state: PREPARED
2021-01-23 06-38-03.501 [Debug] (Alsa) channels: 2
2021-01-23 06-38-03.501 [Debug] (Alsa) rate: 44100 bps
2021-01-23 06-38-03.501 [Info] (Alsa) frames: 5512
2021-01-23 06-38-03.501 [Debug] (Alsa) period time: 125000
2021-01-23 06-38-03.501 [Info] (Alsa) Resizing buffer from 0 to 44100
2021-01-23 06-38-03.501 [Info] (Alsa) setVolume exp with base 10: 1 => 1
2021-01-23 06-38-03.501 [Info] (Stream) No chunks available
2021-01-23 06-38-03.501 [Info] (Alsa) Failed to get chunk
2021-01-23 06-38-04.061 [Info] (Controller) diff to server [ms]: 4.84784e+07
2021-01-23 06-38-04.247 [Debug] (Stream) Silent frames: 3866, frames: 5512, age: -87.679
2021-01-23 06-38-04.372 [Debug] (Stats) Chunk: 0 0 0 0 1 125 0
2021-01-23 06-38-05.122 [Debug] (Stats) Chunk: 0 0 0 0 7 125 0
2021-01-23 06-38-06.122 [Debug] (Stats) Chunk: 1 0 0 0 15 125 0
2021-01-23 06-38-07.122 [Debug] (Stats) Chunk: 2 1 1 1 23 125 0
2021-01-23 06-38-08.122 [Debug] (Stats) Chunk: 3 2 1 1 31 125 0
2021-01-23 06-38-09.122 [Debug] (Stats) Chunk: 3 2 1 1 39 125 0
2021-01-23 06-38-10.122 [Debug] (Stats) Chunk: 4 3 2 2 47 125 0
2021-01-23 06-38-11.122 [Debug] (Stats) Chunk: 5 4 2 2 55 125 0
2021-01-23 06-38-12.122 [Debug] (Stats) Chunk: 5 4 2 2 63 125 0
2021-01-23 06-38-13.122 [Debug] (Stats) Chunk: 6 5 3 3 71 125 0
2021-01-23 06-38-14.122 [Debug] (Stats) Chunk: 7 6 3 3 79 125 0
2021-01-23 06-38-15.122 [Debug] (Stats) Chunk: 8 7 3 3 87 125 0
2021-01-23 06-38-16.122 [Debug] (Stats) Chunk: 9 8 4 4 95 125 0
2021-01-23 06-38-17.122 [Debug] (Stats) Chunk: 9 9 4 4 103 125 -2
2021-01-23 06-38-18.122 [Debug] (Stats) Chunk: 8 9 5 5 111 125 -9
2021-01-23 06-38-19.122 [Debug] (Stats) Chunk: 6 9 6 5 119 125 -10
2021-01-23 06-38-20.122 [Debug] (Stats) Chunk: 4 7 6 5 127 125 -13
2021-01-23 06-38-21.122 [Debug] (Stats) Chunk: 2 5 6 5 135 125 -14
2021-01-23 06-38-22.122 [Debug] (Stats) Chunk: 0 2 6 4 143 125 -11
2021-01-23 06-38-23.122 [Debug] (Stats) Chunk: 0 0 6 4 151 125 -3
2021-01-23 06-38-24.122 [Debug] (Stats) Chunk: 0 0 6 4 159 125 -2
2021-01-23 06-38-25.122 [Debug] (Stats) Chunk: 0 0 6 3 167 125 -3
2021-01-23 06-38-26.122 [Debug] (Stats) Chunk: 0 0 5 3 175 125 -4
2021-01-23 06-38-27.122 [Debug] (Stats) Chunk: 0 0 2 3 183 125 -1
2021-01-23 06-38-28.122 [Debug] (Stats) Chunk: 1 0 1 3 191 125 0
2021-01-23 06-38-29.122 [Debug] (Stats) Chunk: 1 1 1 2 199 125 -1
2021-01-23 06-38-30.122 [Debug] (Stats) Chunk: 1 1 1 2 207 125 -2
2021-01-23 06-38-31.122 [Debug] (Stats) Chunk: 2 1 1 2 215 125 -3
pi@ludwig:~/downloads $ snapclient -v snapclient v0.23.101, built Jan 9 2021
pi@ludwig:~/downloads $ snapclient -h cms --logfilter *:debug
2021-01-23 06-56-18.263 [Info] (Connection) Resolving host IP for: cms
2021-01-23 06-56-18.279 [Info] (Connection) Connecting
2021-01-23 06-56-18.284 [Notice] (Connection) Connected to 192.168.1.37
2021-01-23 06-56-18.287 [Info] (Connection) My MAC: "80:1f:02:b3:46:c1", socket: 8
2021-01-23 06-56-19.487 [Debug] (Connection) outstanding async_write
2021-01-23 06-56-19.520 [Info] (Controller) ServerSettings - buffer: 1000, latency: 0, volume: 100, muted: 0
metadata:{"STREAM":"snapcast"}
2021-01-23 06-56-19.527 [Info] (Controller) Codec: flac, sampleformat: 44100:16:2
2021-01-23 06-56-19.529 [Info] (Player) Player name: alsa, device: default, description: <none>, idx: 3, sharing mode: unspecified, parameters: <none>
2021-01-23 06-56-19.530 [Info] (Player) Mixer mode: software, parameters: <none>
2021-01-23 06-56-19.531 [Info] (Player) Sampleformat: 44100:16:2, stream: 44100:16:2
2021-01-23 06-56-19.544 [Debug] (Alsa) ACCESS: MMAP_INTERLEAVED MMAP_NONINTERLEAVED MMAP_COMPLEX RW_INTERLEAVED RW_NONINTERLEAVED
2021-01-23 06-56-19.544 [Debug] (Alsa) FORMAT: S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE MU_LAW A_LAW IMA_ADPCM S20_LE S20_BE U20_LE U20_BE S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE U18_3BE
2021-01-23 06-56-19.544 [Debug] (Alsa) SUBFORMAT: STD
2021-01-23 06-56-19.544 [Debug] (Alsa) SAMPLE_BITS: [4 64]
2021-01-23 06-56-19.544 [Debug] (Alsa) FRAME_BITS: [4 640000]
2021-01-23 06-56-19.544 [Debug] (Alsa) CHANNELS: [1 10000]
2021-01-23 06-56-19.544 [Debug] (Alsa) RATE: [4000 4294967295)
2021-01-23 06-56-19.544 [Debug] (Alsa) PERIOD_TIME: 125000
2021-01-23 06-56-19.544 [Debug] (Alsa) PERIOD_SIZE: [500 536870912)
2021-01-23 06-56-19.544 [Debug] (Alsa) PERIOD_BYTES: [250 4294967295)
2021-01-23 06-56-19.544 [Debug] (Alsa) PERIODS: (0 3221226)
2021-01-23 06-56-19.544 [Debug] (Alsa) BUFFER_TIME: [1 4294967295]
2021-01-23 06-56-19.544 [Debug] (Alsa) BUFFER_SIZE: [1000 1610612735]
2021-01-23 06-56-19.544 [Debug] (Alsa) BUFFER_BYTES: [500 4294967295]
2021-01-23 06-56-19.544 [Debug] (Alsa) TICK_TIME: ALL
2021-01-23 06-56-19.562 [Info] (Alsa) PCM name: default, sample rate: 44100 Hz, channels: 2, buffer time: 250000 us, periods: 2, period time: 125000 us, period frames: 5512
2021-01-23 06-56-19.564 [Debug] (Alsa) PCM name: default
2021-01-23 06-56-19.567 [Debug] (Alsa) PCM state: PREPARED
2021-01-23 06-56-19.569 [Debug] (Alsa) channels: 2
2021-01-23 06-56-19.570 [Debug] (Alsa) rate: 44100 bps
2021-01-23 06-56-19.571 [Info] (Alsa) frames: 5512
2021-01-23 06-56-19.571 [Debug] (Alsa) period time: 125000
2021-01-23 06-56-19.572 [Debug] (Player) setVolume exp with base 10: 1 => 1
2021-01-23 06-56-19.580 [Info] (Alsa) Resizing buffer from 0 to 44100
2021-01-23 06-56-19.747 [Info] (Controller) diff to server [ms]: 4.92051e+07
2021-01-23 06-56-20.289 [Debug] (Stream) Silent frames: 2841, frames: 5519, age: -64.44
2021-01-23 06-56-20.414 [Debug] (Stats) Chunk: 0 0 0 0 1 125 0
2021-01-23 06-56-21.039 [Debug] (Stats) Chunk: 0 0 0 0 6 124 0
2021-01-23 06-56-22.039 [Debug] (Stats) Chunk: 1 1 1 1 14 125 0
2021-01-23 06-56-23.039 [Debug] (Stats) Chunk: 2 1 1 1 22 125 0
2021-01-23 06-56-24.039 [Debug] (Stats) Chunk: 3 2 1 1 30 125 0
2021-01-23 06-56-25.039 [Debug] (Stats) Chunk: 3 2 2 2 38 124 0
2021-01-23 06-56-26.039 [Debug] (Stats) Chunk: 5 4 2 2 46 125 0
2021-01-23 06-56-27.039 [Debug] (Stats) Chunk: 6 4 2 2 54 125 0
2021-01-23 06-56-28.039 [Debug] (Stats) Chunk: 6 5 3 3 62 125 0
2021-01-23 06-56-29.039 [Debug] (Stats) Chunk: 7 6 3 3 70 125 0
2021-01-23 06-56-30.039 [Debug] (Stats) Chunk: 8 7 4 4 78 125 0
2021-01-23 06-56-31.039 [Debug] (Stats) Chunk: 9 7 4 4 86 125 0
2021-01-23 06-56-32.039 [Debug] (Stats) Chunk: 8 8 4 4 94 124 0
2021-01-23 06-56-33.039 [Debug] (Stats) Chunk: 9 9 5 5 102 124 -1
2021-01-23 06-56-34.039 [Debug] (Stats) Chunk: 8 9 6 6 110 125 -10
To complete the test results. here is the log from testing ludwig with the previous patch v.0.23.100 and buffer_time=120,fragments=4
pi@ludwig:~/downloads $ snapclient -v snapclient v0.23.100, built Jan 9 2021
pi@ludwig:~/downloads $ snapclient -h cms --logfilter *:debug --player alsa:buffer_time=120,fragments=4
2021-01-23 06-53-50.314 [Info] (Connection) Resolving host IP for: cms
2021-01-23 06-53-50.328 [Info] (Connection) Connecting
2021-01-23 06-53-50.332 [Notice] (Connection) Connected to 192.168.1.37
2021-01-23 06-53-50.334 [Info] (Connection) My MAC: "80:1f:02:b3:46:c1", socket: 8
2021-01-23 06-53-51.465 [Debug] (Connection) outstanding async_write
2021-01-23 06-53-51.500 [Info] (Controller) ServerSettings - buffer: 1000, latency: 0, volume: 100, muted: 0
metadata:{"STREAM":"snapcast"}
2021-01-23 06-53-51.509 [Info] (Controller) Codec: flac, sampleformat: 44100:16:2
2021-01-23 06-53-51.512 [Info] (Player) Player name: alsa, device: default, description: <none>, idx: 3, sharing mode: unspecified, parameters: buffer_time=120,fragments=4
2021-01-23 06-53-51.515 [Info] (Player) Mixer mode: software, parameters: <none>
2021-01-23 06-53-51.518 [Info] (Player) Sampleformat: 44100:16:2, stream: 44100:16:2
2021-01-23 06-53-51.520 [Info] (Alsa) Using buffer_time: 120 ms, fragments: 4
2021-01-23 06-53-51.536 [Debug] (Alsa) ACCESS: MMAP_INTERLEAVED MMAP_NONINTERLEAVED MMAP_COMPLEX RW_INTERLEAVED RW_NONINTERLEAVED
2021-01-23 06-53-51.536 [Debug] (Alsa) FORMAT: S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE MU_LAW A_LAW IMA_ADPCM S20_LE S20_BE U20_LE U20_BE S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE U18_3BE
2021-01-23 06-53-51.536 [Debug] (Alsa) SUBFORMAT: STD
2021-01-23 06-53-51.536 [Debug] (Alsa) SAMPLE_BITS: [4 64]
2021-01-23 06-53-51.536 [Debug] (Alsa) FRAME_BITS: [4 640000]
2021-01-23 06-53-51.536 [Debug] (Alsa) CHANNELS: [1 10000]
2021-01-23 06-53-51.536 [Debug] (Alsa) RATE: [4000 4294967295)
2021-01-23 06-53-51.536 [Debug] (Alsa) PERIOD_TIME: 125000
2021-01-23 06-53-51.536 [Debug] (Alsa) PERIOD_SIZE: [500 536870912)
2021-01-23 06-53-51.536 [Debug] (Alsa) PERIOD_BYTES: [250 4294967295)
2021-01-23 06-53-51.536 [Debug] (Alsa) PERIODS: (0 3221226)
2021-01-23 06-53-51.536 [Debug] (Alsa) BUFFER_TIME: [1 4294967295]
2021-01-23 06-53-51.536 [Debug] (Alsa) BUFFER_SIZE: [1000 1610612735]
2021-01-23 06-53-51.536 [Debug] (Alsa) BUFFER_BYTES: [500 4294967295]
2021-01-23 06-53-51.536 [Debug] (Alsa) TICK_TIME: ALL
2021-01-23 06-53-51.557 [Info] (Alsa) PCM name: default, sample rate: 44100 Hz, channels: 2, buffer time: 250000 us, periods: 2, period time: 125000 us, period frames: 5512
2021-01-23 06-53-51.563 [Debug] (Player) setVolume exp with base 10: 1 => 1
2021-01-23 06-53-51.571 [Debug] (Alsa) Resizing buffer from 0 to 44100
2021-01-23 06-53-51.770 [Info] (Controller) diff to server [ms]: 4.92051e+07
2021-01-23 06-53-52.292 [Debug] (Stream) Silent frames: 1319, frames: 5740, age: -29.919
2021-01-23 06-53-52.422 [Debug] (Stats) Chunk: 0 0 0 0 1 120 0
2021-01-23 06-53-53.053 [Debug] (Stats) Chunk: 1 0 0 0 6 125 0
2021-01-23 06-53-54.079 [Warn] (Alsa) snd_pcm_avail_delay failed: Broken pipe (-32), avail: 5497, delay: 5520, using snd_pcm_avail amd snd_pcm_delay.
2021-01-23 06-53-54.086 [Warn] (Alsa) snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 5520
2021-01-23 06-53-54.099 [Debug] (Stats) Chunk: -996 1 1 1 14 0 0
2021-01-23 06-53-55.042 [Debug] (Stats) Chunk: -916 0 0 0 21 125 0
2021-01-23 06-53-55.553 [Info] (Stream) pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -91447
2021-01-23 06-53-55.677 [Debug] (Stream) Silent frames: 4039, frames: 5512, age: -91.603
2021-01-23 06-53-56.058 [Debug] (Stats) Chunk: 0 0 0 0 3 124 0
2021-01-23 06-53-57.075 [Debug] (Stats) Chunk: 0 0 0 0 11 123 0
2021-01-23 06-53-58.094 [Debug] (Stats) Chunk: 1 0 0 0 19 123 0
2021-01-23 06-53-58.733 [Error] (Alsa) XRUN while writing to PCM: Broken pipe
2021-01-23 06-53-59.031 [Debug] (Stats) Chunk: -2397 0 0 0 27 124 0
2021-01-23 06-54-00.042 [Debug] (Stats) Chunk: -2398 -2397 0 0 35 119 0
2021-01-23 06-54-00.167 [Info] (Stream) pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -239712
2021-01-23 06-54-00.416 [Debug] (Stream) Silent frames: 5063, frames: 5512, age: -114.818
2021-01-23 06-54-01.053 [Debug] (Stats) Chunk: 1 1 1 1 5 124 0
2021-01-23 06-54-02.079 [Debug] (Stats) Chunk: 1 1 1 1 13 120 0
Thanks :) This is really interesting, using the exact same alsa configuration, the 0.19 (0.23.101) does not have any dropouts, while the 0.23.100 has dropouts, both using only 2 fragments. I have to investigate the difference in the player logic.
Might be solved now with the commit Don't sleep if frames avail < period size.
Since v0.20 Snapclient only feeds complete fragments to the PCM device. If there is not enough space free in the device's buffer, Snapclient waits for the buffer to have enough free space, this will cause a buffer under run in case of two fragments. There was no explanation in the commit message or comment in the source code, so I removed this constraint, and hope that the develop branch will now work as reliable as the 0.19 did.
Yes, it seems that the problem is solved now! I've tested v.23.100 - latest patch on RPI 3 and RPI Zero (player amadeus and ludwig) without any noticeable problem. Test was executed with different buffer_times (multiples of 20ms) and different fragments (4,6) .
Thanks a lot for the effort you put into the development and maintenance of snapcast.
Great, thanks again for testing! Can you please once more paste the logs of latest version, just for me to double check that everything looks as expected?
Hi Guys
I've been watching this thread keenly, as I've been having the same dropout issues on a Pi Zero with ALSA and an adafruit voice bonnet. The hardware works as expected playing local mp3's using the mpg123 client.
This is my first exposure to snapcast so I've been using the latest 0.23 release of the server and client. The win32 client worked out of the box, but I had audio dropouts with the armhf client.
I've just tested with the .102 armhf client from the "Disable ccache in CI for debian packages" build, and if I run the client on its own without any command line parameters, then I sill get regular dropouts, but if I use the command line parameter "--player alsa:buffer_time=360,fragments=2" then everything seems fine. Using buffer_time of 120 and 240 still gives dropouts so I kept increasing until I got a successful outcome.
So, a couple of questions if I may...
- Is the client supposed to work out the buffer_time and fragments itself, or do we have to tune this manually
- I've tried setting SNAPCLIENT_OPTS="--player alsa:buffer_time=360,fragments=2" in the /etc/defaults/snapclient file, but this isn't picked up by the snapclient when running without any command line parameters. Have I done something wrong here?
Kind regards Dom
@TotalSpaceshipguy
- Yes, this would be the desired behavior. It's also the actual behavior on my test hardware, but unfortunately it seems that there are DACs out there where it doesn't work out. As you were following the thread, you might have read that it's recommended to use more than 2 fragments (i.e. 3 or 4). If you send logs, I can try to figure out what happened and to fix it. You can also try out the versions with these commit messages and send logs:
Backport alsa_player from v0.19,Set buffer time instead of periods,Configure period time instead of buffer time. Without logs I can't do anything but guessing. - The
SNAPCLIENT_OPTSwill be uses as command line arguments when started by systemd through the snapclient unit file:
[Service]
EnvironmentFile=-/etc/default/snapclient
ExecStart=/usr/bin/snapclient --logsink=system $SNAPCLIENT_OPTS
Hi @badaix
Thanks for the clarification on how the SNAPCLIENT_OPTS works. I'll download those other builds, do some more testing upload the logs for you
The log output of the most recent release might be enough to get an idea of what's happening