feelfreelinux / cspot

A Spotify Connect player targeting, but not limited to embedded devices (ESP32).
Other
460 stars 43 forks source link

"replace frame" requires updating position #161

Closed philippe44 closed 8 months ago

philippe44 commented 9 months ago

When a "replace frame" request is received, the current track is part of the updated tracks list and cspot forces a reload at the current position. But the position is what is in frame's state, and it's not taking into account elapsed time since last measure.

FLUSH is a bit of a weird event meaning that after it, we'll get PLAYBACK_START and PLAY_PAUSE as usual but we shall NOT call notifyAudioReachedPlayback and thus we won't get TRACK_INFO. I guess it's ... flush, i.e. everything will restart the same so you can keep what you have memorized. I understand why you need to reload the current track as the n+1 might already be in buffers and we want to flush everything >= n+1, but it means that there is an audio interruption every time we add/remove something from the queue. I guess otherwise FLUSH would have to have a different meaning, i.e. "get rid of everything except the current track" and that's complicated.

Anyway, please don't change that now 😄 but I originally missed the idea.

NB: There is still a mysterious case where the current track might not be re-sent in the list by Spotify but I can't find a way to reproduce that. It does not seem linked to the fact that the current track has already been fully received or not.

feelfreelinux commented 8 months ago

LGTM, thanks a lot :)