diff options
author | Max Kellermann <max@duempel.org> | 2009-12-26 13:56:35 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-12-26 13:56:35 +0100 |
commit | 6622d69fda7cd885e4695e865a9f9c70392257e2 (patch) | |
tree | df8e9a871b9709bb741dc1bdc7fb5c1a3385e34e /src | |
parent | 216dff98d2f558f4095de50c6a848e3b074c70e6 (diff) | |
download | mpd-6622d69fda7cd885e4695e865a9f9c70392257e2.tar.gz mpd-6622d69fda7cd885e4695e865a9f9c70392257e2.tar.xz mpd-6622d69fda7cd885e4695e865a9f9c70392257e2.zip |
song: added function song_get_duration()
Diffstat (limited to '')
-rw-r--r-- | src/dbUtils.c | 3 | ||||
-rw-r--r-- | src/player_thread.c | 3 | ||||
-rw-r--r-- | src/song.c | 9 | ||||
-rw-r--r-- | src/song.h | 3 |
4 files changed, 14 insertions, 4 deletions
diff --git a/src/dbUtils.c b/src/dbUtils.c index 359c8db47..e56b7438d 100644 --- a/src/dbUtils.c +++ b/src/dbUtils.c @@ -135,8 +135,7 @@ searchStatsInDirectory(struct song *song, void *data) if (locate_song_match(song, stats->criteria)) { stats->numberOfSongs++; - if (song->tag->time > 0) - stats->playTime += song->tag->time; + stats->playTime += song_get_duration(song); } return 0; diff --git a/src/player_thread.c b/src/player_thread.c index 83f348d19..1a92a3182 100644 --- a/src/player_thread.c +++ b/src/player_thread.c @@ -212,8 +212,7 @@ player_wait_for_decoder(struct player *player) player_lock(); /* update player_control's song information */ - pc.total_time = pc.next_song->tag != NULL - ? pc.next_song->tag->time : 0; + pc.total_time = song_get_duration(pc.next_song); pc.bit_rate = 0; audio_format_clear(&pc.audio_format); diff --git a/src/song.c b/src/song.c index faaa208ca..bc6cb11c4 100644 --- a/src/song.c +++ b/src/song.c @@ -80,3 +80,12 @@ song_get_uri(const struct song *song) return g_strconcat(directory_get_path(song->parent), "/", song->uri, NULL); } + +double +song_get_duration(const struct song *song) +{ + if (song->tag == NULL) + return 0; + + return song->tag->time; +} diff --git a/src/song.h b/src/song.h index c8e80b0d1..832f3d700 100644 --- a/src/song.h +++ b/src/song.h @@ -69,6 +69,9 @@ song_file_update_inarchive(struct song *song); char * song_get_uri(const struct song *song); +double +song_get_duration(const struct song *song); + static inline bool song_in_database(const struct song *song) { |