Chromium Code Reviews| Index: media/audio/mac/audio_low_latency_input_mac.cc |
| diff --git a/media/audio/mac/audio_low_latency_input_mac.cc b/media/audio/mac/audio_low_latency_input_mac.cc |
| index 15640a57ca94816cdef601122bef988982cf6150..e7e4f78e0e16911e703e6355d7ce6ced6e3424fe 100644 |
| --- a/media/audio/mac/audio_low_latency_input_mac.cc |
| +++ b/media/audio/mac/audio_low_latency_input_mac.cc |
| @@ -36,9 +36,9 @@ const int kMaxErrorTimeoutInSeconds = 1; |
| // stream back to life. |
| const int kCheckInputIsAliveTimeInSeconds = 5; |
| -// Number of restart indications required to actually trigger a restart |
| -// attempt. |
| -const int kNumberOfIndicationsToTriggerRestart = 1; |
| +// Number of restart indications required to trigger a restart after a |
| +// successful start. |
| +const int kIndicationsToTriggerRestartAfterSuccessfulStart = 2; |
| // Max number of times we try to restart a stream when it has been categorized |
| // as dead. Note that we can do many restarts during an audio session and this |
| @@ -1272,18 +1272,21 @@ void AUAudioInputStream::CheckIfInputStreamIsAlive() { |
| } |
| // Restart the audio stream if two conditions are met. First, the number of |
| - // restart indicators must be larger than a threshold, and secondly, only a |
| + // restart indicators must reach a threshold, and secondly, only a |
| // fixed number of restart attempts is allowed. |
| // Note that, the threshold is different depending on if the stream is seen |
| // as dead directly at the first call to Start() (i.e. it has never started) |
| // or if the stream has started OK at least once but then stopped for some |
| // reason (e.g by placing the device in sleep mode). One restart indication |
| // is sufficient for the first case (threshold is zero), while a larger value |
| - // (threshold > 0) is required for the second case to avoid false alarms when |
| + // (threshold > 1) is required for the second case to avoid false alarms when |
| // e.g. resuming from a suspended state. |
| - const size_t restart_threshold = |
| - GetInputCallbackIsActive() ? kNumberOfIndicationsToTriggerRestart : 0; |
| - if (number_of_restart_indications_ > restart_threshold && |
| + const size_t indications_to_trigger_restart = |
| + GetInputCallbackIsActive() |
| + ? kIndicationsToTriggerRestartAfterSuccessfulStart |
| + : 1; |
| + DCHECK_LE(number_of_restart_indications_, indications_to_trigger_restart); |
| + if (number_of_restart_indications_ == indications_to_trigger_restart && |
|
ossu-chromium
2017/05/22 11:27:35
So, this is functionally equivalent but rephrased
Henrik Grunell
2017/05/22 15:04:54
Yes, exactly. I hope you agree it is. :o
|
| number_of_restart_attempts_ < kMaxNumberOfRestartAttempts) { |
| SetInputCallbackIsActive(false); |
| ++total_number_of_restart_attempts_; |