volumio/volumio3-backend

Shairport Sync takes a long time to start playing with Multiroom

timothyjward opened this issue · 0 comments

When streaming audio via shairport sync there is usually a couple of second delay before audio starts. If the target device is a multiroom master then there is a much longer delay (2 minutes or so) before any sound plays. When sound does play it is short snippets played consecutively at high speed for about 5-10 seconds, then audio plays normally.

If you wait 3-5 minutes then everything works fine (including the slave devices).

From the log it appears as though there is a 3 second (approx) buffer:

Oct 29 11:33:53 pi-living-room-music shairport-sync[2189]: {"time":1635507233780,"response":"startAirplayPlayback Success"}ALSA lib /home/pi/volumio-alsa-plugin/src/pcm_volumioswitch.c:254:(_snd_pcm_volumioswitch_hw_params) PCM volumioMultiRoomServer has buffer size 131072, but target_pcm volumioMultiRoom has buffer size 120422
Oct 29 11:33:53 pi-living-room-music shairport-sync[2189]: ALSA lib /home/pi/volumio-alsa-plugin/src/pcm_volumioswitch.c:265:(_snd_pcm_volumioswitch_hw_params) PCM volumioMultiRoomServer has buffer size 131072, but target_pcm volumioMultiRoom has buffer size 120422

This tallies with with the volumiofifo debug alsa plugin reporting that it has 130733 frames buffered before it starts (different sample rate).

Transfers to the volumiofifo PCM buffer seem to be small, 220 frames are added to the switcher with 239` frames added to the fifo with each transfer (44.1 -> 48 resampling), meaning approx 566 transfers are needed to fill the buffer. These small transfers occur frequently but not frequently enough to fill the buffer in real time.

There are periodic calls to _delay from Shairport, which reports the current fill level of the switcher buffer. This may be the issue as Shairport will see that the audio isn't being played. It is all the case that Shairport starts the switcher PCM before writing any data. This may also be the issue.