1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-14 10:24:19 +01:00

Check if track position is valid before sending. Bump protocol version.

This commit is contained in:
Andreas 2013-12-08 20:19:25 +01:00
parent 3122593ab4
commit 03a4145082
3 changed files with 8 additions and 2 deletions

View File

@ -276,7 +276,7 @@ message RequestRateSong {
// The message itself
message Message {
optional int32 version = 1 [default=12];
optional int32 version = 1 [default=13];
optional MsgType type = 2 [default=UNKNOWN]; // What data is in the message?
optional RequestConnect request_connect = 21;

View File

@ -509,11 +509,16 @@ void OutgoingDataCreator::UpdateTrackPosition() {
pb::remote::Message msg;
msg.set_type(pb::remote::UPDATE_TRACK_POSITION);
const int position = std::floor(
int position = std::floor(
float(app_->player()->engine()->position_nanosec()) / kNsecPerSec + 0.5);
if (app_->player()->engine()->position_nanosec() > current_song_.length_nanosec())
position = last_track_position_;
msg.mutable_response_update_track_position()->set_position(position);
last_track_position_ = position;
SendDataToClients(&msg);
}

View File

@ -85,6 +85,7 @@ private:
QTimer* track_position_timer_;
int keep_alive_timeout_;
QMap<RemoteClient*, QQueue<DownloadItem> > download_queue_;
int last_track_position_;
boost::scoped_ptr<UltimateLyricsReader> ultimate_reader_;
ProviderList provider_list_;