| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/audio/mac/audio_low_latency_output_mac.h" | 5 #include "media/audio/mac/audio_low_latency_output_mac.h" |
| 6 | 6 |
| 7 #include <CoreServices/CoreServices.h> | 7 #include <CoreServices/CoreServices.h> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "media/audio/audio_util.h" | 11 #include "media/audio/audio_util.h" |
| 12 #include "media/audio/mac/audio_manager_mac.h" | 12 #include "media/audio/mac/audio_manager_mac.h" |
| 13 | 13 |
| 14 using media::SwizzleCoreAudioLayout5_1; | 14 // Reorder PCM from AAC layout to Core Audio 5.1 layout. |
| 15 // TODO(fbarchard): Switch layout when ffmpeg is updated. |
| 16 template<class Format> |
| 17 static void SwizzleCoreAudioLayout5_1(Format* b, uint32 filled) { |
| 18 static const int kNumSurroundChannels = 6; |
| 19 Format aac[kNumSurroundChannels]; |
| 20 for (uint32 i = 0; i < filled; i += sizeof(aac), b += kNumSurroundChannels) { |
| 21 memcpy(aac, b, sizeof(aac)); |
| 22 b[0] = aac[1]; // L |
| 23 b[1] = aac[2]; // R |
| 24 b[2] = aac[0]; // C |
| 25 b[3] = aac[5]; // LFE |
| 26 b[4] = aac[3]; // Ls |
| 27 b[5] = aac[4]; // Rs |
| 28 } |
| 29 } |
| 15 | 30 |
| 16 // Overview of operation: | 31 // Overview of operation: |
| 17 // 1) An object of AUAudioOutputStream is created by the AudioManager | 32 // 1) An object of AUAudioOutputStream is created by the AudioManager |
| 18 // factory: audio_man->MakeAudioStream(). | 33 // factory: audio_man->MakeAudioStream(). |
| 19 // 2) Next some thread will call Open(), at that point the underlying | 34 // 2) Next some thread will call Open(), at that point the underlying |
| 20 // default output Audio Unit is created and configured. | 35 // default output Audio Unit is created and configured. |
| 21 // 3) Then some thread will call Start(source). | 36 // 3) Then some thread will call Start(source). |
| 22 // Then the Audio Unit is started which creates its own thread which | 37 // Then the Audio Unit is started which creates its own thread which |
| 23 // periodically will call the source for more data as buffers are being | 38 // periodically will call the source for more data as buffers are being |
| 24 // consumed. | 39 // consumed. |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 0, | 254 0, |
| 240 0, | 255 0, |
| 241 &info_size, | 256 &info_size, |
| 242 &nominal_sample_rate); | 257 &nominal_sample_rate); |
| 243 DCHECK_EQ(result, 0); | 258 DCHECK_EQ(result, 0); |
| 244 if (result) | 259 if (result) |
| 245 return 0.0; // error | 260 return 0.0; // error |
| 246 | 261 |
| 247 return nominal_sample_rate; | 262 return nominal_sample_rate; |
| 248 } | 263 } |
| OLD | NEW |