mikebrady / shairport-sync

AirPlay and AirPlay 2 audio player
Other
7.03k stars 567 forks source link

Problem playing from Synology NAS #1

Closed mikebrady closed 8 years ago

mikebrady commented 9 years ago

This from HiFiJ:

Hi Mike,

I compiled shairport-sync on two RasPis and on my Ubuntu Thinkpad and tried to use it with the itunes server implementation (so no "real" itunes) on my Synology NAS (a DS 114 to be exact). I have done this before with the original shairport, and that worked well (meaning good sound quality on RasPis/Openelec/XBMC), but of course without multi player synchronisation.

Now, with shairport-sync I have the problem that the stream is constantly disrupted, playing for a second or so (varying), then stopping for a couple of seconds. I already did a log with -vv which I could send or post, if you are interested in looking into this. I suppose the main parts are these errors with changing frame counts:

syncing to first seqno 871C. Lost sync with source -- flushing and resyncing. Error of 11591 frames. syncing to first seqno 884E. Lost sync with source -- flushing and resyncing. Error of 12257 frames. syncing to first seqno 8978. Lost sync with source -- flushing and resyncing. Error of -3345 frames.

(btw, network connection is fine on both raspis and laptop, shairport and squeezelite are working good).

I guess synology devices are quite common, and I personally now three other persons who use them as an Itunes server, so perhaps this is of some interest to you as it would provide an Apple free, linux based environment for multiroom audio as an alternative to SqueezeCenter/LMS and squeezelite.

Thanks for your work!

Joost

mikebrady commented 8 years ago

Whew! That's good to hear...

anmith commented 8 years ago

Hi, I finally managed to get the development-version running on the HiFiBerry & WiFi-Raspberry and can confirm the development version is working without having to set the "resync_threshold = 0" option.

Main problem that took me quite some time and I wasn't able to solve is that I can't access the HiFiBerry card as normal user, so I had to run shaiport-sync as root for the test.

[andreas@hifi-pi ~]$ aplay -l
aplay: device_list:268: no soundcards found...

versus

[root@hifi-pi shairport-sync]# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Here's some statistics from the test:

[root@hifi-pi shairport-sync]# ./shairport-sync -v --statistics
Looking for the configuration file "/etc/shairport-sync.conf".
Output device name is "default".
startup
avahi: avahi_register.
avahi: register_service.
Avahi without metadata
new RTSP connection.
Play connection from user agent "AudioStation/5.2 (Synology)".
Active-Remote string seen: "0000000000006012".
Connection from IPv4: aaa.bbb.ccc.ddd:35227
Using negotiated latency of 99225 frames.
Using negotiated latency of 105391 frames.
Using negotiated latency of 111794 frames.
Using negotiated latency of 118150 frames.
Using negotiated latency of 124392 frames.
Using negotiated latency of 123526 frames.
Using negotiated latency of 122840 frames.
Using negotiated latency of 122123 frames.
Using negotiated latency of 121371 frames.
Using negotiated latency of 118717 frames.
Using negotiated latency of 124912 frames.
Using negotiated latency of 124191 frames.
Using negotiated latency of 123407 frames.
Using negotiated latency of 122599 frames.
Using negotiated latency of 121864 frames.
Using negotiated latency of 119314 frames.
Using negotiated latency of 125509 frames.
Using negotiated latency of 124788 frames.
Using negotiated latency of 124044 frames.
Using negotiated latency of 123163 frames.
Using negotiated latency of 122388 frames.
Using negotiated latency of 119907 frames.
Using negotiated latency of 126196 frames.
Using negotiated latency of 125477 frames.
Using negotiated latency of 124812 frames.
Using negotiated latency of 123960 frames.
Using negotiated latency of 123177 frames.
Using negotiated latency of 120692 frames.
Using negotiated latency of 127038 frames.
Using negotiated latency of 126272 frames.
Using negotiated latency of 125645 frames.
Using negotiated latency of 124755 frames.
Using negotiated latency of 123947 frames.
Sync error: 17.4 (frames); net correction: 0.0 (ppm); corrections: 0.0 (ppm); missing packets 0; late packets 0; too late packets 0; resend requests 0; min DAC queue size 4928, min and max buffer occupancy 308 and 345.
mikebrady commented 8 years ago

That's great news – many thanks for all your hard work. I must say I'm rather curious about the latency negotiated – its variability but also its value of around 2.8 seconds.

I believe that this fixes the longest-standing issue with Shairport Sync!

anmith commented 8 years ago

You're welcome, seems I finally got a usable version right now :-)

Just tried the "Play on multiple airplay devices" and with the development-version the Raspberry is now also in sync with my Marantz M-CR510, which is more than I hoped for ...

mikebrady commented 8 years ago

That's even better – it's what I was hoping for with one of the new features – automatic latency negotiation! I'm going to promote this development version to master over the weekend. Thanks again.

mikebrady commented 8 years ago

@atze09, @anmith, I've just pushed out the relevant fixes as part of an update to master, now at 2.4.2. @HiFiJ, maybe you'd consider trying the updated version and reporting your experiences?

