core/queue: Remove Q_SAVE_FLAGS and Q_SAVE_SORT

These flags are unused now that the playlist layer handles saving.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2016-09-07 08:28:56 -04:00
parent 15ceda1194
commit 62e494f2af
4 changed files with 9 additions and 32 deletions

View File

@ -148,7 +148,7 @@ static bool sys_pl_queued_load()
file_readf(&sys_deck_f, "%u", &num);
for (i = 0; i < num; i++) {
file_readf(&sys_deck_f, "%u", &flags);
flags &= ~(Q_SAVE_SORT | Q_SAVE_FLAGS);
flags &= Q_UNUSED_MASK;
if (i == 0)
queue->q_flags |= flags;
queue_load_tracks(queue, &sys_deck_f);
@ -189,8 +189,6 @@ static bool sys_pl_collection_load()
if (file_open(&sys_collection_f, OPEN_READ)) {
queue_load_flags(&playlist->pl_queue, &sys_collection_f, false);
queue_unset_flag(&playlist->pl_queue, Q_SAVE_FLAGS);
queue_unset_flag(&playlist->pl_queue, Q_SAVE_SORT);
file_close(&sys_collection_f);
file_remove(&sys_collection_f);
}

View File

@ -199,6 +199,7 @@ void queue_load_flags(struct queue *queue, struct file *file, bool iter)
queue_sort(queue, field + 1, false);
}
flags &= Q_UNUSED_MASK;
queue->q_flags |= flags;
queue->q_cur.it_pos = it;
@ -224,7 +225,6 @@ void queue_load_tracks(struct queue *queue, struct file *file)
void queue_set_flag(struct queue *queue, enum queue_flags flag)
{
queue->q_flags |= flag;
__queue_save(queue, Q_SAVE_FLAGS);
}
void queue_unset_flag(struct queue *queue, enum queue_flags flag)
@ -236,7 +236,6 @@ void queue_unset_flag(struct queue *queue, enum queue_flags flag)
queue_resort(queue);
queue_iter_set(queue, &queue->q_cur, queue->q_cur.it_pos);
}
__queue_save(queue, Q_SAVE_FLAGS);
}
unsigned int queue_add(struct queue *queue, struct track *track)
@ -393,5 +392,4 @@ void queue_sort(struct queue *queue, enum compare_t sort, bool reset)
out_sort:
queue_resort(queue);
__queue_save(queue, Q_SAVE_SORT);
}

View File

