Plethra

Welcome!

This is a collaboratively edited question and answer site for power users of Plethra hardware and software. It's 100% free to participate.

Why are shairport-sync devices in-sync when using iTunes but out of sync when using audio|acacia?

+2 votes

I'm testing out whether your audio|acacia will work for my home audio setup. By all accounts it should be a near perfect fit (short of Spotify playback built in). Unfortunately I've run into a hitch when getting multiple airplay targets synced.

I have two airplay devices on my network, one is an airport express, and the other is a raspberry pi running shairport-sync. When I play from iTunes to both speakers, the audio is perfectly sychronised. When playing via audio|acacia, the sound is not synchronised at all, and out of time by up to a second.

Here's a video of the synced sound: https://www.youtube.com/watch?v=bS24YBfsKVM, and here's a video of the unsychronised sound: https://www.youtube.com/watch?v=m9kLncAdhM0 (sorry about the kids talking in the background).

Is there anything I can do on my end to get this synchronised, or is this a software issue in the server?

asked Jun 6, 2015 by user1145 (6 points)
edited Jun 6, 2015 by user1

3 Answers

0 votes

This is actually an issue with shairport-sync, as it does not fully comply with the AirPlay protocol.

You'll notice that when playing to AirPlay devices using audio|acacia, playback starts almost instantly (well, after 420ms to be exact) while with iTunes or iOS playback starts after 2000ms.

The developers of shairport-sync have hardcoded playback to start after 88,200 samples (2000ms) after receiving the initial Play command, rather than deriving the playback start time from the first sync packet like native AirPlay devices do.

As documented here, to fix this issue you should run shairport-sync with the following parameter:

--latency=18522

18,522 samples = 420ms

This should work in all scenarios except when adding shairport-sync devices to a session on-the-fly (i.e. while the session is playing). This issue will be resolved once shairport-sync correctly follows the protocol or when audio|acacia adds its "fast start" feature for devices joining on-the-fly.

answered Jun 6, 2015 by user66 (450 points)
edited Jun 6, 2015 by user66
Thanks for your quick response user66!  Unfortunately reducing the latency had the opposite effect. The shairplay speaker was already ahead of the airport, so this made the gap even worse. However this sent me off on a task of finding the correct latency. According to the shairport author 88,200 is the latency used by airplay devices. 99,400 is used by iTunes. 99,400 was what I had originally been hearing I believe, so I increased the latency by the difference of those two values and it got more in sync, but not perfect. I found an increase of 1.75x the difference got me to 119,000, which provides perfectly synced sound. I'm also synced in iTunes, so somehow this got both working in sync - brilliant!
Hmm...this is curious. So when you use audio|acacia, does it take longer than iTunes before you hear playback start? As a good test, perform a seek (i.e. set the position of the song to some where) in both iTunes and audio|acacia. Which takes longer before you start hearing audio?
I'm just coming back to this after a couple of weeks away. I've gone to test, except my trial license has expired. Do you know if trial licenses can be extended?
Hi there. I'm the developer of Shairport Sync. The latencies are indeed fixed in Shairport Sync and in older versions of Shairport. I'd be happy to add a latency specifically for audio|acacia is you can tell me what it should be. Also, it presupposes that audio|acacia identifies itself to Shairport Sync and doesn't masquerade as, say iTunes. Alternatively, if you share any pointers as to how the latency should be negotiated, I'd be very grateful.
0 votes

As a audio|acacia and shairport-sync user I' hope that this issue can be fixed soon. Please contact me if I can provide any help!

answered Sep 24, 2015 by user1236 (13 points)
0 votes

Here is also some discussion about the problem:

https://github.com/mikebrady/shairport-sync/issues/130

Please involve to get this fixed!

answered Sep 24, 2015 by user1236 (13 points)
So, it looks like we have a solution to the problem – it should be in a stable version of Shairport Sync in two or three weeks. Adventurous souls can compile a development version from the (temporary) "dynamic-latency" branch at https://github.com/mikebrady/shairport-sync/tree/dynamic-latency.
Hi there. The updates necessary are now in the stable version of Shairport Sync.
...