joerg-krause commented 8 years ago

@mikebrady Thanks for the new version! Though, because of the new features it could have been a 2.6.0. Nevertheless, good work!

daveyrb commented 8 years ago

Hi

I had this to access the HiFiBerry as a normal user do this:

sudo usermod -G audio

Then you can see the card.

Ralph

On 17 Oct 2015, at 10:20, anmith notifications@github.com wrote:

Hi, I finally managed to get the development-version running on the HiFiBerry & WiFi-Raspberry and can confirm the development version is working without having to set the "resync_threshold = 0" option.

Main problem that took me quite some time and I wasn't able to solve is that I can't access the HiFiBerry card as normal user, so I had to run shaiport-sync as root for the test.

[andreas@hifi-pi ~]$ aplay -l aplay: device_list:268: no soundcards found... versus

[root@hifi-pi shairport-sync]# aplay -l \ List of PLAYBACK Hardware Devices ** card 0: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 Here's some statistics from the test:

[root@hifi-pi shairport-sync]# ./shairport-sync -v --statistics Looking for the configuration file "/etc/shairport-sync.conf". Output device name is "default". startup avahi: avahi_register. avahi: register_service. Avahi without metadata new RTSP connection. Play connection from user agent "AudioStation/5.2 (Synology)". Active-Remote string seen: "0000000000006012". Connection from IPv4: aaa.bbb.ccc.ddd:35227 Using negotiated latency of 99225 frames. Using negotiated latency of 105391 frames. Using negotiated latency of 111794 frames. Using negotiated latency of 118150 frames. Using negotiated latency of 124392 frames. Using negotiated latency of 123526 frames. Using negotiated latency of 122840 frames. Using negotiated latency of 122123 frames. Using negotiated latency of 121371 frames. Using negotiated latency of 118717 frames. Using negotiated latency of 124912 frames. Using negotiated latency of 124191 frames. Using negotiated latency of 123407 frames. Using negotiated latency of 122599 frames. Using negotiated latency of 121864 frames. Using negotiated latency of 119314 frames. Using negotiated latency of 125509 frames. Using negotiated latency of 124788 frames. Using negotiated latency of 124044 frames. Using negotiated latency of 123163 frames. Using negotiated latency of 122388 frames. Using negotiated latency of 119907 frames. Using negotiated latency of 126196 frames. Using negotiated latency of 125477 frames. Using negotiated latency of 124812 frames. Using negotiated latency of 123960 frames. Using negotiated latency of 123177 frames. Using negotiated latency of 120692 frames. Using negotiated latency of 127038 frames. Using negotiated latency of 126272 frames. Using negotiated latency of 125645 frames. Using negotiated latency of 124755 frames. Using negotiated latency of 123947 frames. Sync error: 17.4 (frames); net correction: 0.0 (ppm); corrections: 0.0 (ppm); missing packets 0; late packets 0; too late packets 0; resend requests 0; min DAC queue size 4928, min and max buffer occupancy 308 and 345. — Reply to this email directly or view it on GitHub https://github.com/mikebrady/shairport-sync/issues/1#issuecomment-148897245.

mikebrady commented 8 years ago

Thanks — I took up your idea — it’s 2.6 now!

On 17 Oct 2015, at 14:59, Jörg Krause notifications@github.com wrote:

@mikebrady https://github.com/mikebrady Thanks for the new version! Though, because of the new features it could have been a 2.6.0. Nevertheless, good work!

— Reply to this email directly or view it on GitHub https://github.com/mikebrady/shairport-sync/issues/1#issuecomment-148917631.

joerg-krause commented 8 years ago

@mikebrady Great!

atze09 commented 8 years ago

@mikebrady Thank you very much!

mikebrady commented 8 years ago

I think it's reasonably safe to close this issue as fixed, yay!

HiFiJ commented 8 years ago

Hi Mike,

thanks a lot again for your unceasing work on this issue! Right now I'm streaming in sync from my Synology Diskstation 114 to two OpenSuse PC/Laptops without problems, all coming off the DS and controllable with the DS Audio app for Android (there's an iOS equivalent existing). So it seems things are working out, thanks! Later on this week, I'll put this stuff on my RaspBerries around the apartment, hope that also works (bit more wobbly wifi connection and lower processing power). I get a couple of alsa buffer underruns every couple of minutes, mostly on my laptop. Suppose that is a WiFi issue - anyway to increase the network buffer?

Great stuff!!!

HiFiJ

(also thanks to the other guys helping with debugging)

mikebrady commented 8 years ago

Thanks for the update. The alsa buffer underruns could also be a result of a busy Linux system doing something else – it's not a real-time operating system, after all. You could try raising the alsa > audio_backend_buffer_desired_length to, say 11,025 (0.25 seconds). This is up from the default of 6,615 (0.15 seconds) and it might make a difference. Worth experimenting with, for sure.

anmith commented 8 years ago

Finally found the time to replace the self-compiled development version with the updated version from the ArchARM repositories and listen to some music - everything works as expected! Thanks mikebrady for all the hard work you put into this!

mikebrady commented 8 years ago

Excellent.