summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-07-03 19:02:58 +0200
committerwm4 <wm4@nowhere>2015-07-03 19:28:00 +0200
commitae3e151b27cdaf561f5cce1f86814501da7401ad (patch)
treea1be321347f347132dc5353b362c0f8ab191ee31
parentd4ab91f016ef03d460920eb10f2fa52788aa6a3c (diff)
downloadmpv-ae3e151b27cdaf561f5cce1f86814501da7401ad.tar.bz2
mpv-ae3e151b27cdaf561f5cce1f86814501da7401ad.tar.xz
ao_coreaudio_utils: fix format back-mapping
Mapping of spdif formats was imperfect. Since the first format on the list is somehow AAC, it was returned first, which is confusing, because CoreAudio calls all spdif formats AC3. Since the spdif formats have some rather arbitrary, reverse mapping the formats didn"t actually work either. Fix by explicitly ignoring these when spdif is used. Also, don't forget to set the samplerate in ca_asbd_to_mpformat(), or it will work only in some cases.
-rw-r--r--audio/out/ao_coreaudio_utils.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/audio/out/ao_coreaudio_utils.c b/audio/out/ao_coreaudio_utils.c
index c94cd73483..742dc2d5ff 100644
--- a/audio/out/ao_coreaudio_utils.c
+++ b/audio/out/ao_coreaudio_utils.c
@@ -222,14 +222,16 @@ bool ca_asbd_equals(const AudioStreamBasicDescription *a,
const AudioStreamBasicDescription *b)
{
int flags = kAudioFormatFlagIsPacked | kAudioFormatFlagIsFloat |
- kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsBigEndian;
+ kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsBigEndian;
+ bool spdif = ca_formatid_is_compressed(a->mFormatID) &&
+ ca_formatid_is_compressed(b->mFormatID);
return (a->mFormatFlags & flags) == (b->mFormatFlags & flags) &&
a->mBitsPerChannel == b->mBitsPerChannel &&
ca_normalize_formatid(a->mFormatID) ==
ca_normalize_formatid(b->mFormatID) &&
- a->mBytesPerPacket == b->mBytesPerPacket &&
- a->mChannelsPerFrame == b->mChannelsPerFrame &&
+ (spdif || a->mBytesPerPacket == b->mBytesPerPacket) &&
+ (spdif || a->mChannelsPerFrame == b->mChannelsPerFrame) &&
a->mSampleRate == b->mSampleRate;
}
@@ -238,9 +240,9 @@ int ca_asbd_to_mp_format(const AudioStreamBasicDescription *asbd)
{
for (int fmt = 1; fmt < AF_FORMAT_COUNT; fmt++) {
AudioStreamBasicDescription mp_asbd = {0};
- ca_fill_asbd_raw(&mp_asbd, fmt, 0, asbd->mChannelsPerFrame);
+ ca_fill_asbd_raw(&mp_asbd, fmt, asbd->mSampleRate, asbd->mChannelsPerFrame);
if (ca_asbd_equals(&mp_asbd, asbd))
- return fmt;
+ return af_fmt_is_spdif(fmt) ? AF_FORMAT_S_AC3 : fmt;
}
return 0;
}