| 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/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 &default_output_device_address, | 110 &default_output_device_address, |
| 111 0, | 111 0, |
| 112 0, | 112 0, |
| 113 &size, | 113 &size, |
| 114 &output_device_id_); | 114 &output_device_id_); |
| 115 OSSTATUS_DCHECK(result == noErr, result); | 115 OSSTATUS_DCHECK(result == noErr, result); |
| 116 if (result) | 116 if (result) |
| 117 return false; | 117 return false; |
| 118 | 118 |
| 119 // Open and initialize the DefaultOutputUnit. | 119 // Open and initialize the DefaultOutputUnit. |
| 120 Component comp; | 120 AudioComponent comp; |
| 121 ComponentDescription desc; | 121 AudioComponentDescription desc; |
| 122 | 122 |
| 123 desc.componentType = kAudioUnitType_Output; | 123 desc.componentType = kAudioUnitType_Output; |
| 124 desc.componentSubType = kAudioUnitSubType_DefaultOutput; | 124 desc.componentSubType = kAudioUnitSubType_DefaultOutput; |
| 125 desc.componentManufacturer = kAudioUnitManufacturer_Apple; | 125 desc.componentManufacturer = kAudioUnitManufacturer_Apple; |
| 126 desc.componentFlags = 0; | 126 desc.componentFlags = 0; |
| 127 desc.componentFlagsMask = 0; | 127 desc.componentFlagsMask = 0; |
| 128 comp = FindNextComponent(0, &desc); | 128 comp = AudioComponentFindNext(0, &desc); |
| 129 DCHECK(comp); | 129 DCHECK(comp); |
| 130 | 130 |
| 131 result = OpenAComponent(comp, &output_unit_); | 131 result = AudioComponentInstanceNew(comp, &output_unit_); |
| 132 OSSTATUS_DCHECK(result == noErr, result); | 132 OSSTATUS_DCHECK(result == noErr, result); |
| 133 if (result) | 133 if (result) |
| 134 return false; | 134 return false; |
| 135 | 135 |
| 136 result = AudioUnitInitialize(output_unit_); | 136 result = AudioUnitInitialize(output_unit_); |
| 137 OSSTATUS_DCHECK(result == noErr, result); | 137 OSSTATUS_DCHECK(result == noErr, result); |
| 138 if (result) | 138 if (result) |
| 139 return false; | 139 return false; |
| 140 | 140 |
| 141 hardware_latency_frames_ = GetHardwareLatency(); | 141 hardware_latency_frames_ = GetHardwareLatency(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 sizeof(buffer_size)); | 186 sizeof(buffer_size)); |
| 187 OSSTATUS_DCHECK(result == noErr, result); | 187 OSSTATUS_DCHECK(result == noErr, result); |
| 188 if (result) | 188 if (result) |
| 189 return false; | 189 return false; |
| 190 | 190 |
| 191 return true; | 191 return true; |
| 192 } | 192 } |
| 193 | 193 |
| 194 void AUAudioOutputStream::Close() { | 194 void AUAudioOutputStream::Close() { |
| 195 if (output_unit_) | 195 if (output_unit_) |
| 196 CloseComponent(output_unit_); | 196 AudioComponentInstanceDispose(output_unit_); |
| 197 | 197 |
| 198 // Inform the audio manager that we have been closed. This can cause our | 198 // Inform the audio manager that we have been closed. This can cause our |
| 199 // destruction. | 199 // destruction. |
| 200 manager_->ReleaseOutputStream(this); | 200 manager_->ReleaseOutputStream(this); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void AUAudioOutputStream::Start(AudioSourceCallback* callback) { | 203 void AUAudioOutputStream::Start(AudioSourceCallback* callback) { |
| 204 DCHECK(callback); | 204 DCHECK(callback); |
| 205 DLOG_IF(ERROR, !output_unit_) << "Open() has not been called successfully"; | 205 DLOG_IF(ERROR, !output_unit_) << "Open() has not been called successfully"; |
| 206 if (!output_unit_) | 206 if (!output_unit_) |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 UInt64 output_time_ns = AudioConvertHostTimeToNanos( | 392 UInt64 output_time_ns = AudioConvertHostTimeToNanos( |
| 393 output_time_stamp->mHostTime); | 393 output_time_stamp->mHostTime); |
| 394 UInt64 now_ns = AudioConvertHostTimeToNanos(AudioGetCurrentHostTime()); | 394 UInt64 now_ns = AudioConvertHostTimeToNanos(AudioGetCurrentHostTime()); |
| 395 double delay_frames = static_cast<double> | 395 double delay_frames = static_cast<double> |
| 396 (1e-9 * (output_time_ns - now_ns) * format_.mSampleRate); | 396 (1e-9 * (output_time_ns - now_ns) * format_.mSampleRate); |
| 397 | 397 |
| 398 return (delay_frames + hardware_latency_frames_); | 398 return (delay_frames + hardware_latency_frames_); |
| 399 } | 399 } |
| 400 | 400 |
| 401 } // namespace media | 401 } // namespace media |
| OLD | NEW |