summaryrefslogtreecommitdiff
path: root/src/pa-sink-ctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pa-sink-ctl.c')
-rw-r--r--src/pa-sink-ctl.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/pa-sink-ctl.c b/src/pa-sink-ctl.c
index df51b5e..d1fb637 100644
--- a/src/pa-sink-ctl.c
+++ b/src/pa-sink-ctl.c
@@ -114,21 +114,13 @@ get_sink_priority(struct context *ctx, const pa_sink_info *sink_info)
return 0;
}
-static void
-add_sink(struct context *ctx, sink_info *new)
+static gint
+cmp_priority(gconstpointer list_data, gconstpointer b)
{
- GList *l, *pos = NULL;
-
- for (l = ctx->sink_list; l; l = l->next) {
- sink_info *sink = l->data;
+ const sink_info *sink_el = list_data;
+ const sink_info *sink = b;
- if (new->priority > sink->priority) {
- pos = l;
- break;
- }
- }
- ctx->sink_list = g_list_insert_before(ctx->sink_list, pos,
- g_memdup(new, sizeof *new));
+ return (sink->priority > sink_el->priority) ? 0 : -1;
}
static void
@@ -169,7 +161,9 @@ sink_info_cb(pa_context *c, const pa_sink_info *i,
if (inlist)
*inlist = sink;
else
- add_sink(ctx, &sink);
+ list_insert_struct(ctx->sink_list, sink,
+ g_list_find_custom(ctx->sink_list,
+ &sink, cmp_priority));
}
static void