OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/mac/mac_logging.h" | 11 #include "base/mac/mac_logging.h" |
12 #include "media/audio/audio_util.h" | 12 #include "media/audio/audio_util.h" |
13 #include "media/audio/mac/audio_manager_mac.h" | 13 #include "media/audio/mac/audio_manager_mac.h" |
14 | 14 |
15 namespace media { | |
16 | |
17 // Reorder PCM from AAC layout to Core Audio 5.1 layout. | 15 // Reorder PCM from AAC layout to Core Audio 5.1 layout. |
18 // TODO(fbarchard): Switch layout when ffmpeg is updated. | 16 // TODO(fbarchard): Switch layout when ffmpeg is updated. |
19 template<class Format> | 17 template<class Format> |
20 static void SwizzleCoreAudioLayout5_1(Format* b, uint32 filled) { | 18 static void SwizzleCoreAudioLayout5_1(Format* b, uint32 filled) { |
21 static const int kNumSurroundChannels = 6; | 19 static const int kNumSurroundChannels = 6; |
22 Format aac[kNumSurroundChannels]; | 20 Format aac[kNumSurroundChannels]; |
23 for (uint32 i = 0; i < filled; i += sizeof(aac), b += kNumSurroundChannels) { | 21 for (uint32 i = 0; i < filled; i += sizeof(aac), b += kNumSurroundChannels) { |
24 memcpy(aac, b, sizeof(aac)); | 22 memcpy(aac, b, sizeof(aac)); |
25 b[0] = aac[1]; // L | 23 b[0] = aac[1]; // L |
26 b[1] = aac[2]; // R | 24 b[1] = aac[2]; // R |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 // Get the delay between the moment getting the callback and the scheduled | 343 // Get the delay between the moment getting the callback and the scheduled |
346 // time stamp that tells when the data is going to be played out. | 344 // time stamp that tells when the data is going to be played out. |
347 UInt64 output_time_ns = AudioConvertHostTimeToNanos( | 345 UInt64 output_time_ns = AudioConvertHostTimeToNanos( |
348 output_time_stamp->mHostTime); | 346 output_time_stamp->mHostTime); |
349 UInt64 now_ns = AudioConvertHostTimeToNanos(AudioGetCurrentHostTime()); | 347 UInt64 now_ns = AudioConvertHostTimeToNanos(AudioGetCurrentHostTime()); |
350 double delay_frames = static_cast<double> | 348 double delay_frames = static_cast<double> |
351 (1e-9 * (output_time_ns - now_ns) * format_.mSampleRate); | 349 (1e-9 * (output_time_ns - now_ns) * format_.mSampleRate); |
352 | 350 |
353 return (delay_frames + hardware_latency_frames_); | 351 return (delay_frames + hardware_latency_frames_); |
354 } | 352 } |
355 | |
356 } // namespace media | |
OLD | NEW |