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_input_mac.h" | 5 #include "media/audio/mac/audio_low_latency_input_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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 208 } |
209 | 209 |
210 // The hardware latency is fixed and will not change during the call. | 210 // The hardware latency is fixed and will not change during the call. |
211 hardware_latency_frames_ = GetHardwareLatency(); | 211 hardware_latency_frames_ = GetHardwareLatency(); |
212 | 212 |
213 return true; | 213 return true; |
214 } | 214 } |
215 | 215 |
216 void AUAudioInputStream::Start(AudioInputCallback* callback) { | 216 void AUAudioInputStream::Start(AudioInputCallback* callback) { |
217 DCHECK(callback); | 217 DCHECK(callback); |
218 if (started_) | 218 DLOG_IF(ERROR, !audio_unit_) << "Open() has not been called successfully"; |
| 219 if (started_ || !audio_unit_) |
219 return; | 220 return; |
220 sink_ = callback; | 221 sink_ = callback; |
221 OSStatus result = AudioOutputUnitStart(audio_unit_); | 222 OSStatus result = AudioOutputUnitStart(audio_unit_); |
222 if (result == noErr) { | 223 if (result == noErr) { |
223 started_ = true; | 224 started_ = true; |
224 } | 225 } |
225 DLOG_IF(ERROR, result != noErr) << "Failed to start acquiring data"; | 226 DLOG_IF(ERROR, result != noErr) << "Failed to start acquiring data"; |
226 } | 227 } |
227 | 228 |
228 void AUAudioInputStream::Stop() { | 229 void AUAudioInputStream::Stop() { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 // Total latency is composed by the dynamic latency and the fixed | 433 // Total latency is composed by the dynamic latency and the fixed |
433 // hardware latency. | 434 // hardware latency. |
434 return (delay_frames + hardware_latency_frames_); | 435 return (delay_frames + hardware_latency_frames_); |
435 } | 436 } |
436 | 437 |
437 void AUAudioInputStream::HandleError(OSStatus err) { | 438 void AUAudioInputStream::HandleError(OSStatus err) { |
438 NOTREACHED() << "error code: " << err; | 439 NOTREACHED() << "error code: " << err; |
439 if (sink_) | 440 if (sink_) |
440 sink_->OnError(this, static_cast<int>(err)); | 441 sink_->OnError(this, static_cast<int>(err)); |
441 } | 442 } |
OLD | NEW |