diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-12-12 23:28:09 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-12-12 23:28:09 +0100 |
commit | a76d55f553341b46c5b3bd4218df5aff3365433a (patch) | |
tree | 256f7cab59ba376b89c400aa038d3bd9ed143447 /src | |
parent | 3898263f329e877d9b6a997d7a92851908d19166 (diff) | |
download | pa-sink-ctl-a76d55f553341b46c5b3bd4218df5aff3365433a.tar.gz pa-sink-ctl-a76d55f553341b46c5b3bd4218df5aff3365433a.tar.bz2 pa-sink-ctl-a76d55f553341b46c5b3bd4218df5aff3365433a.zip |
Revert "Use g_list_find_custom to calculate sink position"
This reverts commit 3898263f329e877d9b6a997d7a92851908d19166.
Diffstat (limited to 'src')
-rw-r--r-- | src/pa-sink-ctl.c | 22 | ||||
-rw-r--r-- | src/pa-sink-ctl.h | 9 |
2 files changed, 17 insertions, 14 deletions
diff --git a/src/pa-sink-ctl.c b/src/pa-sink-ctl.c index d1fb637..df51b5e 100644 --- a/src/pa-sink-ctl.c +++ b/src/pa-sink-ctl.c @@ -114,13 +114,21 @@ get_sink_priority(struct context *ctx, const pa_sink_info *sink_info) return 0; } -static gint -cmp_priority(gconstpointer list_data, gconstpointer b) +static void +add_sink(struct context *ctx, sink_info *new) { - const sink_info *sink_el = list_data; - const sink_info *sink = b; + GList *l, *pos = NULL; + + for (l = ctx->sink_list; l; l = l->next) { + sink_info *sink = l->data; - return (sink->priority > sink_el->priority) ? 0 : -1; + if (new->priority > sink->priority) { + pos = l; + break; + } + } + ctx->sink_list = g_list_insert_before(ctx->sink_list, pos, + g_memdup(new, sizeof *new)); } static void @@ -161,9 +169,7 @@ sink_info_cb(pa_context *c, const pa_sink_info *i, if (inlist) *inlist = sink; else - list_insert_struct(ctx->sink_list, sink, - g_list_find_custom(ctx->sink_list, - &sink, cmp_priority)); + add_sink(ctx, &sink); } static void diff --git a/src/pa-sink-ctl.h b/src/pa-sink-ctl.h index ac5f476..d8cd5bb 100644 --- a/src/pa-sink-ctl.h +++ b/src/pa-sink-ctl.h @@ -61,13 +61,10 @@ quit(struct context *ctx); void change_callback(pa_context* c, gint success, gpointer); - -#define list_insert_struct(list, data, pos) \ +#define list_append_struct(list, data) \ do { \ - (list) = g_list_insert_before((list), (pos), \ - g_memdup(&(data), sizeof(data)));\ + (list) = g_list_append((list), \ + g_memdup(&(data), sizeof(data))); \ } while (0) -#define list_append_struct(list, data) list_insert_struct((list), (data), NULL) - #endif |