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

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-10-29 02:43:39 -04:00
parent c634f5d5e2
commit 90cdfd4cbd
7 changed files with 17 additions and 17 deletions

View File

@ -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);
}

View File

@ -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++;

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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 *);

View File

@ -23,7 +23,7 @@ public:
void load(struct track *track)
{
cur_file = track->path();
cur_file = track_path(track);
playing = false;
cur_pos = 0;
}

View File

@ -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);