summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_alsa.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-09-23 21:04:37 +0200
committerwm4 <wm4@nowhere>2014-09-23 23:09:25 +0200
commitb745c2d0050468580aec0a4e12aec854fefd1796 (patch)
tree0df9a9f56b339cabc68376840b4d283b848acdf8 /audio/out/ao_alsa.c
parent5b5a3d0c469fa5e282b60eb9ac2b7e4414640d80 (diff)
downloadmpv-b745c2d0050468580aec0a4e12aec854fefd1796.tar.bz2
mpv-b745c2d0050468580aec0a4e12aec854fefd1796.tar.xz
audio: drop swapped-endian audio formats
Until now, the audio chain could handle both little endian and big endian formats. This actually doesn't make much sense, since the audio API and the HW will most likely prefer native formats. Or at the very least, it should be trivial for audio drivers to do the byte swapping themselves. From now on, the audio chain contains native-endian formats only. All AOs and some filters are adjusted. af_convertsignendian.c is now wrongly named, but the filter name is adjusted. In some cases, the audio infrastructure was reused on the demuxer side, but that is relatively easy to rectify. This is a quite intrusive and radical change. It's possible that it will break some things (especially if they're obscure or not Linux), so watch out for regressions. It's probably still better to do it the bulldozer way, since slow transition and researching foreign platforms would take a lot of time and effort.
Diffstat (limited to 'audio/out/ao_alsa.c')
-rw-r--r--audio/out/ao_alsa.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index 60b8338f9d..c344f6f20e 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -38,6 +38,7 @@
#include "options/options.h"
#include "options/m_option.h"
#include "common/msg.h"
+#include "osdep/endian.h"
#define ALSA_PCM_NEW_HW_PARAMS_API
#define ALSA_PCM_NEW_SW_PARAMS_API
@@ -208,22 +209,17 @@ alsa_error:
static const int mp_to_alsa_format[][2] = {
{AF_FORMAT_S8, SND_PCM_FORMAT_S8},
{AF_FORMAT_U8, SND_PCM_FORMAT_U8},
- {AF_FORMAT_U16_LE, SND_PCM_FORMAT_U16_LE},
- {AF_FORMAT_U16_BE, SND_PCM_FORMAT_U16_BE},
- {AF_FORMAT_S16_LE, SND_PCM_FORMAT_S16_LE},
- {AF_FORMAT_S16_BE, SND_PCM_FORMAT_S16_BE},
- {AF_FORMAT_U32_LE, SND_PCM_FORMAT_U32_LE},
- {AF_FORMAT_U32_BE, SND_PCM_FORMAT_U32_BE},
- {AF_FORMAT_S32_LE, SND_PCM_FORMAT_S32_LE},
- {AF_FORMAT_S32_BE, SND_PCM_FORMAT_S32_BE},
- {AF_FORMAT_U24_LE, SND_PCM_FORMAT_U24_3LE},
- {AF_FORMAT_U24_BE, SND_PCM_FORMAT_U24_3BE},
- {AF_FORMAT_S24_LE, SND_PCM_FORMAT_S24_3LE},
- {AF_FORMAT_S24_BE, SND_PCM_FORMAT_S24_3BE},
- {AF_FORMAT_FLOAT_LE, SND_PCM_FORMAT_FLOAT_LE},
- {AF_FORMAT_FLOAT_BE, SND_PCM_FORMAT_FLOAT_BE},
- {AF_FORMAT_AC3, SND_PCM_FORMAT_S16_LE},
- {AF_FORMAT_IEC61937, SND_PCM_FORMAT_S16_LE},
+ {AF_FORMAT_U16, SND_PCM_FORMAT_U16},
+ {AF_FORMAT_S16, SND_PCM_FORMAT_S16},
+ {AF_FORMAT_U32, SND_PCM_FORMAT_U32},
+ {AF_FORMAT_S32, SND_PCM_FORMAT_S32},
+ {AF_FORMAT_U24,
+ MP_SELECT_LE_BE(SND_PCM_FORMAT_U24_3LE, SND_PCM_FORMAT_U24_3BE)},
+ {AF_FORMAT_S24,
+ MP_SELECT_LE_BE(SND_PCM_FORMAT_S24_3LE, SND_PCM_FORMAT_S24_3BE)},
+ {AF_FORMAT_FLOAT, SND_PCM_FORMAT_FLOAT},
+ {AF_FORMAT_AC3, SND_PCM_FORMAT_S16},
+ {AF_FORMAT_IEC61937, SND_PCM_FORMAT_S16},
{AF_FORMAT_MPEG2, SND_PCM_FORMAT_MPEG},
{AF_FORMAT_UNKNOWN, SND_PCM_FORMAT_UNKNOWN},
};
@@ -417,13 +413,13 @@ static int init(struct ao *ao)
if (err < 0) {
MP_INFO(ao, "Format %s is not supported by hardware, trying default.\n",
af_fmt_to_str(ao->format));
- p->alsa_fmt = SND_PCM_FORMAT_S16_LE;
+ p->alsa_fmt = SND_PCM_FORMAT_S16;
if (AF_FORMAT_IS_AC3(ao->format))
ao->format = AF_FORMAT_AC3;
else if (AF_FORMAT_IS_IEC61937(ao->format))
ao->format = AF_FORMAT_IEC61937;
else
- ao->format = AF_FORMAT_S16_LE;
+ ao->format = AF_FORMAT_S16;
}
err = snd_pcm_hw_params_set_format(p->alsa, alsa_hwparams, p->alsa_fmt);