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:
parent
3286b61dcf
commit
448b4a16f4
|
@ -28,7 +28,7 @@ void core_init(int *argc, char ***argv, struct core_init_data *init)
|
|||
idle_init();
|
||||
settings_init();
|
||||
tags_init();
|
||||
playlist_init(init->playlist_ops, init->playlist_cb);
|
||||
playlist_init(init->playlist_cb);
|
||||
audio_init(argc, argv, init->audio_ops);
|
||||
|
||||
idle_schedule(IDLE_SYNC, core_defragment, NULL);
|
||||
|
|
|
@ -33,13 +33,13 @@ static struct playlist *__playlist_saved(const gchar *s_type, const gchar *s_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);
|
||||
pl_system_init(ops);
|
||||
pl_artist_init(ops);
|
||||
pl_user_init(ops);
|
||||
pl_library_init(ops);
|
||||
pl_system_init();
|
||||
pl_artist_init();
|
||||
pl_user_init();
|
||||
pl_library_init();
|
||||
|
||||
current = __playlist_saved(SETTINGS_CUR_TYPE, SETTINGS_CUR_ID);
|
||||
previous = __playlist_saved(SETTINGS_PREV_TYPE, SETTINGS_PREV_ID);
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include <core/playlists/artist.h>
|
||||
#include <core/string.h>
|
||||
|
||||
static struct queue_ops *artist_ops = NULL;
|
||||
static struct file artist_file = FILE_INIT("playlist.artist", 0);
|
||||
|
||||
static struct playlist_ops pl_artist_ops = {
|
||||
|
@ -18,8 +17,7 @@ static struct playlist_ops pl_artist_ops = {
|
|||
static struct playlist *__artist_pl_alloc(struct artist *artist)
|
||||
{
|
||||
return playlist_generic_alloc(artist->ar_name, PL_ARTIST,
|
||||
artist_index(artist), &pl_artist_ops,
|
||||
artist_ops);
|
||||
artist_index(artist), &pl_artist_ops);
|
||||
}
|
||||
|
||||
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 playlist *playlist;
|
||||
|
||||
artist_ops = ops;
|
||||
|
||||
db_for_each(dbe, next, artist_db_get()) {
|
||||
playlist = __artist_pl_alloc(ARTIST(dbe));
|
||||
ARTIST(dbe)->ar_playlist = playlist;
|
||||
|
|
|
@ -38,22 +38,20 @@ void playlist_generic_set_callbacks(struct playlist_callbacks *cb)
|
|||
callbacks = cb;
|
||||
}
|
||||
|
||||
void playlist_generic_init(struct playlist *playlist, struct queue_ops *ops)
|
||||
void playlist_generic_init(struct playlist *playlist)
|
||||
{
|
||||
if (playlist) {
|
||||
g_queue_init(&playlist->pl_tracks);
|
||||
queue_init(&playlist->pl_queue, ops, playlist);
|
||||
playlist->pl_sort = NULL;
|
||||
playlist->pl_current = NULL;
|
||||
playlist->pl_search = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void playlist_generic_init_sorted(struct playlist *playlist,
|
||||
struct queue_ops *ops)
|
||||
void playlist_generic_init_sorted(struct playlist *playlist)
|
||||
{
|
||||
if (playlist) {
|
||||
playlist_generic_init(playlist, ops);
|
||||
playlist_generic_init(playlist);
|
||||
playlist_generic_sort(playlist, COMPARE_ARTIST);
|
||||
playlist_generic_sort(playlist, COMPARE_YEAR);
|
||||
playlist_generic_sort(playlist, COMPARE_TRACK);
|
||||
|
@ -71,11 +69,8 @@ void playlist_generic_deinit(struct playlist *playlist)
|
|||
}
|
||||
}
|
||||
|
||||
struct playlist *playlist_generic_alloc(gchar *name,
|
||||
enum playlist_type_t type,
|
||||
unsigned int id,
|
||||
struct playlist_ops *ops,
|
||||
struct queue_ops *qops)
|
||||
struct playlist *playlist_generic_alloc(gchar *name, enum playlist_type_t type,
|
||||
unsigned int id, struct playlist_ops *ops)
|
||||
{
|
||||
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_ops = ops;
|
||||
|
||||
playlist_generic_init_sorted(playlist, qops);
|
||||
playlist_generic_init_sorted(playlist);
|
||||
if (callbacks)
|
||||
callbacks->pl_cb_alloc(playlist);
|
||||
return playlist;
|
||||
|
|
|
@ -14,7 +14,6 @@ struct scan_data {
|
|||
};
|
||||
|
||||
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 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)
|
||||
{
|
||||
return playlist_generic_alloc(library->li_path, PL_LIBRARY,
|
||||
library_index(library), &pl_library_ops,
|
||||
lib_ops);
|
||||
library_index(library), &pl_library_ops);
|
||||
}
|
||||
|
||||
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 playlist *playlist;
|
||||
|
||||
lib_ops = ops;
|
||||
|
||||
db_for_each(dbe, next, library_db_get()) {
|
||||
playlist = __lib_pl_alloc(LIBRARY(dbe));
|
||||
LIBRARY(dbe)->li_playlist = playlist;
|
||||
|
|
|
@ -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;
|
||||
unsigned int i;
|
||||
|
@ -396,7 +396,7 @@ void pl_system_init(struct queue_ops *ops)
|
|||
switch (i) {
|
||||
case SYS_PL_QUEUED:
|
||||
case SYS_PL_HISTORY:
|
||||
playlist_generic_init(playlist, ops);
|
||||
playlist_generic_init(playlist);
|
||||
break;
|
||||
case SYS_PL_COLLECTION:
|
||||
case SYS_PL_UNPLAYED:
|
||||
|
@ -405,7 +405,7 @@ void pl_system_init(struct queue_ops *ops)
|
|||
sys_pl_update(playlist);
|
||||
case SYS_PL_FAVORITES:
|
||||
case SYS_PL_HIDDEN:
|
||||
playlist_generic_init_sorted(playlist, ops);
|
||||
playlist_generic_init_sorted(playlist);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
*/
|
||||
#include <core/playlists/user.h>
|
||||
|
||||
static struct queue_ops *user_pl_ops = NULL;
|
||||
static struct database user_db;
|
||||
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_id = index;
|
||||
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;
|
||||
}
|
||||
|
@ -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_load(&user_db);
|
||||
}
|
||||
|
|
20
core/queue.c
20
core/queue.c
|
@ -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);
|
||||
}
|
|
@ -33,7 +33,6 @@ const static gchar *OCARINA_APP = "org.gtk.ocarina-debug";
|
|||
|
||||
struct core_init_data init_data = {
|
||||
.playlist_cb = &playlist_cb,
|
||||
.playlist_ops = &playlist_ops,
|
||||
.audio_ops = &audio_ops,
|
||||
};
|
||||
|
||||
|
|
|
@ -28,11 +28,6 @@ static inline void __gui_playlist_update_size(struct playlist *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)
|
||||
{
|
||||
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 = {
|
||||
.pl_cb_alloc = __gui_playlist_alloc,
|
||||
.pl_cb_added = __gui_playlist_added,
|
||||
|
|
|
@ -3,12 +3,10 @@
|
|||
*/
|
||||
#ifndef OCARINA_CORE_CORE_H
|
||||
#define OCARINA_CORE_CORE_H
|
||||
#include <core/queue.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
struct core_init_data {
|
||||
struct playlist_callbacks *playlist_cb;
|
||||
struct queue_ops *playlist_ops;
|
||||
struct audio_ops *audio_ops;
|
||||
#ifdef CONFIG_TESTING
|
||||
bool idle_async;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
|
||||
/* 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. */
|
||||
void playlist_deinit();
|
||||
|
|
|
@ -10,7 +10,7 @@ extern struct playlist_type pl_artist;
|
|||
|
||||
|
||||
/* Called to initialize artist playlists. */
|
||||
void pl_artist_init(struct queue_ops *ops);
|
||||
void pl_artist_init(void);
|
||||
|
||||
/* Called to deinitialize library playlists. */
|
||||
void pl_artist_deinit();
|
||||
|
|
|
@ -40,16 +40,15 @@ struct playlist_callbacks {
|
|||
void playlist_generic_set_callbacks(struct playlist_callbacks *);
|
||||
|
||||
/* Generic playlist init functions. */
|
||||
void playlist_generic_init(struct playlist *, struct queue_ops *);
|
||||
void playlist_generic_init_sorted(struct playlist *, struct queue_ops *);
|
||||
void playlist_generic_init(struct playlist *);
|
||||
void playlist_generic_init_sorted(struct playlist *);
|
||||
|
||||
/* Generic playlist deinit function. */
|
||||
void playlist_generic_deinit(struct playlist *);
|
||||
|
||||
/* Generic playlist alloc function. */
|
||||
struct playlist *playlist_generic_alloc(gchar *, enum playlist_type_t,
|
||||
unsigned int, struct playlist_ops *,
|
||||
struct queue_ops *);
|
||||
unsigned int, struct playlist_ops *);
|
||||
|
||||
/* Generic playlist free function. */
|
||||
void playlist_generic_free(struct playlist *);
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#ifndef OCARINA_CORE_PLAYLISTS_ITERATOR_H
|
||||
#define OCARINA_CORE_PLAYLISTS_ITERATOR_H
|
||||
#include <core/playlists/playlist.h>
|
||||
#include <core/queue.h>
|
||||
|
||||
/* Called to set the playlist iterator to a specific position. */
|
||||
static inline playlist_iter playlist_iter_get(struct playlist *playlist,
|
||||
|
|
|
@ -10,7 +10,7 @@ extern struct playlist_type pl_library;
|
|||
|
||||
|
||||
/* Called to initialize library playlists. */
|
||||
void pl_library_init(struct queue_ops *);
|
||||
void pl_library_init(void);
|
||||
|
||||
/* Called to deinitialize system playlists. */
|
||||
void pl_library_deinit();
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
*/
|
||||
#ifndef OCARINA_CORE_PLAYLISTS_PLAYLIST_H
|
||||
#define OCARINA_CORE_PLAYLISTS_PLAYLIST_H
|
||||
#include <core/queue.h>
|
||||
#include <core/tags/track.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
@ -54,7 +53,6 @@ struct playlist {
|
|||
playlist_iter pl_current; /* This playlist's current track. */
|
||||
GSList *pl_sort; /* This playlist's sort order. */
|
||||
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. */
|
||||
};
|
||||
|
|
|
@ -23,7 +23,7 @@ extern struct playlist_type pl_system;
|
|||
|
||||
|
||||
/* Called to initialize system playlists. */
|
||||
void pl_system_init(struct queue_ops *);
|
||||
void pl_system_init(void);
|
||||
|
||||
/* Called to deinitialize system playlists. */
|
||||
void pl_system_deinit();
|
||||
|
|
|
@ -18,7 +18,7 @@ extern struct playlist_type pl_user;
|
|||
|
||||
|
||||
/* Called to initialize user playlists. */
|
||||
void pl_user_init(struct queue_ops *ops);
|
||||
void pl_user_init(void);
|
||||
|
||||
/* Called to deinitialize user playlists. */
|
||||
void pl_user_deinit();
|
||||
|
|
|
@ -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 */
|
|
@ -25,9 +25,6 @@ static inline GtkMenuItem *gui_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() */
|
||||
extern struct playlist_callbacks playlist_cb;
|
||||
|
||||
|
|
|
@ -5,6 +5,5 @@ date
|
|||
idle
|
||||
settings
|
||||
database
|
||||
queue
|
||||
playlist
|
||||
audio
|
||||
|
|
|
@ -13,7 +13,6 @@ core_unit_test(Settings)
|
|||
core_unit_test(Database)
|
||||
|
||||
add_subdirectory(tags/)
|
||||
core_unit_test(Queue)
|
||||
core_unit_test(Playlist)
|
||||
add_subdirectory(playlists/)
|
||||
core_unit_test(Audio)
|
||||
|
|
|
@ -9,6 +9,11 @@
|
|||
static struct playlist *cb_playlist = 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,
|
||||
unsigned int n)
|
||||
{
|
||||
|
@ -31,6 +36,7 @@ static struct playlist_ops test_ops = {
|
|||
.pl_sort = playlist_generic_sort,
|
||||
};
|
||||
static struct playlist_callbacks test_cb = {
|
||||
.pl_cb_alloc = test_pl_alloc,
|
||||
.pl_cb_added = test_pl_callback,
|
||||
.pl_cb_removed = test_pl_removed,
|
||||
.pl_cb_updated = test_pl_callback,
|
||||
|
@ -43,8 +49,8 @@ static void test_null()
|
|||
g_assert_false(playlist_delete(NULL));
|
||||
playlist_generic_free(NULL);
|
||||
|
||||
playlist_generic_init(NULL, NULL);
|
||||
playlist_generic_init_sorted(NULL, NULL);
|
||||
playlist_generic_init(NULL);
|
||||
playlist_generic_init_sorted(NULL);
|
||||
playlist_generic_deinit(NULL);
|
||||
|
||||
g_assert_null(playlist_lookup(PL_MAX_TYPE, "NULL"));
|
||||
|
@ -104,7 +110,7 @@ static void test_playlist()
|
|||
int i;
|
||||
|
||||
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(p.pl_length, ==, 0);
|
||||
|
||||
|
@ -196,7 +202,7 @@ static void test_sorting()
|
|||
struct track *track;
|
||||
unsigned int i;
|
||||
|
||||
playlist_generic_init_sorted(&p, NULL);
|
||||
playlist_generic_init_sorted(&p);
|
||||
g_assert_cmpuint(g_slist_length(p.pl_sort), ==, 3);
|
||||
playlist_clear_sort(&p);
|
||||
g_assert_cmpuint(g_slist_length(p.pl_sort), ==, 0);
|
||||
|
@ -280,7 +286,7 @@ static void test_next()
|
|||
unsigned int i;
|
||||
|
||||
g_random_set_seed(0);
|
||||
playlist_generic_init(&p, NULL);
|
||||
playlist_generic_init(&p);
|
||||
|
||||
for (i = 0; i < 13; i++)
|
||||
playlist_generic_add(&p, track_get(i));
|
||||
|
@ -374,7 +380,7 @@ int main(int argc, char **argv)
|
|||
idle_init_sync();
|
||||
settings_init();
|
||||
tags_init();
|
||||
playlist_init(NULL, &test_cb);
|
||||
playlist_init(&test_cb);
|
||||
while (idle_run_task()) {};
|
||||
|
||||
library = library_find("tests/Music");
|
||||
|
|
|
@ -24,7 +24,7 @@ void test_artist()
|
|||
g_assert_false(playlist_select(NULL));
|
||||
|
||||
pl_artist_deinit();
|
||||
pl_artist_init(NULL);
|
||||
pl_artist_init();
|
||||
|
||||
while (idle_run_task()) {};
|
||||
|
||||
|
@ -65,7 +65,7 @@ int main(int argc, char **argv)
|
|||
idle_init_sync();
|
||||
settings_init();
|
||||
tags_init();
|
||||
playlist_init(NULL, NULL);
|
||||
playlist_init(NULL);
|
||||
while (idle_run_task()) {};
|
||||
|
||||
/* Add tracks to the collection. */
|
||||
|
|
|
@ -53,7 +53,7 @@ void test_library()
|
|||
pl_library_deinit();
|
||||
g_assert_null(playlist_lookup(PL_LIBRARY, "tests/Music"));
|
||||
g_assert_null(library->li_playlist);
|
||||
pl_library_init(NULL);
|
||||
pl_library_init();
|
||||
while (idle_run_task()) {};
|
||||
|
||||
playlist = library->li_playlist;
|
||||
|
@ -115,7 +115,7 @@ int main(int argc, char **argv)
|
|||
idle_init_sync();
|
||||
settings_init();
|
||||
tags_init();
|
||||
playlist_init(NULL, NULL);
|
||||
playlist_init(NULL);
|
||||
while (idle_run_task()) {};
|
||||
|
||||
g_test_init(&argc, &argv, NULL);
|
||||
|
|
|
@ -365,7 +365,7 @@ int main(int argc, char **argv)
|
|||
idle_init_sync();
|
||||
settings_init();
|
||||
tags_init();
|
||||
playlist_init(NULL, NULL);
|
||||
playlist_init(NULL);
|
||||
while (idle_run_task()) {};
|
||||
|
||||
g_test_init(&argc, &argv, NULL);
|
||||
|
|
|
@ -53,7 +53,7 @@ void test_user()
|
|||
|
||||
pl_user_deinit();
|
||||
g_assert_cmpuint(db->db_size, ==, 0);
|
||||
pl_user_init(NULL);
|
||||
pl_user_init();
|
||||
while (idle_run_task()) {};
|
||||
g_assert_cmpuint(db->db_size, ==, 1);
|
||||
|
||||
|
@ -79,7 +79,7 @@ int main(int argc, char **argv)
|
|||
idle_init_sync();
|
||||
settings_init();
|
||||
tags_init();
|
||||
playlist_init(NULL, NULL);
|
||||
playlist_init(NULL);
|
||||
while (idle_run_task()) {};
|
||||
|
||||
playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony");
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -23,7 +23,6 @@ static struct audio_ops test_audio_ops = {
|
|||
};
|
||||
|
||||
struct core_init_data init_data = {
|
||||
.playlist_ops = &playlist_ops,
|
||||
.audio_ops = &test_audio_ops,
|
||||
#ifdef CONFIG_ALBUM_ART_TEST
|
||||
.idle_async = true,
|
||||
|
|
|
@ -8,13 +8,6 @@
|
|||
#include <gui/model.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_state_change(GstState state) {}
|
||||
void test_on_config_pause(int count) {}
|
||||
|
@ -26,7 +19,6 @@ struct audio_ops test_audio_ops = {
|
|||
};
|
||||
|
||||
struct core_init_data init_data = {
|
||||
.playlist_ops = &test_ops,
|
||||
.audio_ops = &test_audio_ops,
|
||||
};
|
||||
|
||||
|
@ -46,8 +38,6 @@ void test_filter()
|
|||
|
||||
entry = GTK_ENTRY(gui_filter_search());
|
||||
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));
|
||||
gui_filter_set_playlist(playlist_lookup(PL_SYSTEM, "Collection"));
|
||||
|
|
|
@ -23,17 +23,11 @@ void on_row_changed(GtkTreeModel *model, GtkTreePath *path,
|
|||
GtkTreeIter *iter, gpointer data)
|
||||
{ count_update++; }
|
||||
|
||||
void *test_queue_init(struct queue *queue, void *data)
|
||||
{ return NULL; }
|
||||
void test_cb_alloc(struct playlist *playlist) {}
|
||||
void test_on_load(struct track *track) {}
|
||||
void test_on_state_change(GstState state) {}
|
||||
void test_on_config_pause(int count) {}
|
||||
|
||||
struct queue_ops test_ops = {
|
||||
.qop_init = test_queue_init,
|
||||
};
|
||||
|
||||
struct playlist_callbacks test_cb = {
|
||||
.pl_cb_alloc = test_cb_alloc,
|
||||
.pl_cb_added = gui_model_add,
|
||||
|
@ -49,7 +43,6 @@ struct audio_ops test_audio_ops = {
|
|||
|
||||
struct core_init_data init_data = {
|
||||
.playlist_cb = &test_cb,
|
||||
.playlist_ops = &test_ops,
|
||||
.audio_ops = &test_audio_ops,
|
||||
};
|
||||
|
||||
|
@ -174,8 +167,6 @@ static void test_model()
|
|||
/* Okay, now scan a directory ... */
|
||||
collection = playlist_lookup(PL_SYSTEM, "Collection");
|
||||
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");
|
||||
while (idle_run_task() == true) {}
|
||||
g_assert_cmpuint(playlist_size(collection), ==, 13);
|
||||
|
|
|
@ -11,9 +11,7 @@
|
|||
#include <gui/treeview.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
struct core_init_data init_data = {
|
||||
.playlist_ops = &playlist_ops,
|
||||
};
|
||||
struct core_init_data init_data;
|
||||
|
||||
static void test_playlist()
|
||||
{
|
||||
|
|
|
@ -11,9 +11,7 @@
|
|||
#include <gui/treeview.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
struct core_init_data init_data = {
|
||||
.playlist_ops = &playlist_ops,
|
||||
};
|
||||
struct core_init_data init_data;
|
||||
|
||||
static void test_library()
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@ static struct audio_ops test_audio_ops = {
|
|||
};
|
||||
|
||||
struct core_init_data init_data = {
|
||||
.playlist_ops = &playlist_ops,
|
||||
.playlist_cb = &playlist_cb,
|
||||
.audio_ops = &test_audio_ops,
|
||||
};
|
||||
|
||||
|
|
|
@ -11,9 +11,7 @@
|
|||
#include <gui/treeview.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
struct core_init_data init_data = {
|
||||
.playlist_ops = &playlist_ops,
|
||||
};
|
||||
struct core_init_data init_data;
|
||||
|
||||
static void test_user()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue