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" |
11 #include "media/base/user_input_monitor.h" | 11 #include "media/base/user_input_monitor.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 const int kMaxInputChannels = 2; | 14 const int kMaxInputChannels = 2; |
15 | 15 |
16 // TODO(henrika): remove usage of timers and add support for proper | 16 // TODO(henrika): remove usage of timers and add support for proper |
17 // notification of when the input device is removed. This was originally added | 17 // notification of when the input device is removed. This was originally added |
18 // to resolve http://crbug.com/79936 for Windows platforms. This then caused | 18 // to resolve http://crbug.com/79936 for Windows platforms. This then caused |
19 // breakage (very hard to repro bugs!) on other platforms: See | 19 // breakage (very hard to repro bugs!) on other platforms: See |
20 // http://crbug.com/226327 and http://crbug.com/230972. | 20 // http://crbug.com/226327 and http://crbug.com/230972. |
| 21 // See also that the timer has been disabled on Mac now due to |
| 22 // crbug.com/357501. |
21 const int kTimerResetIntervalSeconds = 1; | 23 const int kTimerResetIntervalSeconds = 1; |
22 // We have received reports that the timer can be too trigger happy on some | 24 // We have received reports that the timer can be too trigger happy on some |
23 // Mac devices and the initial timer interval has therefore been increased | 25 // Mac devices and the initial timer interval has therefore been increased |
24 // from 1 second to 5 seconds. | 26 // from 1 second to 5 seconds. |
25 const int kTimerInitialIntervalSeconds = 5; | 27 const int kTimerInitialIntervalSeconds = 5; |
26 } | 28 } |
27 | 29 |
28 namespace media { | 30 namespace media { |
29 | 31 |
30 // static | 32 // static |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 } | 194 } |
193 | 195 |
194 if (stream_ && !stream_->Open()) { | 196 if (stream_ && !stream_->Open()) { |
195 stream_->Close(); | 197 stream_->Close(); |
196 stream_ = NULL; | 198 stream_ = NULL; |
197 handler_->OnError(this, STREAM_OPEN_ERROR); | 199 handler_->OnError(this, STREAM_OPEN_ERROR); |
198 return; | 200 return; |
199 } | 201 } |
200 | 202 |
201 DCHECK(!no_data_timer_.get()); | 203 DCHECK(!no_data_timer_.get()); |
| 204 |
| 205 #if defined(OS_MACOSX) |
| 206 // This is a fix for crbug.com/357501. The timer can trigger when closing |
| 207 // the lid on Macs, which causes more problems than the timer fixes. |
| 208 enable_nodata_timer = false; |
| 209 #endif |
| 210 |
202 if (enable_nodata_timer) { | 211 if (enable_nodata_timer) { |
203 // Create the data timer which will call DoCheckForNoData(). The timer | 212 // Create the data timer which will call DoCheckForNoData(). The timer |
204 // is started in DoRecord() and restarted in each DoCheckForNoData() | 213 // is started in DoRecord() and restarted in each DoCheckForNoData() |
205 // callback. | 214 // callback. |
206 no_data_timer_.reset(new base::Timer( | 215 no_data_timer_.reset(new base::Timer( |
207 FROM_HERE, base::TimeDelta::FromSeconds(kTimerInitialIntervalSeconds), | 216 FROM_HERE, base::TimeDelta::FromSeconds(kTimerInitialIntervalSeconds), |
208 base::Bind(&AudioInputController::DoCheckForNoData, | 217 base::Bind(&AudioInputController::DoCheckForNoData, |
209 base::Unretained(this)), false)); | 218 base::Unretained(this)), false)); |
210 } else { | 219 } else { |
211 DVLOG(1) << "Disabled: timer check for no data."; | 220 DVLOG(1) << "Disabled: timer check for no data."; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 393 |
385 void AudioInputController::SetDataIsActive(bool enabled) { | 394 void AudioInputController::SetDataIsActive(bool enabled) { |
386 base::subtle::Release_Store(&data_is_active_, enabled); | 395 base::subtle::Release_Store(&data_is_active_, enabled); |
387 } | 396 } |
388 | 397 |
389 bool AudioInputController::GetDataIsActive() { | 398 bool AudioInputController::GetDataIsActive() { |
390 return (base::subtle::Acquire_Load(&data_is_active_) != false); | 399 return (base::subtle::Acquire_Load(&data_is_active_) != false); |
391 } | 400 } |
392 | 401 |
393 } // namespace media | 402 } // namespace media |
OLD | NEW |