From 09c61e0a4546d53fd6ca7ec4795591baca3d3ea4 Mon Sep 17 00:00:00 2001 From: Kevin Mitchell Date: Thu, 10 Sep 2015 21:12:56 -0700 Subject: ao_alsa: put spdif formats into find_alsa_format --- audio/out/ao_alsa.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index b32dceb689..4ec1a7b461 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -215,6 +215,14 @@ static const int mp_to_alsa_format[][2] = { static int find_alsa_format(int af_format) { + if (af_fmt_is_spdif(af_format)) { + if (af_format == AF_FORMAT_S_MP3) { + return SND_PCM_FORMAT_MPEG; + } else { + return SND_PCM_FORMAT_S16; + } + } + af_format = af_fmt_from_planar(af_format); for (int n = 0; mp_to_alsa_format[n][0] != AF_FORMAT_UNKNOWN; n++) { if (mp_to_alsa_format[n][0] == af_format) @@ -453,15 +461,7 @@ static int init_device(struct ao *ao, bool second_try) err = snd_pcm_hw_params_any(p->alsa, alsa_hwparams); CHECK_ALSA_ERROR("Unable to get initial parameters"); - if (af_fmt_is_spdif(ao->format)) { - if (ao->format == AF_FORMAT_S_MP3) { - p->alsa_fmt = SND_PCM_FORMAT_MPEG; - } else { - p->alsa_fmt = SND_PCM_FORMAT_S16; - } - } else { - p->alsa_fmt = find_alsa_format(ao->format); - } + p->alsa_fmt = find_alsa_format(ao->format); if (p->alsa_fmt == SND_PCM_FORMAT_UNKNOWN) { p->alsa_fmt = SND_PCM_FORMAT_S16; ao->format = AF_FORMAT_S16; -- cgit v1.2.3