summaryrefslogtreecommitdiffstats
path: root/media/audio
diff options
context:
space:
mode:
authorfbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-08 23:48:17 +0000
committerfbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-08 23:48:17 +0000
commit009fe988b55d165f0796f83ac21005a8e6cffbeb (patch)
tree5a5939c00944999e82b6cae21ecea2837346b0fb /media/audio
parent47b2b1415bedfcbac4406f750d59ba3918dc50d4 (diff)
downloadchromium_src-009fe988b55d165f0796f83ac21005a8e6cffbeb.zip
chromium_src-009fe988b55d165f0796f83ac21005a8e6cffbeb.tar.gz
chromium_src-009fe988b55d165f0796f83ac21005a8e6cffbeb.tar.bz2
Support 8 and 32 bit formats for Mac Channel Swizzler.
Review URL: http://codereview.chromium.org/261028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28484 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio')
-rw-r--r--media/audio/mac/audio_output_mac.cc20
1 files changed, 13 insertions, 7 deletions
diff --git a/media/audio/mac/audio_output_mac.cc b/media/audio/mac/audio_output_mac.cc
index 21131b8..a51d35e 100644
--- a/media/audio/mac/audio_output_mac.cc
+++ b/media/audio/mac/audio_output_mac.cc
@@ -169,10 +169,11 @@ void PCMQueueOutAudioOutputStream::GetVolume(double* left_level,
// Reorder PCM from AAC layout to Core Audio layout.
// TODO(fbarchard): Switch layout when ffmpeg is updated.
-// TODO(fbarchard): Add 8 and 32 bit versions of this function.
-static void PCM16LayoutSwizzle(int16 *b, size_t filled) {
- int16 aac[6];
- for (size_t i = 0; i < filled; i += 12, b += 6) {
+const int kNumSurroundChannels = 6;
+template<class Format>
+static void SwizzleLayout(Format *b, size_t filled) {
+ Format aac[kNumSurroundChannels];
+ for (size_t i = 0; i < filled; i += sizeof(aac), b += kNumSurroundChannels) {
memcpy(aac, b, sizeof(aac));
b[0] = aac[1]; // L
b[1] = aac[2]; // R
@@ -218,9 +219,14 @@ void PCMQueueOutAudioOutputStream::RenderCallback(void* p_this,
}
// Handle channel order for PCM 5.1 audio.
- if (audio_stream->format_.mChannelsPerFrame == 6 &&
- audio_stream->format_.mBitsPerChannel == 16) {
- PCM16LayoutSwizzle(reinterpret_cast<int16*>(buffer->mAudioData), filled);
+ if (audio_stream->format_.mChannelsPerFrame == 6) {
+ if (audio_stream->format_.mBitsPerChannel == 8)
+ SwizzleLayout(reinterpret_cast<uint8*>(buffer->mAudioData), filled);
+ } else if (audio_stream->format_.mBitsPerChannel == 16) {
+ SwizzleLayout(reinterpret_cast<int16*>(buffer->mAudioData), filled);
+ } else if (audio_stream->format_.mBitsPerChannel == 32) {
+ SwizzleLayout(reinterpret_cast<int32*>(buffer->mAudioData), filled);
+ }
}
buffer->mAudioDataByteSize = filled;