mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 08:15:50 +03:00
[GH-ISSUE #310] Time offset in playback position #207
Labels
No labels
A-Alsa
SpotifyAPI
Tokio 1.0
audio
bug
can't reproduce
compilation
dependencies
duplicate
enhancement
good first issue
help wanted
high priority
imported
imported
invalid
new api
pull-request
question
reverse engineering
wiki
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/librespot#207
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @D54 on GitHub (Mar 17, 2019).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/310
The connect-client's playback position is approximately 50s behind the real one.
So when the playback is at 3m 0s, the player shows 2:10.
When the playback is paused, the offset is gone.
Additional symptoms:
Librespot version:
ef28df6built with:
--no-default-features --features alsa-backend --releaseClient version:
1.0.98.78 (Linux)
Webclient is also affected.
@devgianlu commented on GitHub (Mar 17, 2019):
Check that your device time is aligned with any NTP server.
@sashahilton00 and I discovered recently that it could be a problem.
@sashahilton00 commented on GitHub (Mar 17, 2019):
@devgianlu there is almost certainly some time sync going on between clients. I found a
core.clock_deltavariable earlier in the client, I imagine they are keeping time synced across instances.@devgianlu commented on GitHub (Mar 17, 2019):
That makes sense since the original client isn't effected by this issue, but I think that synchronizing with an NTP server by shifting the system time is enough for our purpose.
Implementing it in
librespotshouldn't be very difficult as it's already relaying on custom function to get the time.@plietar commented on GitHub (Mar 17, 2019):
Packet 0x4 (https://github.com/librespot-org/librespot/blob/master/core/src/session.rs#L170) contains a timestamp as the payload.
Client replies with a 0x49 packet, and finally the server sends a 0x4a back.
I suspect this sequence of packets is used for time synchronization
@devgianlu commented on GitHub (Mar 17, 2019):
The
Ping (0x4)packet seems to have the server timestamp as a payload.PongAck (0x4a)will reply with anything that is sent withPong (0x49).So I guess the server timestamp can be used to synchronize the client.You can indeed synchronize the client using the timestamp provided withPing (0x4). (github.com/librespot-org/librespot-java@e105815931)@D54 commented on GitHub (Mar 23, 2019):
I can confirm time-synchronization solved the problem, but I think this is not the optimal solution.
There should be some info about this requirement until the official protocol is implemented.
Anyway, thanks for the help and the possible future implementation!
@mfeif commented on GitHub (Mar 23, 2019):
It doesn't seem to be the same behavior, though it could be the same bug. For example, my clients don't stop paying before the song ends, or based on erroneous UI settings.
But I dug in and looked into the clocks...
The device and my laptop (where the clients are) were within 1 second of one another; close enough that I can't tell without running some kind of sync script between them. When I sync'd them both to the same ntp server, one was off by -0.011 seconds, the other by +0.041 ... so a total mismatch of 5 one hundredths of a second. Neither was off from "real" time (where presumably the spotify servers live) by even that much.
The device also does an ntp sync every day, at midnight or some such, so a manual force shouldn't be required.
But indeed, forcing a resync to ntp on the device where librespot was playing, then killing librespot and starting again did make these problems go away.
Seems like 0.05s is a little tight for tolerance :-[
@sashahilton00 commented on GitHub (Mar 25, 2019):
#321 should fix this.