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/audio_input_controller.h" | 5 #include "media/audio/audio_input_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/threading/thread_restrictions.h" | 8 #include "base/threading/thread_restrictions.h" |
9 #include "media/base/limits.h" | 9 #include "media/base/limits.h" |
10 #include "media/base/scoped_histogram_timer.h" | 10 #include "media/base/scoped_histogram_timer.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 | 195 |
196 if (stream_ && !stream_->Open()) { | 196 if (stream_ && !stream_->Open()) { |
197 stream_->Close(); | 197 stream_->Close(); |
198 stream_ = NULL; | 198 stream_ = NULL; |
199 handler_->OnError(this, STREAM_OPEN_ERROR); | 199 handler_->OnError(this, STREAM_OPEN_ERROR); |
200 return; | 200 return; |
201 } | 201 } |
202 | 202 |
203 DCHECK(!no_data_timer_.get()); | 203 DCHECK(!no_data_timer_.get()); |
204 | 204 |
205 // This is a fix for crbug.com/357501. The timer can trigger when closing | 205 // The timer is enabled for logging purposes. The NO_DATA_ERROR triggered |
DaleCurtis
2014/04/09 22:16:11
Instead of this, all streams should be paused when
jiayl
2014/04/09 22:24:57
That's reasonable but beyond the scope of this cha
DaleCurtis
2014/04/09 22:34:18
Agreed, but I don't think you should enable the no
jiayl
2014/04/09 22:43:24
Yeah, I should have explained it.
We have to enabl
no longer working on chromium
2014/04/10 09:55:02
I also believe hooking up ShouldDeferStreamStart t
no longer working on chromium
2014/04/10 09:55:02
I hope the current code will just be temporary to
| |
206 // the lid on Macs, which causes more problems than the timer fixes. | 206 // from the timer must be ignored by the EventHandler. |
207 // Also, in crbug.com/357569, the goal is to remove usage of this timer | |
208 // since it was added to solve a crash on Windows that no longer can be | |
209 // reproduced. | |
210 // TODO(henrika): remove usage of timer when it has been verified on Canary | 207 // TODO(henrika): remove usage of timer when it has been verified on Canary |
211 // that we are safe doing so. Goal is to get rid of |no_data_timer_| and | 208 // that we are safe doing so. Goal is to get rid of |no_data_timer_| and |
212 // everything that is tied to it. | 209 // everything that is tied to it. crbug.com/357569. |
213 enable_nodata_timer = false; | 210 enable_nodata_timer = true; |
214 | 211 |
215 if (enable_nodata_timer) { | 212 if (enable_nodata_timer) { |
216 // Create the data timer which will call DoCheckForNoData(). The timer | 213 // Create the data timer which will call DoCheckForNoData(). The timer |
217 // is started in DoRecord() and restarted in each DoCheckForNoData() | 214 // is started in DoRecord() and restarted in each DoCheckForNoData() |
218 // callback. | 215 // callback. |
219 no_data_timer_.reset(new base::Timer( | 216 no_data_timer_.reset(new base::Timer( |
220 FROM_HERE, base::TimeDelta::FromSeconds(kTimerInitialIntervalSeconds), | 217 FROM_HERE, base::TimeDelta::FromSeconds(kTimerInitialIntervalSeconds), |
221 base::Bind(&AudioInputController::DoCheckForNoData, | 218 base::Bind(&AudioInputController::DoCheckForNoData, |
222 base::Unretained(this)), false)); | 219 base::Unretained(this)), false)); |
223 } else { | 220 } else { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 stream_->SetAutomaticGainControl(enabled); | 313 stream_->SetAutomaticGainControl(enabled); |
317 } | 314 } |
318 | 315 |
319 void AudioInputController::DoCheckForNoData() { | 316 void AudioInputController::DoCheckForNoData() { |
320 DCHECK(task_runner_->BelongsToCurrentThread()); | 317 DCHECK(task_runner_->BelongsToCurrentThread()); |
321 | 318 |
322 if (!GetDataIsActive()) { | 319 if (!GetDataIsActive()) { |
323 // The data-is-active marker will be false only if it has been more than | 320 // The data-is-active marker will be false only if it has been more than |
324 // one second since a data packet was recorded. This can happen if a | 321 // one second since a data packet was recorded. This can happen if a |
325 // capture device has been removed or disabled. | 322 // capture device has been removed or disabled. |
326 handler_->OnError(this, NO_DATA_ERROR); | 323 handler_->OnError(this, NO_DATA_ERROR); |
no longer working on chromium
2014/04/10 09:55:02
Tommi, on the output side, Dale added a Media.Audi
| |
327 return; | |
328 } | 324 } |
329 | 325 |
330 // Mark data as non-active. The flag will be re-enabled in OnData() each | 326 // Mark data as non-active. The flag will be re-enabled in OnData() each |
331 // time a data packet is received. Hence, under normal conditions, the | 327 // time a data packet is received. Hence, under normal conditions, the |
332 // flag will only be disabled during a very short period. | 328 // flag will only be disabled during a very short period. |
333 SetDataIsActive(false); | 329 SetDataIsActive(false); |
334 | 330 |
335 // Restart the timer to ensure that we check the flag again in | 331 // Restart the timer to ensure that we check the flag again in |
336 // |kTimerResetIntervalSeconds|. | 332 // |kTimerResetIntervalSeconds|. |
337 no_data_timer_->Start( | 333 no_data_timer_->Start( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
397 | 393 |
398 void AudioInputController::SetDataIsActive(bool enabled) { | 394 void AudioInputController::SetDataIsActive(bool enabled) { |
399 base::subtle::Release_Store(&data_is_active_, enabled); | 395 base::subtle::Release_Store(&data_is_active_, enabled); |
400 } | 396 } |
401 | 397 |
402 bool AudioInputController::GetDataIsActive() { | 398 bool AudioInputController::GetDataIsActive() { |
403 return (base::subtle::Acquire_Load(&data_is_active_) != false); | 399 return (base::subtle::Acquire_Load(&data_is_active_) != false); |
404 } | 400 } |
405 | 401 |
406 } // namespace media | 402 } // namespace media |
OLD | NEW |