Chromium Code Reviews| 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_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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/mac_logging.h" | 10 #include "base/mac/mac_logging.h" |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 579 // Receive audio from the AUHAL from the output scope of the Audio Unit. | 579 // Receive audio from the AUHAL from the output scope of the Audio Unit. |
| 580 OSStatus result = AudioUnitRender(audio_input->audio_unit(), | 580 OSStatus result = AudioUnitRender(audio_input->audio_unit(), |
| 581 flags, | 581 flags, |
| 582 time_stamp, | 582 time_stamp, |
| 583 bus_number, | 583 bus_number, |
| 584 number_of_frames, | 584 number_of_frames, |
| 585 audio_input->audio_buffer_list()); | 585 audio_input->audio_buffer_list()); |
| 586 if (result) { | 586 if (result) { |
| 587 UMA_HISTOGRAM_SPARSE_SLOWLY("Media.AudioInputCbErrorMac", result); | 587 UMA_HISTOGRAM_SPARSE_SLOWLY("Media.AudioInputCbErrorMac", result); |
| 588 OSSTATUS_DLOG(ERROR, result) << "AudioUnitRender() failed "; | 588 OSSTATUS_DLOG(ERROR, result) << "AudioUnitRender() failed "; |
| 589 if (result != kAudioUnitErr_TooManyFramesToProcess) { | 589 if (result == kAudioUnitErr_TooManyFramesToProcess) { |
| 590 audio_input->HandleError(result); | |
| 591 } else { | |
| 592 DCHECK(!audio_input->last_success_time_.is_null()); | 590 DCHECK(!audio_input->last_success_time_.is_null()); |
| 593 // We delay stopping the stream for kAudioUnitErr_TooManyFramesToProcess | 591 // We delay stopping the stream for kAudioUnitErr_TooManyFramesToProcess |
| 594 // since it has been observed that some USB headsets can cause this error | 592 // since it has been observed that some USB headsets can cause this error |
| 595 // but only for a few initial frames at startup and then then the stream | 593 // but only for a few initial frames at startup and then then the stream |
| 596 // returns to a stable state again. See b/19524368 for details. | 594 // returns to a stable state again. See b/19524368 for details. |
| 597 // Instead, we measure time since last valid audio frame and call | 595 // Instead, we measure time since last valid audio frame and call |
| 598 // HandleError() only if a too long error sequence is detected. We do | 596 // HandleError() only if a too long error sequence is detected. We do |
| 599 // this to avoid ending up in a non recoverable bad core audio state. | 597 // this to avoid ending up in a non recoverable bad core audio state. |
| 600 base::TimeDelta time_since_last_success = | 598 base::TimeDelta time_since_last_success = |
| 601 base::TimeTicks::Now() - audio_input->last_success_time_; | 599 base::TimeTicks::Now() - audio_input->last_success_time_; |
| 602 if ((time_since_last_success > | 600 if ((time_since_last_success > |
| 603 base::TimeDelta::FromSeconds(kMaxErrorTimeoutInSeconds))) { | 601 base::TimeDelta::FromSeconds(kMaxErrorTimeoutInSeconds))) { |
| 604 DLOG(ERROR) << "Too long sequence of TooManyFramesToProcess errors!"; | 602 DLOG(ERROR) << "Too long sequence of TooManyFramesToProcess errors!"; |
| 605 audio_input->HandleError(result); | 603 audio_input->HandleError(result); |
| 606 } | 604 } |
| 605 } else if (result == kAudioUnitErr_CannotDoInCurrentContext) { | |
| 606 // Returned when an audio unit is in a state where it can't perform the | |
| 607 // requested action now - but it could later. | |
| 608 // TODO(henrika): figure out why we see this error message. | |
| 609 DLOG(ERROR) << "kAudioUnitErr_CannotDoInCurrentContext"; | |
|
tommi (sloooow) - chröme
2016/01/21 12:36:12
maybe LOG(ERROR) for now? In case this could be u
tommi (sloooow) - chröme
2016/01/21 12:42:42
what about this comment?
henrika (OOO until Aug 14)
2016/01/21 12:44:13
Done. Changed some more to LOG as well. To ensure
henrika (OOO until Aug 14)
2016/01/21 12:53:08
Done.
| |
| 610 } else if (result == kAudioUnitErr_NoConnection) { | |
| 611 // There is no connection (generally an audio unit is asked to render | |
| 612 // but it has not input from which to gather data). | |
| 613 // TODO(henrika): figure out why we see this error message. | |
| 614 DLOG(ERROR) << "kAudioUnitErr_NoConnection"; | |
|
tommi (sloooow) - chröme
2016/01/21 12:36:12
I think we should treat this one like a general ca
tommi (sloooow) - chröme
2016/01/21 12:42:42
LOG(ERROR) could be useful for this error as well
henrika (OOO until Aug 14)
2016/01/21 12:44:13
Done.
henrika (OOO until Aug 14)
2016/01/21 12:53:08
It is covered above by OSSTATUS_DLOG(ERROR, result
| |
| 615 } else { | |
| 616 audio_input->HandleError(result); | |
| 607 } | 617 } |
| 608 return result; | 618 return result; |
| 609 } | 619 } |
| 610 // Update time of successful call to AudioUnitRender(). | 620 // Update time of successful call to AudioUnitRender(). |
| 611 audio_input->last_success_time_ = base::TimeTicks::Now(); | 621 audio_input->last_success_time_ = base::TimeTicks::Now(); |
| 612 | 622 |
| 613 // Deliver recorded data to the consumer as a callback. | 623 // Deliver recorded data to the consumer as a callback. |
| 614 return audio_input->Provide(number_of_frames, | 624 return audio_input->Provide(number_of_frames, |
| 615 audio_input->audio_buffer_list(), | 625 audio_input->audio_buffer_list(), |
| 616 time_stamp); | 626 time_stamp); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 848 manager_->low_latency_input_streams()); | 858 manager_->low_latency_input_streams()); |
| 849 UMA_HISTOGRAM_COUNTS_1000("Media.Audio.NumberOfBasicInputStreamsMac", | 859 UMA_HISTOGRAM_COUNTS_1000("Media.Audio.NumberOfBasicInputStreamsMac", |
| 850 manager_->basic_input_streams()); | 860 manager_->basic_input_streams()); |
| 851 // TODO(henrika): this value will currently always report true. It should be | 861 // TODO(henrika): this value will currently always report true. It should be |
| 852 // fixed when we understand the problem better. | 862 // fixed when we understand the problem better. |
| 853 UMA_HISTOGRAM_BOOLEAN("Media.Audio.AutomaticGainControlMac", | 863 UMA_HISTOGRAM_BOOLEAN("Media.Audio.AutomaticGainControlMac", |
| 854 GetAutomaticGainControl()); | 864 GetAutomaticGainControl()); |
| 855 } | 865 } |
| 856 | 866 |
| 857 } // namespace media | 867 } // namespace media |
| OLD | NEW |