From ecc6e379b24dd5e37b864ae599a154880a2bd2d0 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 9 May 2013 18:06:26 +0200 Subject: audio/out: channel map selection Make all AOs use what has been introduced in the previous commit. Note that even AOs which can handle all possible layouts (like ao_null) use the new functions. This might be important if in the future ao_select_champ() possibly honors global user options about downmixing and so on. --- audio/out/ao_pulse.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'audio/out/ao_pulse.c') diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c index 9422fa319d..15a2b8b0a1 100644 --- a/audio/out/ao_pulse.c +++ b/audio/out/ao_pulse.c @@ -187,6 +187,15 @@ static bool chmap_pa_from_mp(pa_channel_map *dst, struct mp_chmap *src) return true; } +static bool select_chmap(struct ao *ao, pa_channel_map *dst) +{ + struct mp_chmap_sel sel = {0}; + for (int n = 0; speaker_map[n][1] != -1; n++) + mp_chmap_sel_add_speaker(&sel, speaker_map[n][1]); + return ao_chmap_sel_adjust(ao, &sel, &ao->channels) && + chmap_pa_from_mp(dst, &ao->channels); +} + static void uninit(struct ao *ao, bool cut_audio) { struct priv *priv = ao->priv; @@ -301,16 +310,8 @@ static int init(struct ao *ao, char *params) goto fail; } - if (!chmap_pa_from_mp(&map, &ao->channels)) { - char *name = mp_chmap_to_str(&ao->channels); - mp_msg(MSGT_AO, MSGL_ERR, "AO: [pulse] Can't map %s channel layout\n", - name); - talloc_free(name); - // Not a really good fallback, since this doesn't trigger if the - // channel map is valid, but unsupported by the output device. - ao->channels = (struct mp_chmap) MP_CHMAP_INIT_STEREO; - pa_channel_map_init_stereo(&map); - } + if (!select_chmap(ao, &map)) + goto fail; ao->bps = pa_bytes_per_second(&ss); -- cgit v1.2.3