Remove core/queue.c and associated files

Everything has been merged into the playlist layer to better match how
playlists are actually used.  This means we can remove the queue files.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2016-09-22 13:37:34 -04:00
parent 3286b61dcf
commit 448b4a16f4
36 changed files with 57 additions and 240 deletions

View File

@ -28,7 +28,7 @@ void core_init(int *argc, char ***argv, struct core_init_data *init)
idle_init(); idle_init();
settings_init(); settings_init();
tags_init(); tags_init();
playlist_init(init->playlist_ops, init->playlist_cb); playlist_init(init->playlist_cb);
audio_init(argc, argv, init->audio_ops); audio_init(argc, argv, init->audio_ops);
idle_schedule(IDLE_SYNC, core_defragment, NULL); idle_schedule(IDLE_SYNC, core_defragment, NULL);

View File

@ -33,13 +33,13 @@ static struct playlist *__playlist_saved(const gchar *s_type, const gchar *s_id)
return playlist_types[type]->pl_get(id); return playlist_types[type]->pl_get(id);
} }
void playlist_init(struct queue_ops *ops, struct playlist_callbacks *cb) void playlist_init(struct playlist_callbacks *cb)
{ {
playlist_generic_set_callbacks(cb); playlist_generic_set_callbacks(cb);
pl_system_init(ops); pl_system_init();
pl_artist_init(ops); pl_artist_init();
pl_user_init(ops); pl_user_init();
pl_library_init(ops); pl_library_init();
current = __playlist_saved(SETTINGS_CUR_TYPE, SETTINGS_CUR_ID); current = __playlist_saved(SETTINGS_CUR_TYPE, SETTINGS_CUR_ID);
previous = __playlist_saved(SETTINGS_PREV_TYPE, SETTINGS_PREV_ID); previous = __playlist_saved(SETTINGS_PREV_TYPE, SETTINGS_PREV_ID);

View File

@ -5,8 +5,7 @@
#include <core/playlists/artist.h> #include <core/playlists/artist.h>
#include <core/string.h> #include <core/string.h>
static struct queue_ops *artist_ops = NULL; static struct file artist_file = FILE_INIT("playlist.artist", 0);
static struct file artist_file = FILE_INIT("playlist.artist", 0);
static struct playlist_ops pl_artist_ops = { static struct playlist_ops pl_artist_ops = {
.pl_can_select = playlist_generic_can_select, .pl_can_select = playlist_generic_can_select,
@ -18,8 +17,7 @@ static struct playlist_ops pl_artist_ops = {
static struct playlist *__artist_pl_alloc(struct artist *artist) static struct playlist *__artist_pl_alloc(struct artist *artist)
{ {
return playlist_generic_alloc(artist->ar_name, PL_ARTIST, return playlist_generic_alloc(artist->ar_name, PL_ARTIST,
artist_index(artist), &pl_artist_ops, artist_index(artist), &pl_artist_ops);
artist_ops);
} }
static bool __artist_pl_add(void *data) static bool __artist_pl_add(void *data)
@ -112,13 +110,11 @@ struct playlist_type pl_artist = {
}; };
void pl_artist_init(struct queue_ops *ops) void pl_artist_init(void)
{ {
struct db_entry *dbe, *next; struct db_entry *dbe, *next;
struct playlist *playlist; struct playlist *playlist;
artist_ops = ops;
db_for_each(dbe, next, artist_db_get()) { db_for_each(dbe, next, artist_db_get()) {
playlist = __artist_pl_alloc(ARTIST(dbe)); playlist = __artist_pl_alloc(ARTIST(dbe));
ARTIST(dbe)->ar_playlist = playlist; ARTIST(dbe)->ar_playlist = playlist;

View File

@ -38,22 +38,20 @@ void playlist_generic_set_callbacks(struct playlist_callbacks *cb)
callbacks = cb; callbacks = cb;
} }
void playlist_generic_init(struct playlist *playlist, struct queue_ops *ops) void playlist_generic_init(struct playlist *playlist)
{ {
if (playlist) { if (playlist) {
g_queue_init(&playlist->pl_tracks); g_queue_init(&playlist->pl_tracks);
queue_init(&playlist->pl_queue, ops, playlist);
playlist->pl_sort = NULL; playlist->pl_sort = NULL;
playlist->pl_current = NULL; playlist->pl_current = NULL;
playlist->pl_search = NULL; playlist->pl_search = NULL;
} }
} }
void playlist_generic_init_sorted(struct playlist *playlist, void playlist_generic_init_sorted(struct playlist *playlist)
struct queue_ops *ops)
{ {
if (playlist) { if (playlist) {
playlist_generic_init(playlist, ops); playlist_generic_init(playlist);
playlist_generic_sort(playlist, COMPARE_ARTIST); playlist_generic_sort(playlist, COMPARE_ARTIST);
playlist_generic_sort(playlist, COMPARE_YEAR); playlist_generic_sort(playlist, COMPARE_YEAR);
playlist_generic_sort(playlist, COMPARE_TRACK); playlist_generic_sort(playlist, COMPARE_TRACK);
@ -71,11 +69,8 @@ void playlist_generic_deinit(struct playlist *playlist)
} }
} }
struct playlist *playlist_generic_alloc(gchar *name, struct playlist *playlist_generic_alloc(gchar *name, enum playlist_type_t type,
enum playlist_type_t type, unsigned int id, struct playlist_ops *ops)
unsigned int id,
struct playlist_ops *ops,
struct queue_ops *qops)
{ {
struct playlist *playlist = g_malloc(sizeof(struct playlist)); struct playlist *playlist = g_malloc(sizeof(struct playlist));
@ -84,7 +79,7 @@ struct playlist *playlist_generic_alloc(gchar *name,
playlist->pl_id = id; playlist->pl_id = id;
playlist->pl_ops = ops; playlist->pl_ops = ops;
playlist_generic_init_sorted(playlist, qops); playlist_generic_init_sorted(playlist);
if (callbacks) if (callbacks)
callbacks->pl_cb_alloc(playlist); callbacks->pl_cb_alloc(playlist);
return playlist; return playlist;

View File

@ -14,8 +14,7 @@ struct scan_data {
}; };
static bool __lib_pl_scan_dir(void *); static bool __lib_pl_scan_dir(void *);
static struct queue_ops *lib_ops = NULL; static struct file lib_file = FILE_INIT("playlist.library", 0);
static struct file lib_file = FILE_INIT("playlist.library", 0);
static struct playlist_ops pl_library_ops; static struct playlist_ops pl_library_ops;
@ -23,8 +22,7 @@ static struct playlist_ops pl_library_ops;
static struct playlist *__lib_pl_alloc(struct library *library) static struct playlist *__lib_pl_alloc(struct library *library)
{ {
return playlist_generic_alloc(library->li_path, PL_LIBRARY, return playlist_generic_alloc(library->li_path, PL_LIBRARY,
library_index(library), &pl_library_ops, library_index(library), &pl_library_ops);
lib_ops);
} }
static bool __lib_pl_add(void *data) static bool __lib_pl_add(void *data)
@ -244,13 +242,11 @@ struct playlist_type pl_library = {
}; };
void pl_library_init(struct queue_ops *ops) void pl_library_init(void)
{ {
struct db_entry *dbe, *next; struct db_entry *dbe, *next;
struct playlist *playlist; struct playlist *playlist;
lib_ops = ops;
db_for_each(dbe, next, library_db_get()) { db_for_each(dbe, next, library_db_get()) {
playlist = __lib_pl_alloc(LIBRARY(dbe)); playlist = __lib_pl_alloc(LIBRARY(dbe));
LIBRARY(dbe)->li_playlist = playlist; LIBRARY(dbe)->li_playlist = playlist;

View File

@ -385,7 +385,7 @@ struct playlist_type pl_system = {
}; };
void pl_system_init(struct queue_ops *ops) void pl_system_init(void)
{ {
struct playlist *playlist; struct playlist *playlist;
unsigned int i; unsigned int i;
@ -396,7 +396,7 @@ void pl_system_init(struct queue_ops *ops)
switch (i) { switch (i) {
case SYS_PL_QUEUED: case SYS_PL_QUEUED:
case SYS_PL_HISTORY: case SYS_PL_HISTORY:
playlist_generic_init(playlist, ops); playlist_generic_init(playlist);
break; break;
case SYS_PL_COLLECTION: case SYS_PL_COLLECTION:
case SYS_PL_UNPLAYED: case SYS_PL_UNPLAYED:
@ -405,7 +405,7 @@ void pl_system_init(struct queue_ops *ops)
sys_pl_update(playlist); sys_pl_update(playlist);
case SYS_PL_FAVORITES: case SYS_PL_FAVORITES:
case SYS_PL_HIDDEN: case SYS_PL_HIDDEN:
playlist_generic_init_sorted(playlist, ops); playlist_generic_init_sorted(playlist);
break; break;
} }
} }

View File

@ -3,7 +3,6 @@
*/ */
#include <core/playlists/user.h> #include <core/playlists/user.h>
static struct queue_ops *user_pl_ops = NULL;
static struct database user_db; static struct database user_db;
static struct playlist_ops user_ops; static struct playlist_ops user_ops;
@ -16,7 +15,7 @@ static struct user_playlist *__user_db_alloc(gchar *name, unsigned int index)
playlist->pl_playlist.pl_type = PL_USER; playlist->pl_playlist.pl_type = PL_USER;
playlist->pl_playlist.pl_id = index; playlist->pl_playlist.pl_id = index;
playlist->pl_playlist.pl_ops = &user_ops; playlist->pl_playlist.pl_ops = &user_ops;
playlist_generic_init_sorted(&playlist->pl_playlist, user_pl_ops); playlist_generic_init_sorted(&playlist->pl_playlist);
return playlist; return playlist;
} }
@ -131,9 +130,8 @@ struct playlist_type pl_user = {
}; };
void pl_user_init(struct queue_ops *ops) void pl_user_init(void)
{ {
user_pl_ops = ops;
db_init(&user_db, "playlist.user", true, &user_db_ops, 0); db_init(&user_db, "playlist.user", true, &user_db_ops, 0);
db_load(&user_db); db_load(&user_db);
} }

View File

@ -1,20 +0,0 @@
/*
* Copyright 2013 (c) Anna Schumaker.
*/
#include <core/queue.h>
#include <core/string.h>
#include <stdlib.h>
static inline void *__queue_init(struct queue *queue, void *data)
{
if (queue->q_ops)
return queue->q_ops->qop_init(queue, data);
return NULL;
}
void queue_init(struct queue *queue, const struct queue_ops *ops, void *data)
{
queue->q_ops = ops;
queue->q_private = __queue_init(queue, data);
}

View File

@ -33,7 +33,6 @@ const static gchar *OCARINA_APP = "org.gtk.ocarina-debug";
struct core_init_data init_data = { struct core_init_data init_data = {
.playlist_cb = &playlist_cb, .playlist_cb = &playlist_cb,
.playlist_ops = &playlist_ops,
.audio_ops = &audio_ops, .audio_ops = &audio_ops,
}; };

View File

@ -28,11 +28,6 @@ static inline void __gui_playlist_update_size(struct playlist *playlist)
update_size[playlist->pl_type](playlist); update_size[playlist->pl_type](playlist);
} }
static void *__gui_playlist_init(struct queue *queue, void *data)
{
return data;
}
static void __gui_playlist_alloc(struct playlist *playlist) static void __gui_playlist_alloc(struct playlist *playlist)
{ {
if (playlist->pl_type == PL_ARTIST) if (playlist->pl_type == PL_ARTIST)
@ -53,10 +48,6 @@ static void __gui_playlist_removed(struct playlist *playlist, struct track *trac
} }
struct queue_ops playlist_ops = {
.qop_init = __gui_playlist_init,
};
struct playlist_callbacks playlist_cb = { struct playlist_callbacks playlist_cb = {
.pl_cb_alloc = __gui_playlist_alloc, .pl_cb_alloc = __gui_playlist_alloc,
.pl_cb_added = __gui_playlist_added, .pl_cb_added = __gui_playlist_added,

View File

@ -3,12 +3,10 @@
*/ */
#ifndef OCARINA_CORE_CORE_H #ifndef OCARINA_CORE_CORE_H
#define OCARINA_CORE_CORE_H #define OCARINA_CORE_CORE_H
#include <core/queue.h> #include <stdbool.h>
struct core_init_data { struct core_init_data {
struct playlist_callbacks *playlist_cb; struct playlist_callbacks *playlist_cb;
struct queue_ops *playlist_ops;
struct audio_ops *audio_ops; struct audio_ops *audio_ops;
#ifdef CONFIG_TESTING #ifdef CONFIG_TESTING
bool idle_async; bool idle_async;

View File

@ -14,7 +14,7 @@
/* Called to initialize the playlist manager. */ /* Called to initialize the playlist manager. */
void playlist_init(struct queue_ops *, struct playlist_callbacks *); void playlist_init(struct playlist_callbacks *);
/* Called to deinitialize the playlist manager. */ /* Called to deinitialize the playlist manager. */
void playlist_deinit(); void playlist_deinit();

View File

@ -10,7 +10,7 @@ extern struct playlist_type pl_artist;
/* Called to initialize artist playlists. */ /* Called to initialize artist playlists. */
void pl_artist_init(struct queue_ops *ops); void pl_artist_init(void);
/* Called to deinitialize library playlists. */ /* Called to deinitialize library playlists. */
void pl_artist_deinit(); void pl_artist_deinit();

View File

@ -40,16 +40,15 @@ struct playlist_callbacks {
void playlist_generic_set_callbacks(struct playlist_callbacks *); void playlist_generic_set_callbacks(struct playlist_callbacks *);
/* Generic playlist init functions. */ /* Generic playlist init functions. */
void playlist_generic_init(struct playlist *, struct queue_ops *); void playlist_generic_init(struct playlist *);
void playlist_generic_init_sorted(struct playlist *, struct queue_ops *); void playlist_generic_init_sorted(struct playlist *);
/* Generic playlist deinit function. */ /* Generic playlist deinit function. */
void playlist_generic_deinit(struct playlist *); void playlist_generic_deinit(struct playlist *);
/* Generic playlist alloc function. */ /* Generic playlist alloc function. */
struct playlist *playlist_generic_alloc(gchar *, enum playlist_type_t, struct playlist *playlist_generic_alloc(gchar *, enum playlist_type_t,
unsigned int, struct playlist_ops *, unsigned int, struct playlist_ops *);
struct queue_ops *);
/* Generic playlist free function. */ /* Generic playlist free function. */
void playlist_generic_free(struct playlist *); void playlist_generic_free(struct playlist *);

View File

@ -6,7 +6,6 @@
#ifndef OCARINA_CORE_PLAYLISTS_ITERATOR_H #ifndef OCARINA_CORE_PLAYLISTS_ITERATOR_H
#define OCARINA_CORE_PLAYLISTS_ITERATOR_H #define OCARINA_CORE_PLAYLISTS_ITERATOR_H
#include <core/playlists/playlist.h> #include <core/playlists/playlist.h>
#include <core/queue.h>
/* Called to set the playlist iterator to a specific position. */ /* Called to set the playlist iterator to a specific position. */
static inline playlist_iter playlist_iter_get(struct playlist *playlist, static inline playlist_iter playlist_iter_get(struct playlist *playlist,

View File

@ -10,7 +10,7 @@ extern struct playlist_type pl_library;
/* Called to initialize library playlists. */ /* Called to initialize library playlists. */
void pl_library_init(struct queue_ops *); void pl_library_init(void);
/* Called to deinitialize system playlists. */ /* Called to deinitialize system playlists. */
void pl_library_deinit(); void pl_library_deinit();

View File

@ -3,7 +3,6 @@
*/ */
#ifndef OCARINA_CORE_PLAYLISTS_PLAYLIST_H #ifndef OCARINA_CORE_PLAYLISTS_PLAYLIST_H
#define OCARINA_CORE_PLAYLISTS_PLAYLIST_H #define OCARINA_CORE_PLAYLISTS_PLAYLIST_H
#include <core/queue.h>
#include <core/tags/track.h> #include <core/tags/track.h>
#include <stdbool.h> #include <stdbool.h>
@ -54,7 +53,6 @@ struct playlist {
playlist_iter pl_current; /* This playlist's current track. */ playlist_iter pl_current; /* This playlist's current track. */
GSList *pl_sort; /* This playlist's sort order. */ GSList *pl_sort; /* This playlist's sort order. */
gchar **pl_search; /* This playlist's search text. */ gchar **pl_search; /* This playlist's search text. */
struct queue pl_queue; /* This playlist's queue of tracks. */
const struct playlist_ops *pl_ops; /* This playlist's supported operations. */ const struct playlist_ops *pl_ops; /* This playlist's supported operations. */
}; };

View File

@ -23,7 +23,7 @@ extern struct playlist_type pl_system;
/* Called to initialize system playlists. */ /* Called to initialize system playlists. */
void pl_system_init(struct queue_ops *); void pl_system_init(void);
/* Called to deinitialize system playlists. */ /* Called to deinitialize system playlists. */
void pl_system_deinit(); void pl_system_deinit();

View File

@ -18,7 +18,7 @@ extern struct playlist_type pl_user;
/* Called to initialize user playlists. */ /* Called to initialize user playlists. */
void pl_user_init(struct queue_ops *ops); void pl_user_init(void);
/* Called to deinitialize user playlists. */ /* Called to deinitialize user playlists. */
void pl_user_deinit(); void pl_user_deinit();

View File

@ -1,33 +0,0 @@
/*
* Copyright 2013 (c) Anna Schumaker.
*
* Queues are lists of tracks that the user has requested to play next.
* Users of queues are expected to implement their own save and load functions,
* and to provide a filled out queue_ops structure during initialization.
*/
#ifndef OCARINA_CORE_QUEUE_H
#define OCARINA_CORE_QUEUE_H
#include <core/file.h>
#include <core/tags/track.h>
struct queue;
struct queue_ops {
/* Called to tell a higher layer that a queue has been initialized. */
void *(*qop_init)(struct queue *, void *);
};
struct queue {
void *q_private; /* The queue's private data. */
const struct queue_ops *q_ops; /* The queue's operations vector. */
};
/* Called to initialize a queue. */
void queue_init(struct queue *, const struct queue_ops *, void *);
#endif /* OCARINA_CORE_QUEUE_H */

View File

@ -25,9 +25,6 @@ static inline GtkMenuItem *gui_rc_add_to_other()
return GTK_MENU_ITEM(gui_builder_widget("rc_add_to_other")); return GTK_MENU_ITEM(gui_builder_widget("rc_add_to_other"));
} }
/* Playlist operations passed to core_init() */
extern struct queue_ops playlist_ops;
/* Playlist callbacks passed to core_init() */ /* Playlist callbacks passed to core_init() */
extern struct playlist_callbacks playlist_cb; extern struct playlist_callbacks playlist_cb;

View File

@ -5,6 +5,5 @@ date
idle idle
settings settings
database database
queue
playlist playlist
audio audio

View File

@ -13,7 +13,6 @@ core_unit_test(Settings)
core_unit_test(Database) core_unit_test(Database)
add_subdirectory(tags/) add_subdirectory(tags/)
core_unit_test(Queue)
core_unit_test(Playlist) core_unit_test(Playlist)
add_subdirectory(playlists/) add_subdirectory(playlists/)
core_unit_test(Audio) core_unit_test(Audio)

View File

@ -9,6 +9,11 @@
static struct playlist *cb_playlist = NULL; static struct playlist *cb_playlist = NULL;
static struct track *cb_track = NULL; static struct track *cb_track = NULL;
static void test_pl_alloc(struct playlist *playlist)
{
cb_playlist = NULL;
}
static void test_pl_removed(struct playlist *playlist, struct track *track, static void test_pl_removed(struct playlist *playlist, struct track *track,
unsigned int n) unsigned int n)
{ {
@ -31,6 +36,7 @@ static struct playlist_ops test_ops = {
.pl_sort = playlist_generic_sort, .pl_sort = playlist_generic_sort,
}; };
static struct playlist_callbacks test_cb = { static struct playlist_callbacks test_cb = {
.pl_cb_alloc = test_pl_alloc,
.pl_cb_added = test_pl_callback, .pl_cb_added = test_pl_callback,
.pl_cb_removed = test_pl_removed, .pl_cb_removed = test_pl_removed,
.pl_cb_updated = test_pl_callback, .pl_cb_updated = test_pl_callback,
@ -43,8 +49,8 @@ static void test_null()
g_assert_false(playlist_delete(NULL)); g_assert_false(playlist_delete(NULL));
playlist_generic_free(NULL); playlist_generic_free(NULL);
playlist_generic_init(NULL, NULL); playlist_generic_init(NULL);
playlist_generic_init_sorted(NULL, NULL); playlist_generic_init_sorted(NULL);
playlist_generic_deinit(NULL); playlist_generic_deinit(NULL);
g_assert_null(playlist_lookup(PL_MAX_TYPE, "NULL")); g_assert_null(playlist_lookup(PL_MAX_TYPE, "NULL"));
@ -104,7 +110,7 @@ static void test_playlist()
int i; int i;
g_assert_cmpuint(playlist_size(&p), ==, 0); g_assert_cmpuint(playlist_size(&p), ==, 0);
playlist_generic_init(&p, NULL); playlist_generic_init(&p);
g_assert_cmpuint(playlist_size(&p), ==, 0); g_assert_cmpuint(playlist_size(&p), ==, 0);
g_assert_cmpuint(p.pl_length, ==, 0); g_assert_cmpuint(p.pl_length, ==, 0);
@ -196,7 +202,7 @@ static void test_sorting()
struct track *track; struct track *track;
unsigned int i; unsigned int i;
playlist_generic_init_sorted(&p, NULL); playlist_generic_init_sorted(&p);
g_assert_cmpuint(g_slist_length(p.pl_sort), ==, 3); g_assert_cmpuint(g_slist_length(p.pl_sort), ==, 3);
playlist_clear_sort(&p); playlist_clear_sort(&p);
g_assert_cmpuint(g_slist_length(p.pl_sort), ==, 0); g_assert_cmpuint(g_slist_length(p.pl_sort), ==, 0);
@ -280,7 +286,7 @@ static void test_next()
unsigned int i; unsigned int i;
g_random_set_seed(0); g_random_set_seed(0);
playlist_generic_init(&p, NULL); playlist_generic_init(&p);
for (i = 0; i < 13; i++) for (i = 0; i < 13; i++)
playlist_generic_add(&p, track_get(i)); playlist_generic_add(&p, track_get(i));
@ -374,7 +380,7 @@ int main(int argc, char **argv)
idle_init_sync(); idle_init_sync();
settings_init(); settings_init();
tags_init(); tags_init();
playlist_init(NULL, &test_cb); playlist_init(&test_cb);
while (idle_run_task()) {}; while (idle_run_task()) {};
library = library_find("tests/Music"); library = library_find("tests/Music");

View File

@ -24,7 +24,7 @@ void test_artist()
g_assert_false(playlist_select(NULL)); g_assert_false(playlist_select(NULL));
pl_artist_deinit(); pl_artist_deinit();
pl_artist_init(NULL); pl_artist_init();
while (idle_run_task()) {}; while (idle_run_task()) {};
@ -65,7 +65,7 @@ int main(int argc, char **argv)
idle_init_sync(); idle_init_sync();
settings_init(); settings_init();
tags_init(); tags_init();
playlist_init(NULL, NULL); playlist_init(NULL);
while (idle_run_task()) {}; while (idle_run_task()) {};
/* Add tracks to the collection. */ /* Add tracks to the collection. */

View File

@ -53,7 +53,7 @@ void test_library()
pl_library_deinit(); pl_library_deinit();
g_assert_null(playlist_lookup(PL_LIBRARY, "tests/Music")); g_assert_null(playlist_lookup(PL_LIBRARY, "tests/Music"));
g_assert_null(library->li_playlist); g_assert_null(library->li_playlist);
pl_library_init(NULL); pl_library_init();
while (idle_run_task()) {}; while (idle_run_task()) {};
playlist = library->li_playlist; playlist = library->li_playlist;
@ -115,7 +115,7 @@ int main(int argc, char **argv)
idle_init_sync(); idle_init_sync();
settings_init(); settings_init();
tags_init(); tags_init();
playlist_init(NULL, NULL); playlist_init(NULL);
while (idle_run_task()) {}; while (idle_run_task()) {};
g_test_init(&argc, &argv, NULL); g_test_init(&argc, &argv, NULL);

View File

@ -365,7 +365,7 @@ int main(int argc, char **argv)
idle_init_sync(); idle_init_sync();
settings_init(); settings_init();
tags_init(); tags_init();
playlist_init(NULL, NULL); playlist_init(NULL);
while (idle_run_task()) {}; while (idle_run_task()) {};
g_test_init(&argc, &argv, NULL); g_test_init(&argc, &argv, NULL);

View File

@ -53,7 +53,7 @@ void test_user()
pl_user_deinit(); pl_user_deinit();
g_assert_cmpuint(db->db_size, ==, 0); g_assert_cmpuint(db->db_size, ==, 0);
pl_user_init(NULL); pl_user_init();
while (idle_run_task()) {}; while (idle_run_task()) {};
g_assert_cmpuint(db->db_size, ==, 1); g_assert_cmpuint(db->db_size, ==, 1);
@ -79,7 +79,7 @@ int main(int argc, char **argv)
idle_init_sync(); idle_init_sync();
settings_init(); settings_init();
tags_init(); tags_init();
playlist_init(NULL, NULL); playlist_init(NULL);
while (idle_run_task()) {}; while (idle_run_task()) {};
playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony"); playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony");

View File

@ -1,74 +0,0 @@
/*
* Copyright 2014 (c) Anna Schumaker.
*/
#include <core/idle.h>
#include <core/queue.h>
#include <core/tags/tags.h>
#include <tests/test.h>
unsigned int count_init = 0;
static void *queue_op_init(struct queue *queue, void *data)
{
count_init++;
return GUINT_TO_POINTER(count_init);
}
static const struct queue_ops test_ops = {
.qop_init = queue_op_init,
};
static void test_init()
{
struct queue q;
queue_init(&q, NULL, NULL);
g_assert_cmpuint(count_init, ==, 0);
g_assert_null(q.q_private);
g_assert_null(q.q_ops);
queue_init(&q, &test_ops, NULL);
g_assert_cmpuint(count_init, ==, 1);
g_assert_cmpuint(GPOINTER_TO_UINT(q.q_private), ==, 1);
g_assert(q.q_ops == &test_ops);
}
int main(int argc, char **argv)
{
struct library *library;
int ret;
idle_init_sync();
tags_init();
while (idle_run_task()) {}
library = library_find("tests/Music");
track_add(library, "tests/Music/Hyrule Symphony/01 - Title Theme.ogg");
track_add(library, "tests/Music/Hyrule Symphony/02 - Kokiri Forest.ogg");
track_add(library, "tests/Music/Hyrule Symphony/03 - Hyrule Field.ogg");
track_add(library, "tests/Music/Hyrule Symphony/04 - Hyrule Castle.ogg");
track_add(library, "tests/Music/Hyrule Symphony/05 - Lon Lon Ranch.ogg");
track_add(library, "tests/Music/Hyrule Symphony/06 - Kakariko Village.ogg");
track_add(library, "tests/Music/Hyrule Symphony/07 - Death Mountain.ogg");
track_add(library, "tests/Music/Hyrule Symphony/08 - Zora's Domain.ogg");
track_add(library, "tests/Music/Hyrule Symphony/09 - Gerudo Valley.ogg");
track_add(library, "tests/Music/Hyrule Symphony/10 - Ganondorf.ogg");
track_add(library, "tests/Music/Hyrule Symphony/11 - Princess Zelda.ogg");
track_add(library, "tests/Music/Hyrule Symphony/12 - Ocarina Medley.ogg");
track_add(library,
"tests/Music/Hyrule Symphony/13 - The Legend of Zelda Medley.ogg");
g_test_init(&argc, &argv, NULL);
g_test_add_func("/Core/Queue/Initialization", test_init);
ret = g_test_run();
tags_deinit();
idle_deinit();
return ret;
}

View File

@ -23,7 +23,6 @@ static struct audio_ops test_audio_ops = {
}; };
struct core_init_data init_data = { struct core_init_data init_data = {
.playlist_ops = &playlist_ops,
.audio_ops = &test_audio_ops, .audio_ops = &test_audio_ops,
#ifdef CONFIG_ALBUM_ART_TEST #ifdef CONFIG_ALBUM_ART_TEST
.idle_async = true, .idle_async = true,

View File

@ -8,13 +8,6 @@
#include <gui/model.h> #include <gui/model.h>
#include <gui/window.h> #include <gui/window.h>
void *test_queue_init(struct queue *queue, void *data)
{ return NULL; }
struct queue_ops test_ops = {
.qop_init = test_queue_init,
};
void test_on_load(struct track *track) {} void test_on_load(struct track *track) {}
void test_on_state_change(GstState state) {} void test_on_state_change(GstState state) {}
void test_on_config_pause(int count) {} void test_on_config_pause(int count) {}
@ -26,8 +19,7 @@ struct audio_ops test_audio_ops = {
}; };
struct core_init_data init_data = { struct core_init_data init_data = {
.playlist_ops = &test_ops, .audio_ops = &test_audio_ops,
.audio_ops = &test_audio_ops,
}; };
void test_filter() void test_filter()
@ -46,8 +38,6 @@ void test_filter()
entry = GTK_ENTRY(gui_filter_search()); entry = GTK_ENTRY(gui_filter_search());
model = GTK_TREE_MODEL(gui_filter_get()); model = GTK_TREE_MODEL(gui_filter_get());
playlist_lookup(PL_SYSTEM, "Collection")->pl_queue.q_private =
playlist_lookup(PL_SYSTEM, "Collection");
g_assert_false(gtk_tree_model_get_iter_first(model, &iter)); g_assert_false(gtk_tree_model_get_iter_first(model, &iter));
gui_filter_set_playlist(playlist_lookup(PL_SYSTEM, "Collection")); gui_filter_set_playlist(playlist_lookup(PL_SYSTEM, "Collection"));

View File

@ -23,17 +23,11 @@ void on_row_changed(GtkTreeModel *model, GtkTreePath *path,
GtkTreeIter *iter, gpointer data) GtkTreeIter *iter, gpointer data)
{ count_update++; } { count_update++; }
void *test_queue_init(struct queue *queue, void *data)
{ return NULL; }
void test_cb_alloc(struct playlist *playlist) {} void test_cb_alloc(struct playlist *playlist) {}
void test_on_load(struct track *track) {} void test_on_load(struct track *track) {}
void test_on_state_change(GstState state) {} void test_on_state_change(GstState state) {}
void test_on_config_pause(int count) {} void test_on_config_pause(int count) {}
struct queue_ops test_ops = {
.qop_init = test_queue_init,
};
struct playlist_callbacks test_cb = { struct playlist_callbacks test_cb = {
.pl_cb_alloc = test_cb_alloc, .pl_cb_alloc = test_cb_alloc,
.pl_cb_added = gui_model_add, .pl_cb_added = gui_model_add,
@ -49,7 +43,6 @@ struct audio_ops test_audio_ops = {
struct core_init_data init_data = { struct core_init_data init_data = {
.playlist_cb = &test_cb, .playlist_cb = &test_cb,
.playlist_ops = &test_ops,
.audio_ops = &test_audio_ops, .audio_ops = &test_audio_ops,
}; };
@ -174,8 +167,6 @@ static void test_model()
/* Okay, now scan a directory ... */ /* Okay, now scan a directory ... */
collection = playlist_lookup(PL_SYSTEM, "Collection"); collection = playlist_lookup(PL_SYSTEM, "Collection");
favorites = playlist_lookup(PL_SYSTEM, "Favorites"); favorites = playlist_lookup(PL_SYSTEM, "Favorites");
collection->pl_queue.q_private = collection;
favorites->pl_queue.q_private = favorites;
playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony"); playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony");
while (idle_run_task() == true) {} while (idle_run_task() == true) {}
g_assert_cmpuint(playlist_size(collection), ==, 13); g_assert_cmpuint(playlist_size(collection), ==, 13);

View File

@ -11,9 +11,7 @@
#include <gui/treeview.h> #include <gui/treeview.h>
#include <tests/test.h> #include <tests/test.h>
struct core_init_data init_data = { struct core_init_data init_data;
.playlist_ops = &playlist_ops,
};
static void test_playlist() static void test_playlist()
{ {

View File

@ -11,9 +11,7 @@
#include <gui/treeview.h> #include <gui/treeview.h>
#include <tests/test.h> #include <tests/test.h>
struct core_init_data init_data = { struct core_init_data init_data;
.playlist_ops = &playlist_ops,
};
static void test_library() static void test_library()
{ {

View File

@ -23,8 +23,8 @@ static struct audio_ops test_audio_ops = {
}; };
struct core_init_data init_data = { struct core_init_data init_data = {
.playlist_ops = &playlist_ops, .playlist_cb = &playlist_cb,
.audio_ops = &test_audio_ops, .audio_ops = &test_audio_ops,
}; };
static const gchar *toplevel[3] = { "Queued Tracks", "Collection", "History" }; static const gchar *toplevel[3] = { "Queued Tracks", "Collection", "History" };

View File

@ -11,9 +11,7 @@
#include <gui/treeview.h> #include <gui/treeview.h>
#include <tests/test.h> #include <tests/test.h>
struct core_init_data init_data = { struct core_init_data init_data;
.playlist_ops = &playlist_ops,
};
static void test_user() static void test_user()
{ {