File tree 1 file changed +12
-0
lines changed
1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 11
11
#include <getopt.h>
12
12
#include <stdio.h>
13
13
#include <stdlib.h>
14
+ #include <string.h>
14
15
15
16
#include <dbus/dbus.h>
16
17
17
18
#include "bluealsactl.h"
18
19
#include "shared/dbus-client-pcm.h"
19
20
21
+ static int ba_pcm_cmp (const void * a , const void * b ) {
22
+ const struct ba_pcm * pcm_a = a ;
23
+ const struct ba_pcm * pcm_b = b ;
24
+ if (pcm_a -> sequence == pcm_b -> sequence )
25
+ return strcmp (pcm_a -> pcm_path , pcm_b -> pcm_path );
26
+ return pcm_a -> sequence - pcm_b -> sequence ;
27
+ }
28
+
20
29
static void usage (const char * command ) {
21
30
printf ("List all BlueALSA PCM paths.\n\n" );
22
31
bactl_print_usage ("%s [OPTION]..." , command );
@@ -64,6 +73,9 @@ static int cmd_list_pcms_func(int argc, char *argv[]) {
64
73
return EXIT_FAILURE ;
65
74
}
66
75
76
+ /* Sort PCMs from the oldest to the newest (most recently added). */
77
+ qsort (pcms , pcms_count , sizeof (* pcms ), ba_pcm_cmp );
78
+
67
79
for (size_t i = 0 ; i < pcms_count ; i ++ ) {
68
80
printf ("%s\n" , pcms [i ].pcm_path );
69
81
if (config .verbose ) {
You can’t perform that action at this time.
0 commit comments