core/playlist: Replace queue_at() with playlist_at()
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
8bf5aefd1a
commit
1c6305e24e
|
@ -117,7 +117,7 @@ static bool sys_pl_hidden_clear(struct playlist *playlist)
|
|||
struct track *track;
|
||||
|
||||
while (playlist_size(playlist) > 0) {
|
||||
track = queue_at(&playlist->pl_queue, 0);
|
||||
track = playlist_at(playlist, 0);
|
||||
sys_pl_hidden_remove(playlist, track);
|
||||
}
|
||||
|
||||
|
|
|
@ -156,14 +156,12 @@ static gboolean __gui_model_iter_nth_child(GtkTreeModel *model,
|
|||
GtkTreeIter *parent,
|
||||
gint n)
|
||||
{
|
||||
struct queue *queue = &cur_playlist->pl_queue;
|
||||
|
||||
if (parent || !cur_playlist || n >= playlist_size(cur_playlist))
|
||||
return FALSE;
|
||||
|
||||
iter->stamp = gui_model->gm_stamp;
|
||||
iter->user_data = GUINT_TO_POINTER(n);
|
||||
iter->user_data2 = queue_at(queue, n);
|
||||
iter->user_data2 = playlist_at(cur_playlist, n);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,4 +76,9 @@ static inline int playlist_current_index(struct playlist *playlist)
|
|||
return playlist ? playlist_iter_index(playlist, playlist->pl_current) : -1;
|
||||
}
|
||||
|
||||
/* Called to find the nth track on a playlist. */
|
||||
static inline struct track *playlist_at(struct playlist *playlist, unsigned int n)
|
||||
{
|
||||
return playlist_iter_track(playlist_iter_get(playlist, n));
|
||||
}
|
||||
#endif /* OCARINA_CORE_PLAYLISTS_ITERATOR_H */
|
||||
|
|
|
@ -37,11 +37,4 @@ void queue_init(struct queue *, const struct queue_ops *, void *);
|
|||
/* Called to deinitialize a queue. */
|
||||
void queue_deinit(struct queue *);
|
||||
|
||||
|
||||
/* Called to access the queued track at a given index. */
|
||||
static inline struct track *queue_at(struct queue *queue, unsigned int index)
|
||||
{
|
||||
return (struct track *)g_queue_peek_nth(&queue->q_tracks, index);
|
||||
}
|
||||
|
||||
#endif /* OCARINA_CORE_QUEUE_H */
|
||||
|
|
|
@ -131,7 +131,7 @@ static void test_playback()
|
|||
|
||||
static void test_next()
|
||||
{
|
||||
struct queue *history_q = &playlist_lookup(PL_SYSTEM, "History")->pl_queue;
|
||||
struct playlist *history = playlist_lookup(PL_SYSTEM, "History");
|
||||
int i;
|
||||
|
||||
state_count = 0;
|
||||
|
@ -146,7 +146,7 @@ static void test_next()
|
|||
g_assert_cmpuint(audio_next()->tr_track, ==, track_get(i)->tr_track);
|
||||
else /* Simulate an error. */
|
||||
test_send_error();
|
||||
g_assert(queue_at(history_q, 0) == track_get(i));
|
||||
g_assert(playlist_at(history, 0) == track_get(i));
|
||||
g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PLAYING);
|
||||
g_assert(audio_cur_track() == track_get(i));
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ static void test_next()
|
|||
g_assert_cmpuint(audio_next()->tr_track, ==, i);
|
||||
else /* Simulate an error. */
|
||||
test_send_error();
|
||||
g_assert_cmpuint(queue_at(history_q, 0)->tr_track, ==, i);
|
||||
g_assert_cmpuint(playlist_at(history, 0)->tr_track, ==, i);
|
||||
g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PLAYING);
|
||||
g_assert_cmpuint(audio_cur_track()->tr_track, ==, i);
|
||||
}
|
||||
|
@ -169,37 +169,37 @@ static void test_next()
|
|||
|
||||
static void test_prev()
|
||||
{
|
||||
struct queue *history_q = &playlist_lookup(PL_SYSTEM, "History")->pl_queue;
|
||||
struct track *track = queue_at(history_q, 0);
|
||||
struct playlist *history = playlist_lookup(PL_SYSTEM, "History");
|
||||
struct track *track = playlist_at(history, 0);
|
||||
|
||||
state_count = 0;
|
||||
g_assert_cmpuint(audio_prev()->tr_track, ==, 2);
|
||||
g_assert(queue_at(history_q, 0) == track);
|
||||
g_assert(playlist_at(history, 0) == track);
|
||||
g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PLAYING);
|
||||
g_assert_cmpuint(audio_cur_track()->tr_track, ==, 2);
|
||||
g_assert_cmpuint(state_count, ==, 1);
|
||||
|
||||
g_assert_cmpuint(audio_prev()->tr_track, ==, 1);
|
||||
g_assert(queue_at(history_q, 0) == track);
|
||||
g_assert(playlist_at(history, 0) == track);
|
||||
g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PLAYING);
|
||||
g_assert_cmpuint(audio_cur_track()->tr_track, ==, 1);
|
||||
g_assert_cmpuint(state_count, ==, 2);
|
||||
|
||||
g_assert_true(audio_pause());
|
||||
g_assert_cmpuint(audio_prev()->tr_track, ==, track_get(0)->tr_track);
|
||||
g_assert(queue_at(history_q, 0) == track);
|
||||
g_assert(playlist_at(history, 0) == track);
|
||||
g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PLAYING);
|
||||
g_assert_cmpuint(audio_cur_track()->tr_track, ==, track_get(0)->tr_track);
|
||||
g_assert_cmpuint(state_count, ==, 4);
|
||||
|
||||
g_assert_cmpuint(audio_prev()->tr_track, ==, track_get(1)->tr_track);
|
||||
g_assert(queue_at(history_q, 0) == track);
|
||||
g_assert(playlist_at(history, 0) == track);
|
||||
g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PLAYING);
|
||||
g_assert_cmpuint(audio_cur_track()->tr_track, ==, track_get(1)->tr_track);
|
||||
g_assert_cmpuint(state_count, ==, 5);
|
||||
|
||||
g_assert_cmpuint(audio_prev()->tr_track, ==, track_get(2)->tr_track);
|
||||
g_assert(queue_at(history_q, 0) == track);
|
||||
g_assert(playlist_at(history, 0) == track);
|
||||
g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PLAYING);
|
||||
g_assert_cmpuint(audio_cur_track()->tr_track, ==, track_get(2)->tr_track);
|
||||
g_assert_cmpuint(state_count, ==, 6);
|
||||
|
@ -207,7 +207,7 @@ static void test_prev()
|
|||
|
||||
void test_autopause()
|
||||
{
|
||||
struct queue *history_q = &playlist_lookup(PL_SYSTEM, "History")->pl_queue;
|
||||
struct playlist *history = playlist_lookup(PL_SYSTEM, "History");
|
||||
int i;
|
||||
|
||||
audio_pause_after(3);
|
||||
|
@ -225,7 +225,7 @@ void test_autopause()
|
|||
audio_eos();
|
||||
g_assert_cmpuint(pause_count, ==, i);
|
||||
g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PLAYING);
|
||||
g_assert(queue_at(history_q, 0) == audio_cur_track());
|
||||
g_assert(playlist_at(history, 0) == audio_cur_track());
|
||||
}
|
||||
g_assert_cmpuint(state_count, ==, 5);
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ static void test_null()
|
|||
g_assert_false(playlist_generic_add(NULL, NULL));
|
||||
g_assert_false(playlist_generic_add_front(NULL, NULL));
|
||||
g_assert_false(playlist_generic_remove(NULL, NULL));
|
||||
g_assert_null(playlist_at(NULL, 0));
|
||||
playlist_generic_update(NULL, NULL);
|
||||
playlist_generic_clear(NULL);
|
||||
|
||||
|
@ -152,6 +153,7 @@ static void test_playlist()
|
|||
g_assert_true( playlist_add(&p, track_get(i)));
|
||||
g_assert_false(playlist_add(&p, track_get(i)));
|
||||
g_assert_true(playlist_has(&p, track_get(i)));
|
||||
g_assert(playlist_at(&p, i) == track_get(i));
|
||||
g_assert_cmpuint(p.pl_length, ==, ex_length);
|
||||
g_assert_cmpuint(playlist_size(&p), ==, i + 1);
|
||||
g_assert(cb_playlist == &p);
|
||||
|
@ -204,7 +206,7 @@ static void test_sorting()
|
|||
g_assert(cb_playlist == &p);
|
||||
g_assert_null(cb_track);
|
||||
for (i = 0; i < 13; i++) {
|
||||
track = queue_at(&p.pl_queue, i);
|
||||
track = playlist_at(&p, i);
|
||||
g_assert_cmpuint(track->tr_track, ==, i + 1);
|
||||
}
|
||||
|
||||
|
@ -213,13 +215,13 @@ static void test_sorting()
|
|||
|
||||
g_assert_true(playlist_sort(&p, COMPARE_COUNT));
|
||||
for (i = 0; i < 13; i++) {
|
||||
track = queue_at(&p.pl_queue, i);
|
||||
track = playlist_at(&p, i);
|
||||
g_assert_cmpuint(track->tr_count, ==, (i < 6) ? 2 : 4);
|
||||
}
|
||||
|
||||
g_assert_true(playlist_sort(&p, COMPARE_TRACK));
|
||||
for (i = 0; i < 13; i++) {
|
||||
track = queue_at(&p.pl_queue, i);
|
||||
track = playlist_at(&p, i);
|
||||
g_assert_cmpuint(track->tr_count, ==, (i < 6) ? 2 : 4);
|
||||
if (i < 6)
|
||||
g_assert_cmpuint(track->tr_track, ==, (i + 1) * 2);
|
||||
|
@ -229,7 +231,7 @@ static void test_sorting()
|
|||
|
||||
g_assert_true(playlist_sort(&p, COMPARE_COUNT));
|
||||
for (i = 0; i < 13; i++) {
|
||||
track = queue_at(&p.pl_queue, i);
|
||||
track = playlist_at(&p, i);
|
||||
g_assert_cmpuint(track->tr_count, ==, (i < 7) ? 4 : 2);
|
||||
if (i < 7)
|
||||
g_assert_cmpuint(track->tr_track, ==, (2 * i) + 1);
|
||||
|
@ -248,7 +250,7 @@ static void test_sorting()
|
|||
g_assert_false(playlist_add(&p, track_get(i)));
|
||||
}
|
||||
for (i = 0; i < 13; i++)
|
||||
g_assert_cmpuint(queue_at(&p.pl_queue, i)->tr_track, ==, 13 - i);
|
||||
g_assert_cmpuint(playlist_at(&p, i)->tr_track, ==, 13 - i);
|
||||
|
||||
/* Deinitialize the playlist. */
|
||||
playlist_generic_deinit(&p);
|
||||
|
@ -340,7 +342,7 @@ static void test_save_load()
|
|||
|
||||
g_assert_false(s.pl_random);
|
||||
g_assert_cmpuint(playlist_current_index(&s), ==, 4);
|
||||
g_assert(playlist_current_track(&s) == queue_at(&q.pl_queue, 4));
|
||||
g_assert(playlist_current_track(&s) == playlist_at(&q, 4));
|
||||
g_assert_cmpuint(g_slist_length(s.pl_sort), ==, 0);
|
||||
g_assert_cmpuint(playlist_size(&s), ==, 13);
|
||||
|
||||
|
|
Loading…
Reference in New Issue