From 90cdfd4cbdb9be3dca9dedcfd51b48acb24cbdcb Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Thu, 29 Oct 2015 02:43:39 -0400 Subject: [PATCH] core/tags/track: Move track_path() out of the track struct Signed-off-by: Anna Schumaker --- core/library.cpp | 2 +- core/tags/track.cpp | 14 +++++++------- gui/gst.cpp | 4 ++-- gui/queue/model.cpp | 2 +- include/core/tags/track.h | 6 +++--- tests/core/audio.cpp | 2 +- tests/core/tags/track.cpp | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/core/library.cpp b/core/library.cpp index 7ab3c4af..f2011337 100644 --- a/core/library.cpp +++ b/core/library.cpp @@ -148,7 +148,7 @@ static void validate_library(struct library *&library) if (track->tr_library != library) continue; - if (g_file_test(track->path().c_str(), G_FILE_TEST_EXISTS) == false) { + if (g_file_test(track_path(track).c_str(), G_FILE_TEST_EXISTS) == false) { library_q.del(track); track_remove(track); } diff --git a/core/tags/track.cpp b/core/tags/track.cpp index 01bc1e9a..e6f9a28a 100644 --- a/core/tags/track.cpp +++ b/core/tags/track.cpp @@ -75,13 +75,6 @@ const std::string track :: date() const return res; } -const std::string track :: path() const -{ - if (tr_library) - return library_file(tr_library, tr_path); - return ""; -} - const std::string track :: primary_key() const { return make_key(tr_library, tr_path); @@ -179,6 +172,13 @@ struct track *track_get(const unsigned int index) return db_at(&track_db, index); } +const std::string track_path(struct track *track) +{ + if (track->tr_library) + return library_file(track->tr_library, track->tr_path); + return ""; +} + void track_played(struct track *track) { track->tr_count++; diff --git a/gui/gst.cpp b/gui/gst.cpp index 295eb337..8d9a63a7 100644 --- a/gui/gst.cpp +++ b/gui/gst.cpp @@ -59,7 +59,7 @@ class GSTDriver : public AudioDriver public: void load(struct track *track) { - gchar *uri = gst_filename_to_uri(track->path().c_str(), NULL); + gchar *uri = gst_filename_to_uri(track_path(track).c_str(), NULL); gchar *len = string_sec2str(track->tr_length); gst_change_state(GST_STATE_NULL); @@ -141,7 +141,7 @@ static void parse_gst_error(GstMessage *error) gst_message_parse_error(error, &err, NULL); if (track) - g_print("Error playing file: %s\n", track->path().c_str()); + g_print("Error playing file: %s\n", track_path(track).c_str()); g_print("Error: %s\n", err->message); g_error_free(err); } diff --git a/gui/queue/model.cpp b/gui/queue/model.cpp index 06b21e5a..1e51ba55 100644 --- a/gui/queue/model.cpp +++ b/gui/queue/model.cpp @@ -129,7 +129,7 @@ void QueueModel::get_value_vfunc(const Gtk::TreeIter &iter, int column, case 8: return set_val(track->date(), value); case 9: - return set_val(Glib::Markup::escape_text(track->path()), value); + return set_val(Glib::Markup::escape_text(track_path(track)), value); } } diff --git a/include/core/tags/track.h b/include/core/tags/track.h index 55d2924a..e08db68e 100644 --- a/include/core/tags/track.h +++ b/include/core/tags/track.h @@ -65,9 +65,6 @@ struct track : public GenericTag { */ const std::string date() const; - /** @return The full path of this track. */ - const std::string path() const; - /** * A track's primary key is the concatenation of the library index * and the relative path. @@ -119,6 +116,9 @@ 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 find the full path of the track tag. */ +const std::string track_path(struct track *); + /* Called to mark a track tag as played. */ void track_played(struct track *); diff --git a/tests/core/audio.cpp b/tests/core/audio.cpp index 1aa71bb6..78dde19b 100644 --- a/tests/core/audio.cpp +++ b/tests/core/audio.cpp @@ -23,7 +23,7 @@ public: void load(struct track *track) { - cur_file = track->path(); + cur_file = track_path(track); playing = false; cur_pos = 0; } diff --git a/tests/core/tags/track.cpp b/tests/core/tags/track.cpp index d34ed4de..c0465947 100644 --- a/tests/core/tags/track.cpp +++ b/tests/core/tags/track.cpp @@ -33,7 +33,7 @@ static void test_track_tag_default() test_equal(track.lowercase(), (std::string)""); test_equal(track.primary_key(), (std::string)""); test_equal(track.date(), (std::string)"Never"); - test_equal(track.path(), (std::string)""); + test_equal(track_path(&track), (std::string)""); test_equal(track.tr_track, (unsigned)0); test_equal(track.tr_length, (unsigned)0); @@ -50,7 +50,7 @@ static void verify_track_tag(struct track *track, unsigned int size) test_equal(track->name(), (std::string)"Legend of Zelda Medley"); test_equal(track->lowercase(), (std::string)"legend of zelda medley"); test_equal(track->date(), (std::string)"Never"); - test_equal(track->path(), (std::string)MUSIC_DIR + "/Hyrule Symphony/13 - Legend of Zelda Medley.mp3"); + test_equal(track_path(track), (std::string)MUSIC_DIR + "/Hyrule Symphony/13 - Legend of Zelda Medley.mp3"); test_equal(track->primary_key(), (std::string)"0/Hyrule Symphony/13 - Legend of Zelda Medley.mp3"); test_equal(track->tr_track, (unsigned)13);