Tag: use SignedSongTime for the song duration
This commit is contained in:
@@ -199,7 +199,10 @@ ProxySong::ProxySong(const mpd_song *song)
|
||||
#endif
|
||||
|
||||
TagBuilder tag_builder;
|
||||
tag_builder.SetTime(mpd_song_get_duration(song));
|
||||
|
||||
const unsigned duration = mpd_song_get_duration(song);
|
||||
if (duration > 0)
|
||||
tag_builder.SetDuration(SignedSongTime::FromS(duration));
|
||||
|
||||
for (const auto *i = &tag_table[0]; i->d != TAG_NUM_OF_ITEM_TYPES; ++i)
|
||||
Copy(tag_builder, i->d, song, i->s);
|
||||
|
||||
@@ -59,28 +59,28 @@ ParseItemClass(const char *name, size_t length)
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
static int
|
||||
static SignedSongTime
|
||||
ParseDuration(const char *duration)
|
||||
{
|
||||
char *endptr;
|
||||
|
||||
unsigned result = ParseUnsigned(duration, &endptr);
|
||||
if (endptr == duration || *endptr != ':')
|
||||
return 0;
|
||||
return SignedSongTime::Negative();
|
||||
|
||||
result *= 60;
|
||||
duration = endptr + 1;
|
||||
result += ParseUnsigned(duration, &endptr);
|
||||
if (endptr == duration || *endptr != ':')
|
||||
return 0;
|
||||
return SignedSongTime::Negative();
|
||||
|
||||
result *= 60;
|
||||
duration = endptr + 1;
|
||||
result += ParseUnsigned(duration, &endptr);
|
||||
if (endptr == duration || *endptr != 0)
|
||||
return 0;
|
||||
return SignedSongTime::Negative();
|
||||
|
||||
return result;
|
||||
return SignedSongTime::FromS(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,7 +183,7 @@ protected:
|
||||
const char *duration =
|
||||
GetAttribute(attrs, "duration");
|
||||
if (duration != nullptr)
|
||||
tag.SetTime(ParseDuration(duration));
|
||||
tag.SetDuration(ParseDuration(duration));
|
||||
|
||||
state = RES;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user