diff --git a/core/audio.c b/core/audio.c index 002b37c3..731995d5 100644 --- a/core/audio.c +++ b/core/audio.c @@ -3,7 +3,6 @@ */ #include #include -#include #include #include #include @@ -66,10 +65,8 @@ static struct track *__audio_load_basic(struct track *track, GstState state) static struct track *__audio_load(struct track *track, GstState state) { - if (__audio_load_basic(track, state)) { - history_add(track); + if (__audio_load_basic(track, state)) playlist_add("History", track); - } return track; } diff --git a/core/core.c b/core/core.c index 3590d5c0..4c3606f2 100644 --- a/core/core.c +++ b/core/core.c @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -23,7 +22,6 @@ void core_init(int *argc, char ***argv, struct core_init_data *init) tags_init(); playlist_init(init->playlist_ops); collection_init(); - history_init(init->history_ops); tempq_init(init->tempq_ops); audio_init(argc, argv, init->audio_ops); } @@ -32,7 +30,6 @@ void core_deinit() { audio_deinit(); tempq_deinit(); - history_deinit(); playlist_deinit(); tags_deinit(); filter_deinit(); diff --git a/core/history.c b/core/history.c deleted file mode 100644 index 8a75453e..00000000 --- a/core/history.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2015 (c) Anna Schumaker. - */ -#include - -static struct queue history_queue; -#define HISTORY_FLAGS Q_ENABLED | Q_REPEAT | Q_NO_SORT | Q_ADD_FRONT - - -void history_init(struct queue_ops *history_ops) -{ - queue_init(&history_queue, HISTORY_FLAGS, history_ops, NULL); -} - -void history_deinit() -{ - queue_deinit(&history_queue); -} - -void history_add(struct track *track) -{ - queue_add(&history_queue, track); - queue_iter_set(&history_queue, &history_queue.q_cur, 0); -} - -struct track *history_prev() -{ - return queue_next(&history_queue); -} - -struct queue *history_get_queue() -{ - return &history_queue; -} diff --git a/core/tempq.c b/core/tempq.c index cc285aa5..258873aa 100644 --- a/core/tempq.c +++ b/core/tempq.c @@ -3,7 +3,6 @@ */ #include #include -#include #include #include #include diff --git a/gui/ocarina.c b/gui/ocarina.c index 822c2ee4..5754d3ea 100644 --- a/gui/ocarina.c +++ b/gui/ocarina.c @@ -22,7 +22,6 @@ const static gchar *OCARINA_NAME = "org.gtk.ocarina-debug"; #endif struct core_init_data init_data = { - NULL, &playlist_ops, &tempq_ops, &audio_ops, diff --git a/include/core/core.h b/include/core/core.h index a8f5d1ea..76539d54 100644 --- a/include/core/core.h +++ b/include/core/core.h @@ -7,7 +7,6 @@ struct core_init_data { - struct queue_ops *history_ops; struct queue_ops *playlist_ops; struct queue_ops *tempq_ops; struct audio_ops *audio_ops; diff --git a/include/core/history.h b/include/core/history.h deleted file mode 100644 index 23f3947c..00000000 --- a/include/core/history.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2015 (c) Anna Schumaker. - */ -#ifndef OCARINA_CORE_HISTORY_H -#define OCARINA_CORE_HISTORY_H - -#include - -/* Called to initialize the history queue. */ -void history_init(struct queue_ops *); - -/* Called to deinitialize the history queue. */ -void history_deinit(); - - -/* Called to add a track to the history queue. */ -void history_add(struct track *); - -/* Called to pick a track from the history. */ -struct track *history_prev(); - - -/* Called to access the queue of recent tracks. */ -struct queue *history_get_queue(); - -#endif /* OCARINA_CORE_HISTORY_H */ diff --git a/tests/core/.gitignore b/tests/core/.gitignore index 0c33f740..da8489bc 100644 --- a/tests/core/.gitignore +++ b/tests/core/.gitignore @@ -14,6 +14,5 @@ queue playlists/system playlist collection -history tempq audio diff --git a/tests/core/Sconscript b/tests/core/Sconscript index cb2a5b53..df9778c9 100644 --- a/tests/core/Sconscript +++ b/tests/core/Sconscript @@ -38,7 +38,6 @@ res += [ CoreTest("queue") ] res += SConscript("playlists/Sconscript") res += [ CoreTest("playlist") ] res += [ CoreTest("collection") ] -res += [ CoreTest("history") ] res += [ CoreTest("tempq") ] core_objs += [ env.Object("../../core/core.c") ] diff --git a/tests/core/audio.c b/tests/core/audio.c index 75699f26..a0e13b54 100644 --- a/tests/core/audio.c +++ b/tests/core/audio.c @@ -3,8 +3,8 @@ */ #include #include -#include #include +#include #include #include #include @@ -91,7 +91,7 @@ static void test_playback() for (i = 0; i < 3; i++) { test_loop_equal(audio_load(tracks[i]), (bool)(i == 0), i); - test_loop_equal(queue_size(history_get_queue()), 1, i); + test_loop_equal(playlist_size("History"), 1, i); test_loop_equal(load_count, 1, i); test_loop_equal(state_count, 1, i); test_loop_equal(audio_cur_state(), GST_STATE_PLAYING, i); @@ -123,7 +123,7 @@ static void test_playback() static void test_next() { - struct queue *history_q = history_get_queue(); + struct queue *history_q = playlist_get_queue("History"); struct queue *temp_q = tempq_alloc(0); int i; @@ -163,7 +163,7 @@ static void test_next() static void test_prev() { - struct queue *history_q = history_get_queue(); + struct queue *history_q = playlist_get_queue("History"); struct track *track = queue_at(history_q, 0); state_count = 0; @@ -201,7 +201,7 @@ static void test_prev() void test_autopause() { - struct queue *history_q = history_get_queue(); + struct queue *history_q = playlist_get_queue("History"); int i; audio_pause_after(3); diff --git a/tests/core/history.c b/tests/core/history.c deleted file mode 100644 index 8318d50e..00000000 --- a/tests/core/history.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2015 (c) Anna Schumaker. - */ -#include -#include -#include -#include -#include -#include -#include -#include - -static void test_init() -{ - struct queue *q = history_get_queue(); - - idle_init_sync(); - filter_init(); - tags_init(); - playlist_init(NULL); - collection_init(); - history_init(NULL); - - test_not_equal((void *)q, NULL); - test_equal(queue_has_flag(q, Q_ENABLED), (bool)true); - test_equal(queue_has_flag(q, Q_REPEAT), (bool)true); - test_equal(queue_has_flag(q, Q_NO_SORT), (bool)true); - test_equal(queue_has_flag(q, Q_ADD_FRONT), (bool)true); - test_equal(queue_has_flag(q, Q_SAVE_SORT), (bool)false); - test_equal(queue_has_flag(q, Q_SAVE_FLAGS), (bool)false); - test_equal((void *)q->q_sort, NULL); - test_equal(queue_size(q), 0); - - collection_add("tests/Music/Hyrule Symphony"); - while (idle_run_task()) {}; -} - -static void test_history() -{ - const struct database *track_db = track_db_get(); - struct queue *q = history_get_queue(); - struct track *prev = track_get(0); - struct db_entry *track, *next; - unsigned int i = 0; - - test_equal((void *)history_prev(), NULL); - - /* Add tracks once */ - db_for_each(track, next, track_db) { - history_add(TRACK(track)); - test_loop_equal(queue_size(q), i + 1, i); - test_loop_equal(q->q_cur.it_pos, 0, i); - test_loop_equal((void *)queue_at(q, 0), (void *)TRACK(track), i); - test_loop_equal((void *)history_prev(), (void *)prev, i); - prev = TRACK(track); - i++; - } test_loop_passed(); - test_equal(queue_size(q), track_db->db_size); - - /* Cycle through the history queue. */ - queue_iter_set(q, &q->q_cur, 0); - for (i = 2; i <= track_db->db_size; i++) { - test_loop_equal((void *)history_prev(), - (void *)track_get(track_db->db_size - i), i); - } test_loop_passed(); - - i = 0; - /* Add tracks again, old tracks should remain */ - db_for_each(track, next, track_db) { - history_add(TRACK(track)); - test_loop_equal(queue_size(q), track_db->db_size + i + 1, i); - test_loop_equal((void *)queue_at(q, 0), (void *)TRACK(track), i); - test_loop_equal((void *)queue_at(q, track_db->db_size), - (void *)TRACK(track), i); - i++; - } test_loop_passed(); - test_equal(queue_size(q), 2 * track_db->db_size); - - history_deinit(); - playlist_deinit(); - tags_deinit(); - filter_deinit(); -} - -DECLARE_UNIT_TESTS( - UNIT_TEST("History Initialization", test_init), - UNIT_TEST("History Queue", test_history), -); diff --git a/tests/core/tempq.c b/tests/core/tempq.c index 24f9044a..0890d49d 100644 --- a/tests/core/tempq.c +++ b/tests/core/tempq.c @@ -3,7 +3,6 @@ */ #include #include -#include #include #include #include @@ -18,7 +17,6 @@ static void test_init() tags_init(); playlist_init(NULL); collection_init(); - history_init(NULL); test_equal((void *)tempq_next(), NULL); @@ -161,7 +159,6 @@ static void test_next() test_equal(tempq_count(), 0); tempq_deinit(); - history_deinit(); playlist_deinit(); tags_deinit(); filter_deinit();