Browse Source

core/history: Remove unused queue

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
keep-around/e578e0e6dd9eda33df63387e0a4d5e362d8c7528
Anna Schumaker 6 years ago
committed by Anna Schumaker
parent
commit
34447007f9
  1. 5
      core/audio.c
  2. 3
      core/core.c
  3. 34
      core/history.c
  4. 1
      core/tempq.c
  5. 1
      gui/ocarina.c
  6. 1
      include/core/core.h
  7. 26
      include/core/history.h
  8. 1
      tests/core/.gitignore
  9. 1
      tests/core/Sconscript
  10. 10
      tests/core/audio.c
  11. 88
      tests/core/history.c
  12. 3
      tests/core/tempq.c

5
core/audio.c

@ -3,7 +3,6 @@
*/
#include <core/audio.h>
#include <core/collection.h>
#include <core/history.h>
#include <core/idle.h>
#include <core/playlist.h>
#include <core/tempq.h>
@ -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;
}

3
core/core.c

@ -5,7 +5,6 @@
#include <core/core.h>
#include <core/collection.h>
#include <core/filter.h>
#include <core/history.h>
#include <core/idle.h>
#include <core/playlist.h>
#include <core/tags/tags.h>
@ -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();

34
core/history.c

@ -1,34 +0,0 @@
/*
* Copyright 2015 (c) Anna Schumaker.
*/
#include <core/history.h>
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;
}

1
core/tempq.c

@ -3,7 +3,6 @@
*/
#include <core/collection.h>
#include <core/file.h>
#include <core/history.h>
#include <core/idle.h>
#include <core/tempq.h>
#include <glib.h>

1
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,

1
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;

26
include/core/history.h

@ -1,26 +0,0 @@
/*
* Copyright 2015 (c) Anna Schumaker.
*/
#ifndef OCARINA_CORE_HISTORY_H
#define OCARINA_CORE_HISTORY_H
#include <core/queue.h>
/* 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 */

1
tests/core/.gitignore

@ -14,6 +14,5 @@ queue
playlists/system
playlist
collection
history
tempq
audio

1
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") ]

10
tests/core/audio.c

@ -3,8 +3,8 @@
*/
#include <core/audio.h>
#include <core/collection.h>
#include <core/history.h>
#include <core/idle.h>
#include <core/playlist.h>
#include <core/tempq.h>
#include <core/core.h>
#include <tests/test.h>
@ -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);

88
tests/core/history.c

@ -1,88 +0,0 @@
/*
* Copyright 2015 (c) Anna Schumaker.
*/
#include <core/history.h>
#include <core/collection.h>
#include <core/filter.h>
#include <core/history.h>
#include <core/idle.h>
#include <core/playlist.h>
#include <core/tags/tags.h>
#include <tests/test.h>
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),
);

3
tests/core/tempq.c

@ -3,7 +3,6 @@
*/
#include <core/collection.h>
#include <core/filter.h>
#include <core/history.h>
#include <core/idle.h>
#include <core/playlist.h>
#include <core/tags/tags.h>
@ -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();

Loading…
Cancel
Save