summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-06 21:33:54 +0200
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-05-07 10:54:32 +0900
commit76d2ba6283cac45a740a1dbb7f3a43326360d2c4 (patch)
tree7f0904ad3c62382c7b905ef191bade3e56527b09 /audio
parent048cd1e73da53f9300f6428280446954bbc0dc4d (diff)
downloadmpv-76d2ba6283cac45a740a1dbb7f3a43326360d2c4.tar.bz2
mpv-76d2ba6283cac45a740a1dbb7f3a43326360d2c4.tar.xz
ao_alsa: move ALSA -> mp channel map to a function
One side effect is that the warning about too many channels goes away, and is replaced with printing the ALSA channel map as "unknown". (cherry picked from commit d577872a28c9729e987566530905bde238af8109)
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao_alsa.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index f4565da0dc..82494717cf 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -275,6 +275,20 @@ static int find_alsa_channel(int mp_channel)
return SND_CHMAP_UNKNOWN;
}
+static int mp_chmap_from_alsa(struct mp_chmap *dst, snd_pcm_chmap_t *src)
+{
+ *dst = (struct mp_chmap) {0};
+
+ if (src->channels > MP_NUM_CHANNELS)
+ return -1;
+
+ dst->num = src->channels;
+ for (int c = 0; c < dst->num; c++)
+ dst->speaker[c] = find_mp_channel(src->pos[c]);
+
+ return 0;
+}
+
static bool query_chmaps(struct ao *ao, struct mp_chmap *chmap)
{
struct priv *p = ao->priv;
@@ -285,14 +299,8 @@ static bool query_chmaps(struct ao *ao, struct mp_chmap *chmap)
return false;
for (int i = 0; maps[i] != NULL; i++) {
- if (maps[i]->map.channels > MP_NUM_CHANNELS) {
- MP_VERBOSE(ao, "skipping ALSA channel map with too many channels.\n");
- continue;
- }
-
- struct mp_chmap entry = {.num = maps[i]->map.channels};
- for (int c = 0; c < entry.num; c++)
- entry.speaker[c] = find_mp_channel(maps[i]->map.pos[c]);
+ struct mp_chmap entry;
+ mp_chmap_from_alsa(&entry, &maps[i]->map);
if (mp_chmap_is_valid(&entry)) {
MP_VERBOSE(ao, "Got supported channel map: %s (type %s)\n",
@@ -564,9 +572,8 @@ static int init_device(struct ao *ao)
if (snd_pcm_chmap_print(alsa_chmap, sizeof(tmp), tmp) > 0)
MP_VERBOSE(ao, "channel map reported by ALSA: %s\n", tmp);
- struct mp_chmap chmap = {.num = alsa_chmap->channels};
- for (int c = 0; c < chmap.num; c++)
- chmap.speaker[c] = find_mp_channel(alsa_chmap->pos[c]);
+ struct mp_chmap chmap;
+ mp_chmap_from_alsa(&chmap, alsa_chmap);
MP_VERBOSE(ao, "which we understand as: %s\n", mp_chmap_to_str(&chmap));