From 6910cdaae18a9b97527ca0978a9b33a3e52866b1 Mon Sep 17 00:00:00 2001 From: reimar Date: Mon, 11 Jan 2010 19:23:18 +0000 Subject: Add and use AF_FORMAT_IS_AC3 macro. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30276 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libao2/ao_alsa.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'libao2/ao_alsa.c') diff --git a/libao2/ao_alsa.c b/libao2/ao_alsa.c index 70cd92198b..c156404ab7 100644 --- a/libao2/ao_alsa.c +++ b/libao2/ao_alsa.c @@ -127,7 +127,7 @@ static int control(int cmd, void *arg) long get_vol, set_vol; float f_multi; - if(ao_data.format == AF_FORMAT_AC3) + if(AF_FORMAT_IS_AC3(ao_data.format)) return CONTROL_TRUE; if(mixer_channel) { @@ -427,7 +427,7 @@ static int init(int rate_hz, int channels, int format, int flags) * while opening the abstract alias for the spdif subdevice * 'iec958' */ - if (format == AF_FORMAT_AC3) { + if (AF_FORMAT_IS_AC3(format)) { device.str = "iec958"; mp_msg(MSGT_AO,MSGL_V,"alsa-spdif-init: playing AC3, %i channels\n", channels); } @@ -486,12 +486,13 @@ static int init(int rate_hz, int channels, int format, int flags) } if (!alsa_handler) { + int isac3 = AF_FORMAT_IS_AC3(format); //modes = 0, SND_PCM_NONBLOCK, SND_PCM_ASYNC - if ((err = try_open_device(alsa_device, open_mode, format == AF_FORMAT_AC3)) < 0) + if ((err = try_open_device(alsa_device, open_mode, isac3)) < 0) { if (err != -EBUSY && ao_noblock) { mp_msg(MSGT_AO,MSGL_INFO,MSGTR_AO_ALSA_OpenInNonblockModeFailed); - if ((err = try_open_device(alsa_device, 0, format == AF_FORMAT_AC3)) < 0) { + if ((err = try_open_device(alsa_device, 0, isac3)) < 0) { mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_PlaybackOpenError, snd_strerror(err)); return 0; } -- cgit v1.2.3 From e3c9e9a09b45ad660800d107265e0518df8d8ee9 Mon Sep 17 00:00:00 2001 From: reimar Date: Mon, 11 Jan 2010 19:40:58 +0000 Subject: Use af_fmt2bits, it should give more sensible values than snd_pcm_format_physical_width, especially for AC3. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30279 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libao2/ao_alsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libao2/ao_alsa.c') diff --git a/libao2/ao_alsa.c b/libao2/ao_alsa.c index c156404ab7..0734da46f1 100644 --- a/libao2/ao_alsa.c +++ b/libao2/ao_alsa.c @@ -574,7 +574,7 @@ static int init(int rate_hz, int channels, int format, int flags) return 0; } - bytes_per_sample = snd_pcm_format_physical_width(alsa_format) / 8; + bytes_per_sample = af_fmt2bits(ao_data.format) / 8; bytes_per_sample *= ao_data.channels; ao_data.bps = ao_data.samplerate * bytes_per_sample; -- cgit v1.2.3 From 33bc71f10d0218a99128b6a786357f8c60ba821e Mon Sep 17 00:00:00 2001 From: reimar Date: Mon, 11 Jan 2010 20:27:52 +0000 Subject: Add support for distinguishing between little- and big-endian SPDIF AC3 and converting between both. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30283 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libao2/ao_alsa.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'libao2/ao_alsa.c') diff --git a/libao2/ao_alsa.c b/libao2/ao_alsa.c index 0734da46f1..ac9bb3b115 100644 --- a/libao2/ao_alsa.c +++ b/libao2/ao_alsa.c @@ -364,15 +364,11 @@ static int init(int rate_hz, int channels, int format, int flags) case AF_FORMAT_U16_BE: alsa_format = SND_PCM_FORMAT_U16_BE; break; -#if !HAVE_BIGENDIAN - case AF_FORMAT_AC3: -#endif + case AF_FORMAT_AC3_LE: case AF_FORMAT_S16_LE: alsa_format = SND_PCM_FORMAT_S16_LE; break; -#if HAVE_BIGENDIAN - case AF_FORMAT_AC3: -#endif + case AF_FORMAT_AC3_BE: case AF_FORMAT_S16_BE: alsa_format = SND_PCM_FORMAT_S16_BE; break; @@ -535,6 +531,9 @@ static int init(int rate_hz, int channels, int format, int flags) mp_msg(MSGT_AO,MSGL_INFO, MSGTR_AO_ALSA_FormatNotSupportedByHardware, af_fmt2str_short(format)); alsa_format = SND_PCM_FORMAT_S16_LE; + if (AF_FORMAT_IS_AC3(ao_data.format)) + ao_data.format = AF_FORMAT_AC3_LE; + else ao_data.format = AF_FORMAT_S16_LE; } -- cgit v1.2.3