diff options
author | henrika <henrika@chromium.org> | 2016-03-02 06:28:25 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-02 14:29:16 +0000 |
commit | 14464a7a3220d80234d05e5226d45484166c59a5 (patch) | |
tree | 0ebb8c973378960da4cae0da4c2cebeac2ec09dd | |
parent | 70f51b280f579b0999c12a710a4b5b268011e69c (diff) | |
download | chromium_src-14464a7a3220d80234d05e5226d45484166c59a5.zip chromium_src-14464a7a3220d80234d05e5226d45484166c59a5.tar.gz chromium_src-14464a7a3220d80234d05e5226d45484166c59a5.tar.bz2 |
Increases defer time for calling Start on Mac input audio streams
BUG=549021
Review URL: https://codereview.chromium.org/1757823002
Cr-Commit-Position: refs/heads/master@{#378743}
-rw-r--r-- | media/audio/mac/audio_low_latency_input_mac.cc | 29 | ||||
-rw-r--r-- | media/audio/mac/audio_manager_mac.cc | 2 |
2 files changed, 23 insertions, 8 deletions
diff --git a/media/audio/mac/audio_low_latency_input_mac.cc b/media/audio/mac/audio_low_latency_input_mac.cc index e9c4899..131ff72 100644 --- a/media/audio/mac/audio_low_latency_input_mac.cc +++ b/media/audio/mac/audio_low_latency_input_mac.cc @@ -32,6 +32,15 @@ const int kMaxErrorTimeoutInSeconds = 1; // if input callbacks have started, and false otherwise. const int kInputCallbackStartTimeoutInSeconds = 5; +// Replaces AudioManagerMac::kStartDelayInSecsForPowerEvents to allow for a +// longer delay when calling Start() in conjunction to a power resume event. +// If it is detected that Start() should be deferred, we wait this amount of +// time before trying Start() again. The default value in AudioManagerMac is +// 2 seconds. +// TODO(henrika): investigate if an increase results in a lower frequency of +// detecting no input callbacks at startup. +const int kStartDelayInSecsForPowerEvents = 4; + // Returns true if the format flags in |format_flags| has the "non-interleaved" // flag (kAudioFormatFlagIsNonInterleaved) cleared (set to 0). static bool FormatIsInterleaved(UInt32 format_flags) { @@ -468,16 +477,15 @@ void AUAudioInputStream::Start(AudioInputCallback* callback) { // Check if we should defer Start() for http://crbug.com/160920. if (manager_->ShouldDeferStreamStart()) { + LOG(WARNING) << "Start of input audio is deferred"; start_was_deferred_ = true; // Use a cancellable closure so that if Stop() is called before Start() // actually runs, we can cancel the pending start. deferred_start_cb_.Reset(base::Bind( &AUAudioInputStream::Start, base::Unretained(this), callback)); manager_->GetTaskRunner()->PostDelayedTask( - FROM_HERE, - deferred_start_cb_.callback(), - base::TimeDelta::FromSeconds( - AudioManagerMac::kStartDelayInSecsForPowerEvents)); + FROM_HERE, deferred_start_cb_.callback(), + base::TimeDelta::FromSeconds(kStartDelayInSecsForPowerEvents)); return; } @@ -545,10 +553,15 @@ void AUAudioInputStream::Close() { CloseAudioUnit(); // Disable the listener for device property changes. DeRegisterDeviceChangeListener(); - // Check if any device property changes are added by filtering out a selected - // set of the |device_property_changes_map_| map. Add UMA stats if valuable - // data is found. - AddDevicePropertyChangesToUMA(false); + // Add more UMA stats but only if AGC was activated, i.e. for e.g. WebRTC + // audio input streams. + if (GetAutomaticGainControl()) { + // Check if any device property changes are added by filtering out a + // selected set of the |device_property_changes_map_| map. Add UMA stats + // if valuable data is found. + AddDevicePropertyChangesToUMA(false); + // TODO(henrika): possibly add more values here... + } // Inform the audio manager that we have been closed. This will cause our // destruction. manager_->ReleaseInputStream(this); diff --git a/media/audio/mac/audio_manager_mac.cc b/media/audio/mac/audio_manager_mac.cc index 2ec4f28..beedf92 100644 --- a/media/audio/mac/audio_manager_mac.cc +++ b/media/audio/mac/audio_manager_mac.cc @@ -342,11 +342,13 @@ class AudioManagerMac::AudioPowerObserver : public base::PowerObserver { private: void OnSuspend() override { DCHECK(thread_checker_.CalledOnValidThread()); + DVLOG(1) << "OnSuspend"; is_suspending_ = true; } void OnResume() override { DCHECK(thread_checker_.CalledOnValidThread()); + DVLOG(1) << "OnResume"; ++num_resume_notifications_; is_suspending_ = false; earliest_start_time_ = base::TimeTicks::Now() + |