From 6147bcce359358855ad02d8d5cbd6575d39b0449 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 26 Jun 2015 23:06:37 +0200 Subject: audio: fix format function consistency issues Replace all the check macros with function calls. Give them all the same case and naming schema. Drop af_fmt2bits(). Only af_fmt2bps() survives as af_fmt_to_bytes(). Introduce af_fmt_is_pcm(), and use it in situations that used !AF_FORMAT_IS_SPECIAL. Nobody really knew what a "special" format was. It simply meant "not PCM". --- audio/out/ao_alsa.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'audio/out/ao_alsa.c') diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index fddc637e53..d81df23f9d 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -101,7 +101,7 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg) long get_vol, set_vol; float f_multi; - if (AF_FORMAT_IS_SPECIAL(ao->format)) + if (!af_fmt_is_pcm(ao->format)) return CONTROL_FALSE; snd_mixer_selem_id_alloca(&sid); @@ -376,7 +376,7 @@ static int try_open_device(struct ao *ao, const char *device) struct priv *p = ao->priv; int err; - if (AF_FORMAT_IS_IEC61937(ao->format)) { + if (af_fmt_is_spdif(ao->format)) { void *tmp = talloc_new(NULL); char *params = talloc_asprintf(tmp, "AES0=%d,AES1=%d,AES2=0,AES3=%d", @@ -453,7 +453,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_FORMAT_IS_IEC61937(ao->format)) { + if (af_fmt_is_spdif(ao->format)) { if (ao->format == AF_FORMAT_S_MP3) { p->alsa_fmt = SND_PCM_FORMAT_MPEG; } else { @@ -469,7 +469,7 @@ static int init_device(struct ao *ao, bool second_try) err = snd_pcm_hw_params_test_format(p->alsa, alsa_hwparams, p->alsa_fmt); if (err < 0) { - if (AF_FORMAT_IS_IEC61937(ao->format)) + if (af_fmt_is_spdif(ao->format)) CHECK_ALSA_ERROR("Unable to set IEC61937 format"); MP_INFO(ao, "Format %s is not supported by hardware, trying default.\n", af_fmt_to_str(ao->format)); @@ -480,11 +480,11 @@ static int init_device(struct ao *ao, bool second_try) err = snd_pcm_hw_params_set_format(p->alsa, alsa_hwparams, p->alsa_fmt); CHECK_ALSA_ERROR("Unable to set format"); - snd_pcm_access_t access = AF_FORMAT_IS_PLANAR(ao->format) + snd_pcm_access_t access = af_fmt_is_planar(ao->format) ? SND_PCM_ACCESS_RW_NONINTERLEAVED : SND_PCM_ACCESS_RW_INTERLEAVED; err = snd_pcm_hw_params_set_access(p->alsa, alsa_hwparams, access); - if (err < 0 && AF_FORMAT_IS_PLANAR(ao->format)) { + if (err < 0 && af_fmt_is_planar(ao->format)) { ao->format = af_fmt_from_planar(ao->format); access = SND_PCM_ACCESS_RW_INTERLEAVED; err = snd_pcm_hw_params_set_access(p->alsa, alsa_hwparams, access); @@ -492,7 +492,7 @@ static int init_device(struct ao *ao, bool second_try) CHECK_ALSA_ERROR("Unable to set access type"); struct mp_chmap dev_chmap = ao->channels; - if (AF_FORMAT_IS_IEC61937(ao->format) || p->cfg_ignore_chmap) { + if (af_fmt_is_spdif(ao->format) || p->cfg_ignore_chmap) { dev_chmap.num = 0; // disable chmap API } else if (dev_chmap.num == 1 && dev_chmap.speaker[0] == MP_SPEAKER_ID_FC) { // As yet another ALSA API inconsistency, mono is not reported correctly. @@ -597,7 +597,7 @@ static int init_device(struct ao *ao, bool second_try) if (p->cfg_ignore_chmap) { MP_VERBOSE(ao, "user set ignore-chmap; ignoring the channel map.\n"); - } else if (AF_FORMAT_IS_IEC61937(ao->format)) { + } else if (af_fmt_is_spdif(ao->format)) { MP_VERBOSE(ao, "using spdif passthrough; ignoring the channel map.\n"); } else if (mp_chmap_is_valid(&chmap)) { // Is it one that contains NA channels? @@ -849,7 +849,7 @@ static int play(struct ao *ao, void **data, int samples, int flags) return 0; do { - if (AF_FORMAT_IS_PLANAR(ao->format)) { + if (af_fmt_is_planar(ao->format)) { res = snd_pcm_writen(p->alsa, data, samples); } else { res = snd_pcm_writei(p->alsa, data[0], samples); -- cgit v1.2.3