From 6ad933982f68f5fcbd1b3179bf5fed26f63aa792 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 28 Aug 2014 06:54:19 +0200 Subject: DetachedSong: use std::chrono::duration for start_ms and end_ms --- src/PlayerThread.cxx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/PlayerThread.cxx') diff --git a/src/PlayerThread.cxx b/src/PlayerThread.cxx index 0aa8d105d..e527a80ba 100644 --- a/src/PlayerThread.cxx +++ b/src/PlayerThread.cxx @@ -291,12 +291,12 @@ Player::StartDecoder(MusicPipe &_pipe) assert(queued || pc.command == PlayerCommand::SEEK); assert(pc.next_song != nullptr); - unsigned start_ms = pc.next_song->GetStartMS(); + SongTime start_time = pc.next_song->GetStartTime(); if (pc.command == PlayerCommand::SEEK) - start_ms += pc.seek_time.ToMS(); + start_time += pc.seek_time; dc.Start(new DetachedSong(*pc.next_song), - start_ms, pc.next_song->GetEndMS(), + start_time.ToMS(), pc.next_song->GetEndTime().ToMS(), buffer, _pipe); } @@ -376,13 +376,13 @@ real_song_duration(const DetachedSong &song, double decoder_duration) back to Song::GetDuration() */ return song.GetDuration(); - const unsigned start_ms = song.GetStartMS(); - const unsigned end_ms = song.GetEndMS(); + const SongTime start_time = song.GetStartTime(); + const SongTime end_time = song.GetEndTime(); - if (end_ms > 0 && end_ms / 1000.0 < decoder_duration) - return (end_ms - start_ms) / 1000.0; + if (end_time.IsPositive() && end_time.ToDoubleS() < decoder_duration) + return (end_time - start_time).ToDoubleS(); - return decoder_duration - start_ms / 1000.0; + return decoder_duration - start_time.ToDoubleS(); } bool @@ -518,7 +518,7 @@ Player::SeekDecoder() { assert(pc.next_song != nullptr); - const unsigned start_ms = pc.next_song->GetStartMS(); + const SongTime start_time = pc.next_song->GetStartTime(); if (!dc.LockIsCurrentSong(*pc.next_song)) { /* the decoder is already decoding the "next" song - @@ -568,7 +568,7 @@ Player::SeekDecoder() where = total_time; } - if (!dc.Seek(where + SongTime::FromMS(start_ms))) { + if (!dc.Seek(where + start_time)) { /* decoder failure */ player_command_finished(pc); return false; -- cgit v1.2.3