context: fix sorted insert

This commit is contained in:
Wim Taymans 2020-06-30 20:22:53 +02:00
parent 34775b7577
commit 813e2d22a6

View file

@ -1104,14 +1104,19 @@ static int set_mask(pa_context *c, struct global *g)
static inline void insert_global(pa_context *c, struct global *global) static inline void insert_global(pa_context *c, struct global *global)
{ {
struct global *g, *t; struct global *g;
bool found = false;
spa_list_for_each_safe(g, t, &c->globals, link) { spa_list_for_each(g, &c->globals, link) {
if (g->priority_master < global->priority_master) { if (g->priority_master < global->priority_master) {
g = spa_list_prev(g, link); g = spa_list_prev(g, link);
found = true;
break; break;
} }
} }
if (!found)
spa_list_append(&g->link, &global->link);
else
spa_list_prepend(&g->link, &global->link); spa_list_prepend(&g->link, &global->link);
} }