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" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 AudioBufferList* io_data, | 220 AudioBufferList* io_data, |
221 const AudioTimeStamp* output_time_stamp) { | 221 const AudioTimeStamp* output_time_stamp) { |
222 // Update the playout latency. | 222 // Update the playout latency. |
223 double playout_latency_frames = GetPlayoutLatency(output_time_stamp); | 223 double playout_latency_frames = GetPlayoutLatency(output_time_stamp); |
224 | 224 |
225 AudioBuffer& buffer = io_data->mBuffers[0]; | 225 AudioBuffer& buffer = io_data->mBuffers[0]; |
226 uint8* audio_data = reinterpret_cast<uint8*>(buffer.mData); | 226 uint8* audio_data = reinterpret_cast<uint8*>(buffer.mData); |
227 uint32 hardware_pending_bytes = static_cast<uint32> | 227 uint32 hardware_pending_bytes = static_cast<uint32> |
228 ((playout_latency_frames + 0.5) * format_.mBytesPerFrame); | 228 ((playout_latency_frames + 0.5) * format_.mBytesPerFrame); |
229 uint32 filled = source_->OnMoreData( | 229 uint32 filled = source_->OnMoreData( |
230 this, audio_data, buffer.mDataByteSize, | 230 audio_data, buffer.mDataByteSize, |
231 AudioBuffersState(0, hardware_pending_bytes)); | 231 AudioBuffersState(0, hardware_pending_bytes)); |
232 | 232 |
233 // Handle channel order for 5.1 audio. | 233 // Handle channel order for 5.1 audio. |
234 if (format_.mChannelsPerFrame == 6) { | 234 if (format_.mChannelsPerFrame == 6) { |
235 if (format_.mBitsPerChannel == 8) { | 235 if (format_.mBitsPerChannel == 8) { |
236 SwizzleCoreAudioLayout5_1(reinterpret_cast<uint8*>(audio_data), filled); | 236 SwizzleCoreAudioLayout5_1(reinterpret_cast<uint8*>(audio_data), filled); |
237 } else if (format_.mBitsPerChannel == 16) { | 237 } else if (format_.mBitsPerChannel == 16) { |
238 SwizzleCoreAudioLayout5_1(reinterpret_cast<int16*>(audio_data), filled); | 238 SwizzleCoreAudioLayout5_1(reinterpret_cast<int16*>(audio_data), filled); |
239 } else if (format_.mBitsPerChannel == 32) { | 239 } else if (format_.mBitsPerChannel == 32) { |
240 SwizzleCoreAudioLayout5_1(reinterpret_cast<int32*>(audio_data), filled); | 240 SwizzleCoreAudioLayout5_1(reinterpret_cast<int32*>(audio_data), filled); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 UInt64 output_time_ns = AudioConvertHostTimeToNanos( | 347 UInt64 output_time_ns = AudioConvertHostTimeToNanos( |
348 output_time_stamp->mHostTime); | 348 output_time_stamp->mHostTime); |
349 UInt64 now_ns = AudioConvertHostTimeToNanos(AudioGetCurrentHostTime()); | 349 UInt64 now_ns = AudioConvertHostTimeToNanos(AudioGetCurrentHostTime()); |
350 double delay_frames = static_cast<double> | 350 double delay_frames = static_cast<double> |
351 (1e-9 * (output_time_ns - now_ns) * format_.mSampleRate); | 351 (1e-9 * (output_time_ns - now_ns) * format_.mSampleRate); |
352 | 352 |
353 return (delay_frames + hardware_latency_frames_); | 353 return (delay_frames + hardware_latency_frames_); |
354 } | 354 } |
355 | 355 |
356 } // namespace media | 356 } // namespace media |
OLD | NEW |