core/queue: Remove unused queue_selected()

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2016-09-20 10:31:30 -04:00
parent 1d09e967d0
commit 287c6e0e9c
5 changed files with 3 additions and 64 deletions

View File

@ -207,6 +207,5 @@ struct track *playlist_generic_next(struct playlist *playlist)
&playlist->pl_queue.q_cur, 0);
}
return queue_selected(&playlist->pl_queue,
playlist->pl_queue.q_cur.it_pos);
return queue_iter_val(&playlist->pl_queue.q_cur);
}

View File

@ -106,14 +106,6 @@ static inline void __queue_updated(struct queue *queue, unsigned int pos)
queue->q_ops->qop_updated(queue, pos);
}
static inline struct track *__queue_selected(struct queue *queue, unsigned int pos)
{
struct track *track = queue_iter_val(&queue->q_cur);
__queue_updated(queue, pos);
return track;
}
void queue_init(struct queue *queue, const struct queue_ops *ops, void *data)
{
queue->q_length = 0;
@ -202,12 +194,3 @@ void queue_updated(struct queue *queue, struct track *track)
__queue_updated(queue, it.it_pos);
}
}
struct track *queue_selected(struct queue *queue, unsigned int index)
{
if (index > queue_size(queue))
return NULL;
if (queue->q_cur.it_pos != index)
queue_iter_set(queue, &queue->q_cur, index);
return __queue_selected(queue, index);
}

View File

@ -131,7 +131,8 @@ void gui_filter_path_load_track(GtkTreePath *path)
unsigned int index = gtk_tree_path_get_indices(path)[0];
audio_load(track);
queue_selected(&gui_model_get_playlist()->pl_queue, index);
queue_iter_set(&gui_model_get_playlist()->pl_queue,
&gui_model_get_playlist()->pl_queue.q_cur, index);
}
unsigned int gui_filter_path_get_index(GtkTreePath *path)

View File

@ -134,8 +134,4 @@ bool queue_has(struct queue *, struct track *);
/* Called to tell the queue that a track has been updated. */
void queue_updated(struct queue *, struct track *);
/* Called to tell the queue that a specific index has been selected. */
struct track *queue_selected(struct queue *, unsigned int);
#endif /* OCARINA_CORE_QUEUE_H */

View File

@ -165,13 +165,6 @@ static void test_queue(gconstpointer arg)
queue_updated(&q, track);
g_assert_cmpuint(count_updated, ==, N / 13);
/* Tracks should not be removed. */
for (i = 0; i < ex_size; i++) {
queue_selected(&q, i);
g_assert_cmpuint(count_updated, ==, (N / 13) + (i + 1));
g_assert_cmpuint(queue_size(&q), ==, ex_size);
}
queue_clear(&q);
g_assert_cmpuint(count_cleared, ==, 1);
g_assert_cmpuint(queue_size(&q), ==, 0);
@ -182,38 +175,6 @@ static void test_queue(gconstpointer arg)
g_assert_null(q.q_sort);
}
static void test_rand_select()
{
unsigned int i;
struct queue q;
g_random_set_seed(0);
queue_init(&q, &test_ops, NULL);
q.q_sort = g_slist_append(q.q_sort, GINT_TO_POINTER(COMPARE_TRACK));
for (i = 0; i < 13; i++)
queue_add(&q, track_get(i));
/*
* The comments below use the following notation:
* <val>: The value pointed to by q._cur.
* (val): The value selected by q.track_selected().
* [val]: The value picked by q.next().
*/
/* select = 6, track = 7 */
g_assert_cmpuint(queue_selected(&q, 6)->tr_track, ==, 7);
/* select = 7, track = 8 */
g_assert_cmpuint(queue_selected(&q, 7)->tr_track, ==, 8);
/* select = 2, track = 3 */
g_assert_cmpuint(queue_selected(&q, 2)->tr_track, ==, 3);
g_assert_null(queue_selected(&q, 14));
queue_deinit(&q);
}
int main(int argc, char **argv)
{
struct library *library;
@ -244,7 +205,6 @@ int main(int argc, char **argv)
g_test_add_data_func("/Core/Queue/n = 0", GUINT_TO_POINTER( 0), test_queue);
g_test_add_data_func("/Core/Queue/n = 13", GUINT_TO_POINTER( 13), test_queue);
g_test_add_data_func("/Core/Queue/n = 100,009)", GUINT_TO_POINTER(100009), test_queue);
g_test_add_func("/Core/Queue/Random Next and Selection", test_rand_select);
ret = g_test_run();
tags_deinit();