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

@@ -20,14 +20,16 @@
#include "LightSong.hxx"
#include "tag/Tag.hxx"
double
SignedSongTime
LightSong::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;
if (tag->time <= 0)
return 0;
b = SongTime(tag->duration);
}
return tag->time - start_time.ToDoubleS();
return SignedSongTime(b - a);
}