Module Name:    src
Committed By:   nia
Date:           Sat May  8 13:03:41 UTC 2021

Modified Files:
        src/usr.bin/aiomixer: parse.c

Log Message:
aiomixer: try to make sure the first pane is always "outputs"

In QEMU with an ac97 audio device, "inputs" is the first pane,
which is significantly less important especially when you don't
have input in QEMU most of the time.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/aiomixer/parse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/aiomixer/parse.c
diff -u src/usr.bin/aiomixer/parse.c:1.2 src/usr.bin/aiomixer/parse.c:1.3
--- src/usr.bin/aiomixer/parse.c:1.2	Sat May  8 12:53:15 2021
+++ src/usr.bin/aiomixer/parse.c	Sat May  8 13:03:40 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.2 2021/05/08 12:53:15 nia Exp $ */
+/* $NetBSD: parse.c,v 1.3 2021/05/08 13:03:40 nia Exp $ */
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -36,6 +36,7 @@
 
 static struct aiomixer_class *get_class(struct aiomixer *, int);
 static int compare_control(const void *, const void *);
+static int compare_class(const void *, const void *);
 
 static struct aiomixer_class *
 get_class(struct aiomixer *aio, int class)
@@ -68,6 +69,20 @@ compare_control(const void *pa, const vo
 	return 0;
 }
 
+static int
+compare_class(const void *pa, const void *pb)
+{
+	const struct aiomixer_class *a = (const struct aiomixer_class *)pa;
+	const struct aiomixer_class *b = (const struct aiomixer_class *)pb;
+
+	if (strcmp(a->name, AudioCoutputs) == 0)
+		return -1;
+	if (strcmp(b->name, AudioCoutputs) == 0)
+		return 1;
+
+	return strcmp(a->name, b->name);
+}
+
 int
 aiomixer_parse(struct aiomixer *aio)
 {
@@ -106,6 +121,9 @@ aiomixer_parse(struct aiomixer *aio)
 		control = &class->controls[class->numcontrols++];
 		control->info = info;
 	}
+	qsort(aio->classes, aio->numclasses,
+	    sizeof(struct aiomixer_class),
+	    compare_class);
 	for (i = 0; i < aio->numclasses; ++i) {
 		class = &aio->classes[i];
 		qsort(class->controls, class->numcontrols,

Reply via email to