summaryrefslogtreecommitdiffstats
path: root/libao2
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2010-01-25 15:04:07 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-01-25 15:07:30 +0200
commit69fe2522f8c2a04eda112eee6319ca2e85d7038b (patch)
tree83a8b19997e621309344ca1f3997a48886ef0944 /libao2
parent9436e0452fad48e671d7320cb18c588655f3d230 (diff)
parent1cda8b002fb19c3da14760fe1f9fc76992a05c29 (diff)
downloadmpv-69fe2522f8c2a04eda112eee6319ca2e85d7038b.tar.bz2
mpv-69fe2522f8c2a04eda112eee6319ca2e85d7038b.tar.xz
Merge svn changes up to r30301
Diffstat (limited to 'libao2')
-rw-r--r--libao2/ao_alsa.c22
-rw-r--r--libao2/ao_alsa5.c8
-rw-r--r--libao2/ao_coreaudio.c28
-rw-r--r--libao2/ao_dsound.c9
-rw-r--r--libao2/ao_dxr2.c2
-rw-r--r--libao2/ao_mpegpes.c7
-rw-r--r--libao2/ao_oss.c16
-rw-r--r--libao2/ao_pcm.c3
-rw-r--r--libao2/ao_win32.c6
9 files changed, 42 insertions, 59 deletions
diff --git a/libao2/ao_alsa.c b/libao2/ao_alsa.c
index 140b13a62a..92b8b64ea7 100644
--- a/libao2/ao_alsa.c
+++ b/libao2/ao_alsa.c
@@ -128,7 +128,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) {
@@ -374,15 +374,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;
@@ -437,7 +433,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);
}
@@ -496,12 +492,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_tmsg(MSGT_AO,MSGL_INFO,"[AO_ALSA] Open in nonblock-mode failed, trying to open in block-mode.\n");
- if ((err = try_open_device(alsa_device, 0, format == AF_FORMAT_AC3)) < 0) {
+ if ((err = try_open_device(alsa_device, 0, isac3)) < 0) {
mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Playback open error: %s\n", snd_strerror(err));
return 0;
}
@@ -544,6 +541,9 @@ static int init(int rate_hz, int channels, int format, int flags)
mp_tmsg(MSGT_AO,MSGL_INFO,
"[AO_ALSA] Format %s is not supported by hardware, trying default.\n", 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;
}
@@ -583,7 +583,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;
diff --git a/libao2/ao_alsa5.c b/libao2/ao_alsa5.c
index 8843efb68a..ad17f5895f 100644
--- a/libao2/ao_alsa5.c
+++ b/libao2/ao_alsa5.c
@@ -101,15 +101,11 @@ static int init(int rate_hz, int channels, int format, int flags)
case AF_FORMAT_U16_BE:
alsa_format.format = SND_PCM_SFMT_U16_BE;
break;
-#if !HAVE_BIGENDIAN
- case AF_FORMAT_AC3:
-#endif
+ case AF_FORMAT_AC3_LE:
case AF_FORMAT_S16_LE:
alsa_format.format = SND_PCM_SFMT_S16_LE;
break;
-#if HAVE_BIGENDIAN
- case AF_FORMAT_AC3:
-#endif
+ case AF_FORMAT_AC3_BE:
case AF_FORMAT_S16_BE:
alsa_format.format = SND_PCM_SFMT_S16_BE;
break;
diff --git a/libao2/ao_coreaudio.c b/libao2/ao_coreaudio.c
index 130eee8f97..b60fb094e7 100644
--- a/libao2/ao_coreaudio.c
+++ b/libao2/ao_coreaudio.c
@@ -263,7 +263,7 @@ int b_alive;
ao->b_changed_mixing = 0;
/* Probe whether device support S/PDIF stream output if input is AC3 stream. */
- if ((format & AF_FORMAT_SPECIAL_MASK) == AF_FORMAT_AC3)
+ if (AF_FORMAT_IS_AC3(format))
{
/* Find the ID of the default Device. */
i_param_size = sizeof(AudioDeviceID);
@@ -314,23 +314,7 @@ int b_alive;
inDesc.mSampleRate=rate;
inDesc.mFormatID=ao->b_supports_digital ? kAudioFormat60958AC3 : kAudioFormatLinearPCM;
inDesc.mChannelsPerFrame=channels;
- switch(format&AF_FORMAT_BITS_MASK){
- case AF_FORMAT_8BIT:
- inDesc.mBitsPerChannel=8;
- break;
- case AF_FORMAT_16BIT:
- inDesc.mBitsPerChannel=16;
- break;
- case AF_FORMAT_24BIT:
- inDesc.mBitsPerChannel=24;
- break;
- case AF_FORMAT_32BIT:
- inDesc.mBitsPerChannel=32;
- break;
- default:
- ao_msg(MSGT_AO, MSGL_WARN, "Unsupported format (0x%08x)\n", format);
- goto err_out;
- }
+ inDesc.mBitsPerChannel=af_fmt2bits(format);
if((format&AF_FORMAT_POINT_MASK)==AF_FORMAT_F) {
// float
@@ -344,13 +328,7 @@ int b_alive;
// unsigned int
inDesc.mFormatFlags = kAudioFormatFlagIsPacked;
}
- if ((format & AF_FORMAT_SPECIAL_MASK) == AF_FORMAT_AC3) {
- // Currently ac3 input (comes from hwac3) is always in native byte-order.
-#if HAVE_BIGENDIAN
- inDesc.mFormatFlags |= kAudioFormatFlagIsBigEndian;
-#endif
- }
- else if ((format & AF_FORMAT_END_MASK) == AF_FORMAT_BE)
+ if ((format & AF_FORMAT_END_MASK) == AF_FORMAT_BE)
inDesc.mFormatFlags |= kAudioFormatFlagIsBigEndian;
inDesc.mFramesPerPacket = 1;
diff --git a/libao2/ao_dsound.c b/libao2/ao_dsound.c
index f66042a793..c53820638d 100644
--- a/libao2/ao_dsound.c
+++ b/libao2/ao_dsound.c
@@ -327,7 +327,7 @@ static int write_buffer(unsigned char *data, int len)
if (SUCCEEDED(res))
{
- if( (ao_data.channels == 6) && (ao_data.format!=AF_FORMAT_AC3) ) {
+ if( (ao_data.channels == 6) && !AF_FORMAT_IS_AC3(ao_data.format) ) {
// reorder channels while writing to pointers.
// it's this easy because buffer size and len are always
// aligned to multiples of channels*bytespersample
@@ -432,8 +432,11 @@ static int init(int rate, int channels, int format, int flags)
mp_msg(MSGT_AO, MSGL_ERR, "ao_dsound: 8 channel audio not yet supported\n");
return 0;
}
+
+ if (AF_FORMAT_IS_AC3(format))
+ format = AF_FORMAT_AC3_NE;
switch(format){
- case AF_FORMAT_AC3:
+ case AF_FORMAT_AC3_NE:
case AF_FORMAT_S24_LE:
case AF_FORMAT_S16_LE:
case AF_FORMAT_U8:
@@ -456,7 +459,7 @@ static int init(int rate, int channels, int format, int flags)
wformat.Format.cbSize = (channels > 2) ? sizeof(WAVEFORMATEXTENSIBLE)-sizeof(WAVEFORMATEX) : 0;
wformat.Format.nChannels = channels;
wformat.Format.nSamplesPerSec = rate;
- if (format == AF_FORMAT_AC3) {
+ if (AF_FORMAT_IS_AC3(format)) {
wformat.Format.wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF;
wformat.Format.wBitsPerSample = 16;
wformat.Format.nBlockAlign = 4;
diff --git a/libao2/ao_dxr2.c b/libao2/ao_dxr2.c
index 4712f3341f..f9e31836d5 100644
--- a/libao2/ao_dxr2.c
+++ b/libao2/ao_dxr2.c
@@ -201,7 +201,7 @@ static int play(void* data,int len,int flags){
// MPEG and AC3 don't work :-(
if(ao_data.format==AF_FORMAT_MPEG2)
send_mpeg_ps_packet (data, len, 0xC0, ao_data.pts, 2, write_dxr2);
- else if(ao_data.format==AF_FORMAT_AC3)
+ else if(AF_FORMAT_IS_AC3(ao_data.format))
send_mpeg_ps_packet (data, len, 0x80, ao_data.pts, 2, write_dxr2);
else {
int i;
diff --git a/libao2/ao_mpegpes.c b/libao2/ao_mpegpes.c
index 47a75d7545..f6ab1c6aca 100644
--- a/libao2/ao_mpegpes.c
+++ b/libao2/ao_mpegpes.c
@@ -250,9 +250,12 @@ static int init(int rate,int channels,int format,int flags){
switch(format){
case AF_FORMAT_S16_BE:
case AF_FORMAT_MPEG2:
- case AF_FORMAT_AC3:
+ case AF_FORMAT_AC3_BE:
ao_data.format=format;
break;
+ case AF_FORMAT_AC3_LE:
+ ao_data.format=AF_FORMAT_AC3_BE;
+ break;
default:
ao_data.format=AF_FORMAT_S16_BE;
}
@@ -331,8 +334,6 @@ static int play(void* data,int len,int flags){
unsigned short *s=data;
// if(len>2000) len=2000;
// printf("ao_mpegpes: len=%d \n",len);
- if(ao_data.format==AF_FORMAT_AC3)
- for(i=0;i<len/2;i++) s[i]=(s[i]>>8)|(s[i]<<8); // le<->be
send_mpeg_lpcm_packet(data, len, 0xA0, ao_data.pts, freq_id, my_ao_write);
}
return len;
diff --git a/libao2/ao_oss.c b/libao2/ao_oss.c
index 6872b15946..58d3b233cc 100644
--- a/libao2/ao_oss.c
+++ b/libao2/ao_oss.c
@@ -96,7 +96,7 @@ static int format2oss(int format)
case AF_FORMAT_MPEG2: return AFMT_MPEG;
#endif
#ifdef AFMT_AC3
- case AF_FORMAT_AC3: return AFMT_AC3;
+ case AF_FORMAT_AC3_NE: return AFMT_AC3;
#endif
}
mp_msg(MSGT_AO, MSGL_V, "OSS: Unknown/not supported internal format: %s\n", af_fmt2str_short(format));
@@ -139,7 +139,7 @@ static int oss2format(int format)
case AFMT_MPEG: return AF_FORMAT_MPEG2;
#endif
#ifdef AFMT_AC3
- case AFMT_AC3: return AF_FORMAT_AC3;
+ case AFMT_AC3: return AF_FORMAT_AC3_NE;
#endif
}
mp_tmsg(MSGT_GLOBAL,MSGL_ERR,"[AO OSS] Unknown/Unsupported OSS format: %x.\n", format);
@@ -208,7 +208,7 @@ static int control(int cmd,void *arg){
return CONTROL_OK;
#endif
- if(ao_data.format == AF_FORMAT_AC3)
+ if(AF_FORMAT_IS_AC3(ao_data.format))
return CONTROL_TRUE;
if ((fd = open(oss_mixer_device, O_RDONLY)) > 0)
@@ -326,12 +326,14 @@ static int init(int rate,int channels,int format,int flags){
fcntl(audio_fd, F_SETFD, FD_CLOEXEC);
#endif
- if(format == AF_FORMAT_AC3) {
+ if(AF_FORMAT_IS_AC3(format)) {
ao_data.samplerate=rate;
ioctl (audio_fd, SNDCTL_DSP_SPEED, &ao_data.samplerate);
}
ac3_retry:
+ if (AF_FORMAT_IS_AC3(format))
+ format = AF_FORMAT_AC3_NE;
ao_data.format=format;
oss_format=format2oss(format);
if (oss_format == -1) {
@@ -361,7 +363,7 @@ ac3_retry:
af_fmt2str_short(ao_data.format), af_fmt2str_short(format));
ao_data.channels = channels;
- if(format != AF_FORMAT_AC3) {
+ if(!AF_FORMAT_IS_AC3(format)) {
// We only use SNDCTL_DSP_CHANNELS for >2 channels, in case some drivers don't have it
if (ao_data.channels > 2) {
if ( ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &ao_data.channels) == -1 ||
@@ -476,10 +478,10 @@ static void reset(void){
#endif
oss_format = format2oss(ao_data.format);
- if(ao_data.format == AF_FORMAT_AC3)
+ if(AF_FORMAT_IS_AC3(ao_data.format))
ioctl (audio_fd, SNDCTL_DSP_SPEED, &ao_data.samplerate);
ioctl (audio_fd, SNDCTL_DSP_SETFMT, &oss_format);
- if(ao_data.format != AF_FORMAT_AC3) {
+ if(!AF_FORMAT_IS_AC3(ao_data.format)) {
if (ao_data.channels > 2)
ioctl (audio_fd, SNDCTL_DSP_CHANNELS, &ao_data.channels);
else {
diff --git a/libao2/ao_pcm.c b/libao2/ao_pcm.c
index a03f41193e..5c418d0f5a 100644
--- a/libao2/ao_pcm.c
+++ b/libao2/ao_pcm.c
@@ -127,7 +127,8 @@ static int init(int rate,int channels,int format,int flags){
format=AF_FORMAT_U8;
case AF_FORMAT_U8:
break;
- case AF_FORMAT_AC3:
+ case AF_FORMAT_AC3_BE:
+ case AF_FORMAT_AC3_LE:
bits=16;
break;
default:
diff --git a/libao2/ao_win32.c b/libao2/ao_win32.c
index a0475455ec..55ed17b457 100644
--- a/libao2/ao_win32.c
+++ b/libao2/ao_win32.c
@@ -143,8 +143,10 @@ static int init(int rate,int channels,int format,int flags)
unsigned char* buffer;
int i;
+ if (AF_FORMAT_IS_AC3(format))
+ format = AF_FORMAT_AC3_NE;
switch(format){
- case AF_FORMAT_AC3:
+ case AF_FORMAT_AC3_NE:
case AF_FORMAT_S24_LE:
case AF_FORMAT_S16_LE:
case AF_FORMAT_U8:
@@ -180,7 +182,7 @@ static int init(int rate,int channels,int format,int flags)
wformat.Format.cbSize = (channels>2)?sizeof(WAVEFORMATEXTENSIBLE)-sizeof(WAVEFORMATEX):0;
wformat.Format.nChannels = channels;
wformat.Format.nSamplesPerSec = rate;
- if(format == AF_FORMAT_AC3)
+ if(AF_FORMAT_IS_AC3(format))
{
wformat.Format.wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF;
wformat.Format.wBitsPerSample = 16;