From c634f5d5e23db7da238be82f23644f1ac6dc1fa7 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Tue, 29 Sep 2015 09:34:06 -0400 Subject: [PATCH] core/tags/track: Move track_played() out of the track struct Signed-off-by: Anna Schumaker --- core/audio.cpp | 2 +- core/tags/track.cpp | 14 +++++++------- include/core/tags/track.h | 6 +++--- tests/core/tags/track.cpp | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/audio.cpp b/core/audio.cpp index 67518aff..051b9e00 100644 --- a/core/audio.cpp +++ b/core/audio.cpp @@ -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); } diff --git a/core/tags/track.cpp b/core/tags/track.cpp index cfc23527..01bc1e9a 100644 --- a/core/tags/track.cpp +++ b/core/tags/track.cpp @@ -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(); +} diff --git a/include/core/tags/track.h b/include/core/tags/track.h index c6813976..55d2924a 100644 --- a/include/core/tags/track.h +++ b/include/core/tags/track.h @@ -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 */ diff --git a/tests/core/tags/track.cpp b/tests/core/tags/track.cpp index a5c12da6..d34ed4de 100644 --- a/tests/core/tags/track.cpp +++ b/tests/core/tags/track.cpp @@ -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);