From 2efd8ef52ddf880c26d48bcb55eb1fd4c830481a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 28 Aug 2014 12:35:26 +0200 Subject: db/LightSong: use std::chrono::duration for start_ms and end_ms --- src/db/LightSong.cxx | 6 +++--- src/db/LightSong.hxx | 9 +++++---- src/db/plugins/ProxyDatabasePlugin.cxx | 6 +++--- src/db/plugins/simple/Song.cxx | 4 ++-- src/db/plugins/upnp/UpnpDatabasePlugin.cxx | 4 ++-- 5 files changed, 15 insertions(+), 14 deletions(-) (limited to 'src/db') diff --git a/src/db/LightSong.cxx b/src/db/LightSong.cxx index af1e801f8..3e0f361d8 100644 --- a/src/db/LightSong.cxx +++ b/src/db/LightSong.cxx @@ -23,11 +23,11 @@ double LightSong::GetDuration() const { - if (end_ms > 0) - return (end_ms - start_ms) / 1000.0; + if (end_time.IsPositive()) + return (end_time - start_time).ToDoubleS(); if (tag->time <= 0) return 0; - return tag->time - start_ms / 1000.0; + return tag->time - start_time.ToDoubleS(); } diff --git a/src/db/LightSong.hxx b/src/db/LightSong.hxx index add9da855..26f68d18c 100644 --- a/src/db/LightSong.hxx +++ b/src/db/LightSong.hxx @@ -20,6 +20,7 @@ #ifndef MPD_LIGHT_SONG_HXX #define MPD_LIGHT_SONG_HXX +#include "Chrono.hxx" #include "Compiler.h" #include @@ -64,15 +65,15 @@ struct LightSong { time_t mtime; /** - * Start of this sub-song within the file in milliseconds. + * Start of this sub-song within the file. */ - unsigned start_ms; + SongTime start_time; /** - * End of this sub-song within the file in milliseconds. + * End of this sub-song within the file. * Unused if zero. */ - unsigned end_ms; + SongTime end_time; gcc_pure std::string GetURI() const { diff --git a/src/db/plugins/ProxyDatabasePlugin.cxx b/src/db/plugins/ProxyDatabasePlugin.cxx index 0b358c0ba..c6b57d248 100644 --- a/src/db/plugins/ProxyDatabasePlugin.cxx +++ b/src/db/plugins/ProxyDatabasePlugin.cxx @@ -192,10 +192,10 @@ ProxySong::ProxySong(const mpd_song *song) mtime = mpd_song_get_last_modified(song); #if LIBMPDCLIENT_CHECK_VERSION(2,3,0) - start_ms = mpd_song_get_start(song) * 1000; - end_ms = mpd_song_get_end(song) * 1000; + start_time = SongTime::FromS(mpd_song_get_start(song)); + end_time = SongTime::FromS(mpd_song_get_end(song)); #else - start_ms = end_ms = 0; + start_time = end_time = SongTime::zero(); #endif TagBuilder tag_builder; diff --git a/src/db/plugins/simple/Song.cxx b/src/db/plugins/simple/Song.cxx index 9e62d579e..ff7796b30 100644 --- a/src/db/plugins/simple/Song.cxx +++ b/src/db/plugins/simple/Song.cxx @@ -105,7 +105,7 @@ Song::Export() const dest.real_uri = nullptr; dest.tag = &tag; dest.mtime = mtime; - dest.start_ms = start_ms; - dest.end_ms = end_ms; + dest.start_time = SongTime::FromMS(start_ms); + dest.end_time = SongTime::FromMS(end_ms); return dest; } diff --git a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx index 66951f402..e16f230fb 100644 --- a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx +++ b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx @@ -66,7 +66,7 @@ public: real_uri = real_uri2.c_str(); tag = &tag2; mtime = 0; - start_ms = end_ms = 0; + start_time = end_time = SongTime::zero(); } }; @@ -360,7 +360,7 @@ visitSong(const UPnPDirObject &meta, const char *path, song.real_uri = meta.url.c_str(); song.tag = &meta.tag; song.mtime = 0; - song.start_ms = song.end_ms = 0; + song.start_time = song.end_time = SongTime::zero(); return !selection.Match(song) || visit_song(song, error); } -- cgit v1.2.3