summaryrefslogtreecommitdiffstats
path: root/audio/out
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-11-24 19:47:58 +0100
committerwm4 <wm4@nowhere>2015-11-24 19:47:58 +0100
commit06df54a111c6a4b4ed3f682c8a5e82c11a70a80f (patch)
tree75f88183006afc118653cc1938cf2036ed92c562 /audio/out
parentef918b239ec514f0e6b26dd3633096be1ec1fb3e (diff)
downloadmpv-06df54a111c6a4b4ed3f682c8a5e82c11a70a80f.tar.bz2
mpv-06df54a111c6a4b4ed3f682c8a5e82c11a70a80f.tar.xz
ao_alsa: filter audio device list
Remove known useless device entries from the --audio-device list (and corresponding property). Do this because the list is supposed to be a high level list of devices the user can select. ALSA does not provide such a list (in an useable manner), and ao_alsa.c is still in the best position to improve the situation somewhat.
Diffstat (limited to 'audio/out')
-rw-r--r--audio/out/ao_alsa.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index a0b05c898d..9ffd4792ee 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -977,6 +977,20 @@ alsa_error:
return -1;
}
+static bool is_useless_device(char *name)
+{
+ char *crap[] = {"front", "rear", "center_lfe", "side", "surround21",
+ "surround40", "surround41", "surround50", "surround51", "surround71",
+ "sysdefault", "pulse", "null", "dsnoop", "dmix", "hw", "iec958"};
+ for (int i = 0; i < MP_ARRAY_SIZE(crap); i++) {
+ int l = strlen(crap[i]);
+ if (name && strncmp(name, crap[i], l) == 0 &&
+ (!name[l] || name[l] == ':'))
+ return true;
+ }
+ return false;
+}
+
static void list_devs(struct ao *ao, struct ao_device_list *list)
{
void **hints;
@@ -987,7 +1001,7 @@ static void list_devs(struct ao *ao, struct ao_device_list *list)
char *name = snd_device_name_get_hint(hints[n], "NAME");
char *desc = snd_device_name_get_hint(hints[n], "DESC");
char *io = snd_device_name_get_hint(hints[n], "IOID");
- if (!io || strcmp(io, "Output") == 0) {
+ if (!is_useless_device(name) && (!io || strcmp(io, "Output") == 0)) {
char desc2[1024];
snprintf(desc2, sizeof(desc2), "%s", desc ? desc : "");
for (int i = 0; desc2[i]; i++) {