core/tags/track: Move track_played() out of the track struct

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-09-29 09:34:06 -04:00
parent fb4933e418
commit c634f5d5e2
4 changed files with 12 additions and 12 deletions

View File

@ -66,7 +66,7 @@ AudioDriver :: ~AudioDriver()
void AudioDriver :: eos()
{
if (cur_track) {
cur_track->played();
track_played(cur_track);
collection :: get_queue()->updated(cur_track);
}

View File

@ -87,13 +87,6 @@ const std::string track :: primary_key() const
return make_key(tr_library, tr_path);
}
void track :: played()
{
tr_count++;
date_today(&tr_date);
track_db_commit();
}
void track :: read(file &file)
{
unsigned int library_id, artist_id, album_id, genre_id;
@ -185,3 +178,10 @@ struct track *track_get(const unsigned int index)
{
return db_at(&track_db, index);
}
void track_played(struct track *track)
{
track->tr_count++;
date_today(&track->tr_date);
track_db_commit();
}

View File

@ -76,9 +76,6 @@ struct track : public GenericTag {
*/
const std::string primary_key() const;
/** Increment Track::_count and set Track::_date to today's date. */
void played();
/**
* Read track data from file.
@ -122,4 +119,7 @@ void track_remove_all(struct library *);
/* Called to get a track tag with a specific index. */
struct track *track_get(const unsigned int);
/* Called to mark a track tag as played. */
void track_played(struct track *);
#endif /* OCARINA_CORE_TAGS_TRACK_H */

View File

@ -187,7 +187,7 @@ static void test_track_tag_locale()
test_equal(track->tr_count, (unsigned)0);
test_equal(track->date(), "Never");
track->played();
track_played(track);
test_equal(track->tr_count, (unsigned)1);
test_equal(track->date(), date);
g_free(date);