core/queue: Remove Q_ENABLED flag
Queues are always enabled now that we can select different playlists as the default. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
7e3e4194f3
commit
c59b097638
|
@ -34,7 +34,7 @@ void playlist_noop_sort(struct playlist *playlist,
|
||||||
void playlist_generic_init(struct playlist *playlist, unsigned int flags,
|
void playlist_generic_init(struct playlist *playlist, unsigned int flags,
|
||||||
struct queue_ops *ops)
|
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_ARTIST, true);
|
||||||
queue_sort(&playlist->pl_queue, COMPARE_YEAR, false);
|
queue_sort(&playlist->pl_queue, COMPARE_YEAR, false);
|
||||||
queue_sort(&playlist->pl_queue, COMPARE_TRACK, false);
|
queue_sort(&playlist->pl_queue, COMPARE_TRACK, false);
|
||||||
|
|
|
@ -162,7 +162,7 @@ static bool sys_pl_queued_load()
|
||||||
static void sys_pl_queued_init(struct playlist *playlist,
|
static void sys_pl_queued_init(struct playlist *playlist,
|
||||||
unsigned int flags, struct queue_ops *ops)
|
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 = {
|
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,
|
static void sys_pl_history_init(struct playlist *playlist,
|
||||||
unsigned int flags, struct queue_ops *ops)
|
unsigned int flags, struct queue_ops *ops)
|
||||||
{
|
{
|
||||||
queue_init(&playlist->pl_queue, Q_ENABLED | Q_REPEAT | Q_ADD_FRONT,
|
queue_init(&playlist->pl_queue, Q_REPEAT | Q_ADD_FRONT, ops, playlist);
|
||||||
ops, playlist);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool sys_pl_history_add(struct playlist *playlist, struct track *track)
|
static bool sys_pl_history_add(struct playlist *playlist, struct track *track)
|
||||||
|
|
|
@ -332,12 +332,9 @@ struct track *queue_next(struct queue *queue)
|
||||||
{
|
{
|
||||||
unsigned int pos, size = queue_size(queue);
|
unsigned int pos, size = queue_size(queue);
|
||||||
|
|
||||||
if (!queue_has_flag(queue, Q_ENABLED))
|
if (size == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
else if (size == 0)
|
else if (size == 1)
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (size == 1)
|
|
||||||
queue_iter_set(queue, &queue->q_cur, 0);
|
queue_iter_set(queue, &queue->q_cur, 0);
|
||||||
else if (queue_has_flag(queue, Q_RANDOM)) {
|
else if (queue_has_flag(queue, Q_RANDOM)) {
|
||||||
pos = g_random_int_range(1, (size < 15) ? size : size / 3);
|
pos = g_random_int_range(1, (size < 15) ? size : size / 3);
|
||||||
|
|
|
@ -15,7 +15,7 @@ struct queue;
|
||||||
|
|
||||||
|
|
||||||
enum queue_flags {
|
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_RANDOM = (1 << 1), /* Queue will pick songs randomly. */
|
||||||
Q_REPEAT = (1 << 2), /* Queue will not remove songs when picked. */
|
Q_REPEAT = (1 << 2), /* Queue will not remove songs when picked. */
|
||||||
Q_UNUSED_3 = (1 << 3), /* Removed: 6.5.4 */
|
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. */
|
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 {
|
struct queue_ops {
|
||||||
|
|
|
@ -91,12 +91,12 @@ static void test_init()
|
||||||
queue_deinit(&q);
|
queue_deinit(&q);
|
||||||
g_assert_cmpuint(count_deinit, ==, 0);
|
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(count_init, ==, 1);
|
||||||
g_assert_cmpuint(GPOINTER_TO_UINT(q.q_private), ==, 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_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_cmpuint(q.q_length, ==, 0);
|
||||||
g_assert_null(q.q_sort);
|
g_assert_null(q.q_sort);
|
||||||
g_assert(q.q_ops == &test_ops);
|
g_assert(q.q_ops == &test_ops);
|
||||||
|
@ -112,7 +112,7 @@ static void test_flags()
|
||||||
|
|
||||||
queue_init(&q, 0, &test_ops, NULL);
|
queue_init(&q, 0, &test_ops, NULL);
|
||||||
g_assert_cmpuint(q.q_flags, ==, 0);
|
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_RANDOM));
|
||||||
g_assert_false(queue_has_flag(&q, Q_REPEAT));
|
g_assert_false(queue_has_flag(&q, Q_REPEAT));
|
||||||
g_assert_false(queue_has_flag(&q, Q_UNUSED_3));
|
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_UNUSED_5));
|
||||||
g_assert_false(queue_has_flag(&q, Q_ADD_FRONT));
|
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_RANDOM);
|
||||||
queue_set_flag(&q, Q_REPEAT);
|
queue_set_flag(&q, Q_REPEAT);
|
||||||
queue_set_flag(&q, Q_ADD_FRONT);
|
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_RANDOM));
|
||||||
g_assert_true(queue_has_flag(&q, Q_REPEAT));
|
g_assert_true(queue_has_flag(&q, Q_REPEAT));
|
||||||
g_assert_true(queue_has_flag(&q, Q_ADD_FRONT));
|
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_RANDOM);
|
||||||
queue_unset_flag(&q, Q_REPEAT);
|
queue_unset_flag(&q, Q_REPEAT);
|
||||||
queue_unset_flag(&q, Q_ADD_FRONT);
|
queue_unset_flag(&q, Q_ADD_FRONT);
|
||||||
|
@ -227,11 +218,7 @@ static void test_queue(gconstpointer arg)
|
||||||
queue_updated(&q, track);
|
queue_updated(&q, track);
|
||||||
g_assert_cmpuint(count_updated, ==, N / 13);
|
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. */
|
/* Tracks should not be removed. */
|
||||||
queue_set_flag(&q, Q_ENABLED);
|
|
||||||
queue_set_flag(&q, Q_REPEAT);
|
queue_set_flag(&q, Q_REPEAT);
|
||||||
for (i = 0; i < ex_size; i++) {
|
for (i = 0; i < ex_size; i++) {
|
||||||
g_assert(queue_next(&q) == track_get((i % 11) + 2));
|
g_assert(queue_next(&q) == track_get((i % 11) + 2));
|
||||||
|
@ -269,7 +256,7 @@ static void test_rand_select()
|
||||||
struct queue q;
|
struct queue q;
|
||||||
|
|
||||||
g_random_set_seed(0);
|
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. */
|
/* Call next() on an empty queue. */
|
||||||
for (i = 0; i < 13; i++) {
|
for (i = 0; i < 13; i++) {
|
||||||
|
|
Loading…
Reference in New Issue