@ -19,11 +19,13 @@ enum queue_flags {
Q_RANDOM = (1 << 1), /* Queue will pick songs randomly. */
Q_REPEAT = (1 << 2), /* Queue will not remove songs when picked. */
Q_NO_SORT = (1 << 3), /* Queue will not be sorted. */
Q_SAVE_FLAGS = (1 << 4), /* Queue will be saved when flags change. */
Q_SAVE_SORT = (1 << 5), /* Queue will be saved when sorted. */
Q_UNUSED_4 = (1 << 4), /* Queue will be saved when flags change. */
Q_UNUSED_5 = (1 << 5), /* Queue will be saved when sorted. */
Q_ADD_FRONT = (1 << 6), /* Queue will add new tracks at the front. */
};
#define Q_UNUSED_MASK (~(Q_UNUSED_4 | Q_UNUSED_5))
struct queue_ops {
/* Called to tell a higher layer that a queue has been initialized. */

View File

@ -13,8 +13,6 @@ unsigned int count_added = 0;
unsigned int count_erase = 0;
unsigned int count_deleted = 0;
unsigned int count_cleared = 0;
unsigned int count_flags = 0;
unsigned int count_sort = 0;
unsigned int count_updated = 0;
bool can_erase = true;
@ -54,10 +52,6 @@ static void queue_op_cleared(struct queue *queue, unsigned int n)
static void queue_op_save(struct queue *queue, enum queue_flags flag)
{
if (flag == Q_SAVE_FLAGS)
count_flags++;
else if (flag == Q_SAVE_SORT)
count_sort++;
}
static void queue_op_updated(struct queue *queue, unsigned int pos)
@ -127,19 +121,16 @@ static void test_flags()
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_NO_SORT));
g_assert_false(queue_has_flag(&q, Q_SAVE_FLAGS));
g_assert_false(queue_has_flag(&q, Q_SAVE_SORT));
g_assert_false(queue_has_flag(&q, Q_UNUSED_4));
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);
g_assert_cmpuint(count_flags, ==, 0);
queue_unset_flag(&q, Q_ENABLED);
g_assert_cmpuint(q.q_flags, ==, 0);
g_assert_cmpuint(count_flags, ==, 0);
queue_set_flag(&q, Q_SAVE_FLAGS);
queue_set_flag(&q, Q_ENABLED);
queue_set_flag(&q, Q_RANDOM);
queue_set_flag(&q, Q_REPEAT);
@ -149,18 +140,14 @@ static void test_flags()
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_NO_SORT));
g_assert_true(queue_has_flag(&q, Q_SAVE_FLAGS));
g_assert_true(queue_has_flag(&q, Q_ADD_FRONT));
g_assert_cmpuint(count_flags, ==, 6);
queue_unset_flag(&q, Q_ENABLED);
queue_unset_flag(&q, Q_RANDOM);
queue_unset_flag(&q, Q_REPEAT);
queue_unset_flag(&q, Q_NO_SORT);
queue_unset_flag(&q, Q_ADD_FRONT);
queue_unset_flag(&q, Q_SAVE_FLAGS);
g_assert_cmpuint(q.q_flags, ==, 0);
g_assert_cmpuint(count_flags, ==, 11);
}
static void test_queue(gconstpointer arg)
@ -377,7 +364,7 @@ static void test_sorting()
unsigned int i;
struct queue q;
queue_init(&q, Q_SAVE_SORT | Q_ADD_FRONT, &test_ops, NULL);
queue_init(&q, Q_ADD_FRONT, &test_ops, NULL);
for (i = 0; i < 13; i++) {
track = track_get(i);
track->tr_count = (track->tr_track <= 6) ? 4 : 2;
@ -389,7 +376,6 @@ static void test_sorting()
g_assert_nonnull(track);
g_assert_cmpuint(track->tr_dbe.dbe_index, ==, 12 - i);
}
g_assert_cmpuint(count_sort, ==, 0);
queue_sort(&q, COMPARE_TRACK, true);
for (i = 0; i < 13; i++) {
@ -397,7 +383,6 @@ static void test_sorting()
g_assert_nonnull(track);
g_assert_cmpuint(track->tr_track, ==, i + 1);
}
g_assert_cmpuint(count_sort, ==, 1);
queue_sort(&q, COMPARE_COUNT, true);
for (i = 0; i < 13; i++) {
@ -405,7 +390,6 @@ static void test_sorting()
g_assert_nonnull(track);
g_assert_cmpuint(track->tr_track, ==, ex_count[i]);
}
g_assert_cmpuint(count_sort, ==, 2);
queue_set_flag(&q, Q_NO_SORT);
queue_sort(&q, COMPARE_TITLE, true);
@ -414,7 +398,6 @@ static void test_sorting()
g_assert_nonnull(track);
g_assert_cmpuint(track->tr_track, ==, ex_count[i]);
}
g_assert_cmpuint(count_sort, ==, 2);
queue_unset_flag(&q, Q_NO_SORT);
queue_sort(&q, COMPARE_TITLE, true);
@ -423,7 +406,6 @@ static void test_sorting()
g_assert_nonnull(track);
g_assert_cmpuint(track->tr_track, ==, ex_title[i]);
}
g_assert_cmpuint(count_sort, ==, 3);
queue_sort(&q, COMPARE_COUNT, true);
queue_sort(&q, COMPARE_TITLE, false);
@ -433,9 +415,7 @@ static void test_sorting()
g_assert_nonnull(track);
g_assert_cmpuint(track->tr_track, ==, ex_co_ti[i]);
}
g_assert_cmpuint(count_sort, ==, 6);
queue_unset_flag(&q, Q_SAVE_SORT);
queue_sort(&q, COMPARE_ARTIST, true);
queue_sort(&q, COMPARE_ALBUM, false);
queue_sort(&q, COMPARE_TRACK, false);
@ -445,7 +425,6 @@ static void test_sorting()
g_assert_nonnull(track);
g_assert_cmpuint(track->tr_track, ==, 13 - i);
}
g_assert_cmpuint(count_sort, ==, 6);
queue_deinit(&q);
g_assert_cmpuint(q.q_length, ==, 0);