Commit 6622d69f authored by Max Kellermann's avatar Max Kellermann

song: added function song_get_duration()

parent 216dff98
...@@ -135,8 +135,7 @@ searchStatsInDirectory(struct song *song, void *data) ...@@ -135,8 +135,7 @@ searchStatsInDirectory(struct song *song, void *data)
if (locate_song_match(song, stats->criteria)) { if (locate_song_match(song, stats->criteria)) {
stats->numberOfSongs++; stats->numberOfSongs++;
if (song->tag->time > 0) stats->playTime += song_get_duration(song);
stats->playTime += song->tag->time;
} }
return 0; return 0;
......
...@@ -212,8 +212,7 @@ player_wait_for_decoder(struct player *player) ...@@ -212,8 +212,7 @@ player_wait_for_decoder(struct player *player)
player_lock(); player_lock();
/* update player_control's song information */ /* update player_control's song information */
pc.total_time = pc.next_song->tag != NULL pc.total_time = song_get_duration(pc.next_song);
? pc.next_song->tag->time : 0;
pc.bit_rate = 0; pc.bit_rate = 0;
audio_format_clear(&pc.audio_format); audio_format_clear(&pc.audio_format);
......
...@@ -80,3 +80,12 @@ song_get_uri(const struct song *song) ...@@ -80,3 +80,12 @@ song_get_uri(const struct song *song)
return g_strconcat(directory_get_path(song->parent), return g_strconcat(directory_get_path(song->parent),
"/", song->uri, NULL); "/", song->uri, NULL);
} }
double
song_get_duration(const struct song *song)
{
if (song->tag == NULL)
return 0;
return song->tag->time;
}
...@@ -69,6 +69,9 @@ song_file_update_inarchive(struct song *song); ...@@ -69,6 +69,9 @@ song_file_update_inarchive(struct song *song);
char * char *
song_get_uri(const struct song *song); song_get_uri(const struct song *song);
double
song_get_duration(const struct song *song);
static inline bool static inline bool
song_in_database(const struct song *song) song_in_database(const struct song *song)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment