Tag: use SignedSongTime for the song duration

This commit is contained in:
Max Kellermann
2014-08-29 12:14:27 +02:00
parent 8ce30c6a69
commit 7c25d83f1c
25 changed files with 103 additions and 84 deletions

View File

@@ -58,11 +58,16 @@ DetachedSong::IsInDatabase() const
return !uri_has_scheme(_uri) && !PathTraitsUTF8::IsAbsolute(_uri);
}
double
SignedSongTime
DetachedSong::GetDuration() const
{
if (end_time.IsPositive())
return (end_time - start_time).ToDoubleS();
SongTime a = start_time, b = end_time;
if (!b.IsPositive()) {
if (tag.duration.IsNegative())
return tag.duration;
return tag.time - start_time.ToDoubleS();
b = SongTime(tag.duration);
}
return SignedSongTime(b - a);
}