core/tags/track: Move track_path() out of the track struct
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
c634f5d5e2
commit
90cdfd4cbd
|
@ -148,7 +148,7 @@ static void validate_library(struct library *&library)
|
||||||
if (track->tr_library != library)
|
if (track->tr_library != library)
|
||||||
continue;
|
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);
|
library_q.del(track);
|
||||||
track_remove(track);
|
track_remove(track);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,13 +75,6 @@ const std::string track :: date() const
|
||||||
return res;
|
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
|
const std::string track :: primary_key() const
|
||||||
{
|
{
|
||||||
return make_key(tr_library, tr_path);
|
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);
|
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)
|
void track_played(struct track *track)
|
||||||
{
|
{
|
||||||
track->tr_count++;
|
track->tr_count++;
|
||||||
|
|
|
@ -59,7 +59,7 @@ class GSTDriver : public AudioDriver
|
||||||
public:
|
public:
|
||||||
void load(struct track *track)
|
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);
|
gchar *len = string_sec2str(track->tr_length);
|
||||||
|
|
||||||
gst_change_state(GST_STATE_NULL);
|
gst_change_state(GST_STATE_NULL);
|
||||||
|
@ -141,7 +141,7 @@ static void parse_gst_error(GstMessage *error)
|
||||||
gst_message_parse_error(error, &err, NULL);
|
gst_message_parse_error(error, &err, NULL);
|
||||||
|
|
||||||
if (track)
|
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_print("Error: %s\n", err->message);
|
||||||
g_error_free(err);
|
g_error_free(err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ void QueueModel::get_value_vfunc(const Gtk::TreeIter &iter, int column,
|
||||||
case 8:
|
case 8:
|
||||||
return set_val(track->date(), value);
|
return set_val(track->date(), value);
|
||||||
case 9:
|
case 9:
|
||||||
return set_val(Glib::Markup::escape_text(track->path()), value);
|
return set_val(Glib::Markup::escape_text(track_path(track)), value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,9 +65,6 @@ struct track : public GenericTag {
|
||||||
*/
|
*/
|
||||||
const std::string date() const;
|
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
|
* A track's primary key is the concatenation of the library index
|
||||||
* and the relative path.
|
* and the relative path.
|
||||||
|
@ -119,6 +116,9 @@ void track_remove_all(struct library *);
|
||||||
/* Called to get a track tag with a specific index. */
|
/* Called to get a track tag with a specific index. */
|
||||||
struct track *track_get(const unsigned int);
|
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. */
|
/* Called to mark a track tag as played. */
|
||||||
void track_played(struct track *);
|
void track_played(struct track *);
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ public:
|
||||||
|
|
||||||
void load(struct track *track)
|
void load(struct track *track)
|
||||||
{
|
{
|
||||||
cur_file = track->path();
|
cur_file = track_path(track);
|
||||||
playing = false;
|
playing = false;
|
||||||
cur_pos = 0;
|
cur_pos = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ static void test_track_tag_default()
|
||||||
test_equal(track.lowercase(), (std::string)"");
|
test_equal(track.lowercase(), (std::string)"");
|
||||||
test_equal(track.primary_key(), (std::string)"");
|
test_equal(track.primary_key(), (std::string)"");
|
||||||
test_equal(track.date(), (std::string)"Never");
|
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_track, (unsigned)0);
|
||||||
test_equal(track.tr_length, (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->name(), (std::string)"Legend of Zelda Medley");
|
||||||
test_equal(track->lowercase(), (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->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->primary_key(), (std::string)"0/Hyrule Symphony/13 - Legend of Zelda Medley.mp3");
|
||||||
|
|
||||||
test_equal(track->tr_track, (unsigned)13);
|
test_equal(track->tr_track, (unsigned)13);
|
||||||
|
|
Loading…
Reference in New Issue