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 <inttypes.h> | 7 #include <inttypes.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <limits> | 10 #include <limits> |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 // lower level. AGC can fail on platforms where we don't support the | 352 // lower level. AGC can fail on platforms where we don't support the |
353 // functionality to modify the input volume slider. One such example is | 353 // functionality to modify the input volume slider. One such example is |
354 // Windows XP. | 354 // Windows XP. |
355 power_measurement_is_enabled_ &= agc_is_supported; | 355 power_measurement_is_enabled_ &= agc_is_supported; |
356 #else | 356 #else |
357 stream_to_control->SetAutomaticGainControl(enable_agc); | 357 stream_to_control->SetAutomaticGainControl(enable_agc); |
358 #endif | 358 #endif |
359 | 359 |
360 // Finally, keep the stream pointer around, update the state and notify. | 360 // Finally, keep the stream pointer around, update the state and notify. |
361 stream_ = stream_to_control; | 361 stream_ = stream_to_control; |
362 handler_->OnCreated(this); | |
363 | 362 |
364 // Check the current muted state and start the repeating timer to keep that | 363 // Send initial muted state along with OnCreated, to avoid races. |
365 // updated. | 364 is_muted_ = stream_->IsMuted(); |
366 CheckMutedState(); | 365 handler_->OnCreated(this, is_muted_); |
| 366 |
367 check_muted_state_timer_.Start( | 367 check_muted_state_timer_.Start( |
368 FROM_HERE, base::TimeDelta::FromSeconds(kCheckMutedStateIntervalSeconds), | 368 FROM_HERE, base::TimeDelta::FromSeconds(kCheckMutedStateIntervalSeconds), |
369 this, &AudioInputController::CheckMutedState); | 369 this, &AudioInputController::CheckMutedState); |
370 DCHECK(check_muted_state_timer_.IsRunning()); | 370 DCHECK(check_muted_state_timer_.IsRunning()); |
371 } | 371 } |
372 | 372 |
373 void AudioInputController::DoRecord() { | 373 void AudioInputController::DoRecord() { |
374 DCHECK(task_runner_->BelongsToCurrentThread()); | 374 DCHECK(task_runner_->BelongsToCurrentThread()); |
375 SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioInputController.RecordTime"); | 375 SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioInputController.RecordTime"); |
376 | 376 |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 case AudioParameters::Format::AUDIO_PCM_LOW_LATENCY: | 698 case AudioParameters::Format::AUDIO_PCM_LOW_LATENCY: |
699 return AudioInputController::StreamType::LOW_LATENCY; | 699 return AudioInputController::StreamType::LOW_LATENCY; |
700 default: | 700 default: |
701 // Currently, the remaining supported type is fake. Reconsider if other | 701 // Currently, the remaining supported type is fake. Reconsider if other |
702 // formats become supported. | 702 // formats become supported. |
703 return AudioInputController::StreamType::FAKE; | 703 return AudioInputController::StreamType::FAKE; |
704 } | 704 } |
705 } | 705 } |
706 | 706 |
707 } // namespace media | 707 } // namespace media |
OLD | NEW |