diff --git a/core/audio.cpp b/core/audio.cpp index 03929a3a..67518aff 100644 --- a/core/audio.cpp +++ b/core/audio.cpp @@ -84,7 +84,7 @@ void audio :: init() file_open(&f_cur_track, OPEN_READ); file_readf(&f_cur_track, "%u", &id); file_close(&f_cur_track); - audio :: load_track(tags :: get_track(id)); + audio :: load_track(track_get(id)); } } diff --git a/core/library.cpp b/core/library.cpp index 0e94c6ab..3acaea75 100644 --- a/core/library.cpp +++ b/core/library.cpp @@ -145,7 +145,7 @@ static void validate_library(struct library *&library) struct track *track; for (unsigned int i = 0; i < tags :: track_size(); i++) { - track = tags :: get_track(i); + track = track_get(i); if (!track || (track->library() != library)) continue; @@ -169,7 +169,7 @@ void collection :: init() library_q.load(); for (unsigned int i = 0; i < tags :: track_size(); i++) { - track = tags :: get_track(i); + track = track_get(i); if (track && (track->library()->li_enabled)) library_q.add(track); } @@ -228,7 +228,7 @@ void collection :: set_enabled(struct library *library, bool enabled) library_set_enabled(library, enabled); for (unsigned int i = 0; i < tags :: track_size(); i++) { - track = tags :: get_track(i); + track = track_get(i); if (track && (track->library() == library)) { if (enabled) library_q.add(track); diff --git a/core/playlist.cpp b/core/playlist.cpp index 5c611c7f..48c37bf0 100644 --- a/core/playlist.cpp +++ b/core/playlist.cpp @@ -28,7 +28,7 @@ public: clear(); set_for_each(&ent->ie_set, &it) - add(tags :: get_track(it.it_val)); + add(track_get(it.it_val)); } unsigned int find_average_count() @@ -37,7 +37,7 @@ public: unsigned int total = 0, count = 0; for (unsigned int i = 0; i < tags :: track_size(); i++) { - track = tags :: get_track(i); + track = track_get(i); if (track != NULL) { total += track->count(); count++; @@ -69,7 +69,7 @@ public: clear(); for (unsigned int i = 0; i < tags :: track_size(); i++) { - track = tags :: get_track(i); + track = track_get(i); if (track != NULL) dynamic_add(name, track, avg); } @@ -95,7 +95,7 @@ void playlist :: init() return; set_for_each(&ent->ie_set, &it) - collection :: get_queue()->del(tags :: get_track(it.it_val)); + collection :: get_queue()->del(track_get(it.it_val)); } bool playlist :: has(struct track *track, const std::string &name) diff --git a/core/queue.cpp b/core/queue.cpp index d339f031..71b5bb7d 100644 --- a/core/queue.cpp +++ b/core/queue.cpp @@ -45,7 +45,7 @@ void Queue :: read(file &file) _tracks.resize(n); for (unsigned int i = 0; i < n; i++) { file_readf(&file, "%u", &id); - _tracks[i] = tags :: get_track(id); + _tracks[i] = track_get(id); _length += _tracks[i]->length(); } } diff --git a/core/tags/track.cpp b/core/tags/track.cpp index dea265a7..0bb55862 100644 --- a/core/tags/track.cpp +++ b/core/tags/track.cpp @@ -164,11 +164,6 @@ struct track *tags :: add_track(struct album *album, struct artist *artist, path, name, length, track)); } -struct track *tags :: get_track(const unsigned int index) -{ - return db_at(&track_db, index); -} - void tags :: remove_track(struct track *track) { db_remove(&track_db, track); @@ -185,6 +180,11 @@ void tags :: remove_library_tracks(struct library *library) tags :: commit_track_db(); } +struct track *track_get(const unsigned int index) +{ + return db_at(&track_db, index); +} + unsigned int tags :: track_size() { return db_actual_size(&track_db); diff --git a/gui/collection.cpp b/gui/collection.cpp index e8a3acd0..36ac9745 100644 --- a/gui/collection.cpp +++ b/gui/collection.cpp @@ -39,7 +39,7 @@ public: tab_selected_ids(ids); for (unsigned int i = 0; i < ids.size(); i++) - playlist :: add(tags :: get_track(ids[i]), "Banned"); + playlist :: add(track_get(ids[i]), "Banned"); return true; } diff --git a/gui/manager.cpp b/gui/manager.cpp index 63fcb0cd..f2a8a5f9 100644 --- a/gui/manager.cpp +++ b/gui/manager.cpp @@ -95,7 +95,7 @@ static void remove_banned_tracks() return; set_for_each(&ent->ie_set, &it) - collection :: get_queue()->del(tags :: get_track(it.it_val)); + collection :: get_queue()->del(track_get(it.it_val)); } diff --git a/gui/playlist.cpp b/gui/playlist.cpp index 86b10796..294baa13 100644 --- a/gui/playlist.cpp +++ b/gui/playlist.cpp @@ -115,7 +115,7 @@ public: tab_selected_ids(ids); for (unsigned int i = 0; i < ids.size(); i++) - playlist :: del(tags :: get_track(ids[i]), cur); + playlist :: del(track_get(ids[i]), cur); return true; } } *p_tab; diff --git a/gui/queue/model.cpp b/gui/queue/model.cpp index 4f32dcff..b8dd3158 100644 --- a/gui/queue/model.cpp +++ b/gui/queue/model.cpp @@ -49,7 +49,7 @@ void QueueModel::on_row_changed(unsigned int row) void QueueModel::on_path_selected(const Gtk::TreePath &path) { - audio :: load_track(tags :: get_track(path_to_id(path))); + audio :: load_track(track_get(path_to_id(path))); _queue->track_selected(path[0]); audio :: play(); } diff --git a/gui/tabs.cpp b/gui/tabs.cpp index 52a1a482..baa2b9f2 100644 --- a/gui/tabs.cpp +++ b/gui/tabs.cpp @@ -160,7 +160,7 @@ void Tab :: tab_queue_add(Queue *pq) tab_selected_ids(ids); for (unsigned int i = 0; i < ids.size(); i++) - pq->add(tags :: get_track(ids[i])); + pq->add(track_get(ids[i])); } bool Tab :: tab_queue_selected(bool random) @@ -190,7 +190,7 @@ bool Tab :: tab_add_to_playlist(const std::string &playlist) tab_selected_ids(ids); for (unsigned int i = 0; i < ids.size(); i++) - playlist :: add(tags :: get_track(ids[i]), playlist); + playlist :: add(track_get(ids[i]), playlist); return true; } diff --git a/include/core/tags/track.h b/include/core/tags/track.h index 36f34eda..cb4854a3 100644 --- a/include/core/tags/track.h +++ b/include/core/tags/track.h @@ -138,14 +138,6 @@ namespace tags struct library *, const std::string &, const std::string &, unsigned int, unsigned int); - /** - * Called to look up a Track tag by tag index. - * - * @param index The index of the Track tag. - * @return A matching Track tag, or NULL. - */ - struct track *get_track(const unsigned int); - /** * Called to remove a Track tag from the database. * @@ -172,4 +164,8 @@ namespace tags void commit_track_db(); } + +/* Called to get a track tag with a specific index. */ +struct track *track_get(const unsigned int); + #endif /* OCARINA_CORE_TAGS_TRACK_H */ diff --git a/tests/core/audio.cpp b/tests/core/audio.cpp index a5854b7e..1aa71bb6 100644 --- a/tests/core/audio.cpp +++ b/tests/core/audio.cpp @@ -136,7 +136,7 @@ void test_track_controls() audio :: load_track(track); test_not_equal(audio :: current_track(), track); - track = tags :: get_track(0); + track = track_get(0); audio :: seek_to(4242); audio :: load_track(track); test_equal(driver->is_playing(), true); diff --git a/tests/core/deck.cpp b/tests/core/deck.cpp index 977c7b70..f57625a6 100644 --- a/tests/core/deck.cpp +++ b/tests/core/deck.cpp @@ -116,7 +116,7 @@ static void test_next_prev() q0->unset_flag(Q_RANDOM); for (unsigned int i = 0; i < 4; i++) - q0->add(tags :: get_track(i)); + q0->add(track_get(i)); test_not_equal(q, Q_NULL); test_equal(q->size(), (unsigned)0); diff --git a/tests/core/playlist.cpp b/tests/core/playlist.cpp index b4030051..2a0fa40c 100644 --- a/tests/core/playlist.cpp +++ b/tests/core/playlist.cpp @@ -66,19 +66,19 @@ static void test_add() playlist :: select("Favorites"); - playlist :: add(tags :: get_track(5), "Banned"); + playlist :: add(track_get(5), "Banned"); ent = playlist :: get_tracks("Banned"); test_equal(set_size(&ent->ie_set), (size_t)5); test_equal(q->size(), (unsigned)8); test_equal(l->size(), (unsigned)19); - playlist :: add(tags :: get_track(16), "Favorites"); - playlist :: add(tags :: get_track(5), "Favorites"); + playlist :: add(track_get(16), "Favorites"); + playlist :: add(track_get(5), "Favorites"); ent = playlist :: get_tracks("Favorites"); test_equal(set_size(&ent->ie_set), (size_t)9); test_equal(q->size(), (unsigned)9); - playlist :: add(tags :: get_track(6), "No Playlist"); + playlist :: add(track_get(6), "No Playlist"); test_equal(playlist :: get_tracks("No Playlist"), IDX_NULL); } @@ -88,18 +88,18 @@ static void test_delete() Queue *q = playlist :: get_queue(); Queue *l = collection :: get_queue(); - playlist :: del(tags :: get_track(5), "Banned"); + playlist :: del(track_get(5), "Banned"); ent = playlist :: get_tracks("Banned"); test_equal(set_size(&ent->ie_set), (size_t)4); test_equal(q->size(), (unsigned)9); test_equal(l->size(), (unsigned)20); - playlist :: del(tags :: get_track(5), "Favorites"); + playlist :: del(track_get(5), "Favorites"); ent = playlist :: get_tracks("Favorites"); test_equal(set_size(&ent->ie_set), (size_t)8); test_equal(q->size(), (unsigned)8); - playlist :: del(tags :: get_track(6), "No Playlist"); + playlist :: del(track_get(6), "No Playlist"); test_equal(playlist :: get_tracks("No Playlist"), IDX_NULL); } @@ -109,13 +109,13 @@ static void test_has() struct track *track; for (unsigned int i = 0; i < 24; i++) { - track = tags :: get_track(i); + track = track_get(i); test_loop_equal(playlist :: has(track, "Banned"), (i <= 3) ? true : false, i); } test_loop_passed(); for (unsigned int i = 0; i < 24; i++) { - track = tags :: get_track(i); + track = track_get(i); test_loop_equal(playlist :: has(track, "Favorites"), (i >= 16) ? true : false, i); } test_loop_passed(); diff --git a/tests/core/queue.cpp b/tests/core/queue.cpp index 6e841631..6ad1ad75 100644 --- a/tests/core/queue.cpp +++ b/tests/core/queue.cpp @@ -99,7 +99,7 @@ void test_add_remove() /* Add tracks */ for (unsigned int i = 0; i < 24; i++) { - track = tags :: get_track(i); + track = track_get(i); expected += track->length(); test_loop_equal(q.add(track), i, i); test_loop_equal(count_add, i + 1, i); @@ -110,7 +110,7 @@ void test_add_remove() /* Add everything again */ for (unsigned int i = 24; i < 48; i++) { - track = tags :: get_track(i - 24); + track = track_get(i - 24); expected += track->length(); test_loop_equal(q.add(track), i, i); test_loop_equal(count_add, i + 1, i); @@ -122,7 +122,7 @@ void test_add_remove() /* Test removing multiple tracks at once */ count_del = 0; for (unsigned int i = 0; i < 12; i++) { - track = tags :: get_track(i); + track = track_get(i); q.del(track); expected -= track->length() * 2; test_loop_equal(count_del, (i + 1) * 2, i); @@ -156,7 +156,7 @@ void test_add_remove() static void test_fill_q(TestQueue *q) { for (unsigned int i = 0; i < 24; i++) - q->add(tags :: get_track(i)); + q->add(track_get(i)); } void test_updated() @@ -167,12 +167,12 @@ void test_updated() test_fill_q(&q); for (unsigned int i = 0; i < 24; i++) { - q.updated(tags :: get_track(i)); + q.updated(track_get(i)); test_loop_equal(last_update, i, i); test_loop_equal(count_updated, i + 1, i); } test_loop_passed(); - track = tags :: get_track(0); + track = track_get(0); q.add(track); q.add(track); q.updated(track); diff --git a/tests/core/tags/track.cpp b/tests/core/tags/track.cpp index b185b821..846f742a 100644 --- a/tests/core/tags/track.cpp +++ b/tests/core/tags/track.cpp @@ -141,9 +141,9 @@ static void test_track_tag_lookup() test_equal(tags :: track_size(), b->index() + 1); - test_equal(tags :: get_track(a->index()), a); - test_equal(tags :: get_track(a->index() + 1), b); - test_equal(tags :: get_track(a->index() + 2), (struct track *)NULL); + test_equal(track_get(a->index()), a); + test_equal(track_get(a->index() + 1), b); + test_equal(track_get(a->index() + 2), (struct track *)NULL); test_track_tag_load_db(0); tags :: commit_track_db(); @@ -152,7 +152,7 @@ static void test_track_tag_lookup() index = a->index(); tags :: remove_track(a); - test_equal(tags :: get_track(index), (struct track *)NULL); + test_equal(track_get(index), (struct track *)NULL); test_track_tag_load_db(2); tags :: commit_track_db(); test_track_tag_load_db(1);