diff --git a/core/playlists/generic.c b/core/playlists/generic.c index fdeda6bd..27bb7e1b 100644 --- a/core/playlists/generic.c +++ b/core/playlists/generic.c @@ -34,7 +34,7 @@ void playlist_noop_sort(struct playlist *playlist, void playlist_generic_init(struct playlist *playlist, unsigned int flags, struct queue_ops *ops) { - queue_init(&playlist->pl_queue, flags | Q_ENABLED, ops, playlist); + queue_init(&playlist->pl_queue, flags, ops, playlist); queue_sort(&playlist->pl_queue, COMPARE_ARTIST, true); queue_sort(&playlist->pl_queue, COMPARE_YEAR, false); queue_sort(&playlist->pl_queue, COMPARE_TRACK, false); diff --git a/core/playlists/system.c b/core/playlists/system.c index c04b82b3..6c1ed3ab 100644 --- a/core/playlists/system.c +++ b/core/playlists/system.c @@ -162,7 +162,7 @@ static bool sys_pl_queued_load() static void sys_pl_queued_init(struct playlist *playlist, unsigned int flags, struct queue_ops *ops) { - queue_init(&playlist->pl_queue, Q_ENABLED, ops, playlist); + queue_init(&playlist->pl_queue, 0, ops, playlist); } static struct sys_playlist sys_queued = { @@ -229,8 +229,7 @@ static struct sys_playlist sys_collection = { static void sys_pl_history_init(struct playlist *playlist, unsigned int flags, struct queue_ops *ops) { - queue_init(&playlist->pl_queue, Q_ENABLED | Q_REPEAT | Q_ADD_FRONT, - ops, playlist); + queue_init(&playlist->pl_queue, Q_REPEAT | Q_ADD_FRONT, ops, playlist); } static bool sys_pl_history_add(struct playlist *playlist, struct track *track) diff --git a/core/queue.c b/core/queue.c index a05eed29..8c090a5c 100644 --- a/core/queue.c +++ b/core/queue.c @@ -332,12 +332,9 @@ struct track *queue_next(struct queue *queue) { unsigned int pos, size = queue_size(queue); - if (!queue_has_flag(queue, Q_ENABLED)) + if (size == 0) return NULL; - else if (size == 0) - return NULL; - - if (size == 1) + else if (size == 1) queue_iter_set(queue, &queue->q_cur, 0); else if (queue_has_flag(queue, Q_RANDOM)) { pos = g_random_int_range(1, (size < 15) ? size : size / 3); diff --git a/include/core/queue.h b/include/core/queue.h index 5f22f528..f642851c 100644 --- a/include/core/queue.h +++ b/include/core/queue.h @@ -15,7 +15,7 @@ struct queue; enum queue_flags { - Q_ENABLED = (1 << 0), /* Queue is enabled. */ + Q_UNUSED_0 = (1 << 0), /* Removed: 6.5.4 */ Q_RANDOM = (1 << 1), /* Queue will pick songs randomly. */ Q_REPEAT = (1 << 2), /* Queue will not remove songs when picked. */ Q_UNUSED_3 = (1 << 3), /* Removed: 6.5.4 */ @@ -24,7 +24,7 @@ enum queue_flags { Q_ADD_FRONT = (1 << 6), /* Queue will add new tracks at the front. */ }; -#define Q_UNUSED_MASK (~(Q_UNUSED_3 | Q_UNUSED_4 | Q_UNUSED_5)) +#define Q_UNUSED_MASK (~(Q_UNUSED_0 | Q_UNUSED_3 | Q_UNUSED_4 | Q_UNUSED_5)) struct queue_ops { diff --git a/tests/core/queue.c b/tests/core/queue.c index dc500f8a..a67c6eff 100644 --- a/tests/core/queue.c +++ b/tests/core/queue.c @@ -91,12 +91,12 @@ static void test_init() queue_deinit(&q); g_assert_cmpuint(count_deinit, ==, 0); - queue_init(&q, Q_ENABLED | Q_RANDOM, &test_ops, NULL); + queue_init(&q, Q_RANDOM, &test_ops, NULL); g_assert_cmpuint(count_init, ==, 1); g_assert_cmpuint(GPOINTER_TO_UINT(q.q_private), ==, 1); g_assert_cmpuint(q.q_cur.it_pos, ==, (unsigned int)-1); - g_assert_cmpuint(q.q_flags, ==, Q_ENABLED | Q_RANDOM); + g_assert_cmpuint(q.q_flags, ==, Q_RANDOM); g_assert_cmpuint(q.q_length, ==, 0); g_assert_null(q.q_sort); g_assert(q.q_ops == &test_ops); @@ -112,7 +112,7 @@ static void test_flags() queue_init(&q, 0, &test_ops, NULL); g_assert_cmpuint(q.q_flags, ==, 0); - g_assert_false(queue_has_flag(&q, Q_ENABLED)); + g_assert_false(queue_has_flag(&q, Q_UNUSED_0)); g_assert_false(queue_has_flag(&q, Q_RANDOM)); g_assert_false(queue_has_flag(&q, Q_REPEAT)); g_assert_false(queue_has_flag(&q, Q_UNUSED_3)); @@ -120,22 +120,13 @@ static void test_flags() g_assert_false(queue_has_flag(&q, Q_UNUSED_5)); g_assert_false(queue_has_flag(&q, Q_ADD_FRONT)); - queue_set_flag(&q, Q_ENABLED); - g_assert_cmpuint(q.q_flags, ==, Q_ENABLED); - - queue_unset_flag(&q, Q_ENABLED); - g_assert_cmpuint(q.q_flags, ==, 0); - - queue_set_flag(&q, Q_ENABLED); queue_set_flag(&q, Q_RANDOM); queue_set_flag(&q, Q_REPEAT); queue_set_flag(&q, Q_ADD_FRONT); - g_assert_true(queue_has_flag(&q, Q_ENABLED)); g_assert_true(queue_has_flag(&q, Q_RANDOM)); g_assert_true(queue_has_flag(&q, Q_REPEAT)); g_assert_true(queue_has_flag(&q, Q_ADD_FRONT)); - queue_unset_flag(&q, Q_ENABLED); queue_unset_flag(&q, Q_RANDOM); queue_unset_flag(&q, Q_REPEAT); queue_unset_flag(&q, Q_ADD_FRONT); @@ -227,11 +218,7 @@ static void test_queue(gconstpointer arg) queue_updated(&q, track); g_assert_cmpuint(count_updated, ==, N / 13); - g_assert_null(queue_next(&q)); - g_assert_cmpint(queue_size(&q), ==, ex_size); - /* Tracks should not be removed. */ - queue_set_flag(&q, Q_ENABLED); queue_set_flag(&q, Q_REPEAT); for (i = 0; i < ex_size; i++) { g_assert(queue_next(&q) == track_get((i % 11) + 2)); @@ -269,7 +256,7 @@ static void test_rand_select() struct queue q; g_random_set_seed(0); - queue_init(&q, Q_ENABLED | Q_RANDOM, &test_ops, NULL); + queue_init(&q, Q_RANDOM, &test_ops, NULL); /* Call next() on an empty queue. */ for (i = 0; i < 13; i++) {