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" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 if (output_unit_) | 168 if (output_unit_) |
169 CloseComponent(output_unit_); | 169 CloseComponent(output_unit_); |
170 | 170 |
171 // Inform the audio manager that we have been closed. This can cause our | 171 // Inform the audio manager that we have been closed. This can cause our |
172 // destruction. | 172 // destruction. |
173 manager_->ReleaseOutputStream(this); | 173 manager_->ReleaseOutputStream(this); |
174 } | 174 } |
175 | 175 |
176 void AUAudioOutputStream::Start(AudioSourceCallback* callback) { | 176 void AUAudioOutputStream::Start(AudioSourceCallback* callback) { |
177 DCHECK(callback); | 177 DCHECK(callback); |
| 178 DLOG_IF(ERROR, !output_unit_) << "Open() has not been called successfully"; |
| 179 if (!output_unit_) |
| 180 return; |
| 181 |
178 source_ = callback; | 182 source_ = callback; |
179 | 183 |
180 AudioOutputUnitStart(output_unit_); | 184 AudioOutputUnitStart(output_unit_); |
181 } | 185 } |
182 | 186 |
183 void AUAudioOutputStream::Stop() { | 187 void AUAudioOutputStream::Stop() { |
184 // We request a synchronous stop, so the next call can take some time. In | 188 // We request a synchronous stop, so the next call can take some time. In |
185 // the windows implementation we block here as well. | 189 // the windows implementation we block here as well. |
186 source_ = NULL; | 190 source_ = NULL; |
187 | 191 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 // Get the delay between the moment getting the callback and the scheduled | 366 // Get the delay between the moment getting the callback and the scheduled |
363 // time stamp that tells when the data is going to be played out. | 367 // time stamp that tells when the data is going to be played out. |
364 UInt64 output_time_ns = AudioConvertHostTimeToNanos( | 368 UInt64 output_time_ns = AudioConvertHostTimeToNanos( |
365 output_time_stamp->mHostTime); | 369 output_time_stamp->mHostTime); |
366 UInt64 now_ns = AudioConvertHostTimeToNanos(AudioGetCurrentHostTime()); | 370 UInt64 now_ns = AudioConvertHostTimeToNanos(AudioGetCurrentHostTime()); |
367 double delay_frames = static_cast<double> | 371 double delay_frames = static_cast<double> |
368 (1e-9 * (output_time_ns - now_ns) * format_.mSampleRate); | 372 (1e-9 * (output_time_ns - now_ns) * format_.mSampleRate); |
369 | 373 |
370 return (delay_frames + hardware_latency_frames_); | 374 return (delay_frames + hardware_latency_frames_); |
371 } | 375 } |
OLD | NEW |