From 06df54a111c6a4b4ed3f682c8a5e82c11a70a80f Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 24 Nov 2015 19:47:58 +0100 Subject: 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. --- audio/out/ao_alsa.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'audio/out') 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++) { -- cgit v1.2.3