Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_AUDIO_AUDIO_INPUT_STREAM_IMPL_H_ | |
| 6 #define MEDIA_AUDIO_AUDIO_INPUT_STREAM_IMPL_H_ | |
| 7 | |
| 8 #include "base/compiler_specific.h" | |
| 9 #include "base/synchronization/lock.h" | |
| 10 #include "base/time.h" | |
| 11 #include "media/audio/audio_io.h" | |
| 12 | |
| 13 // AudioInputStreamImpl implements platform-independent parts of the | |
| 14 // AudioInputStream interface. Each platform dependent implementation | |
| 15 // should derive from this class. | |
| 16 // TODO(henrika): we can probably break out more parts from our current | |
| 17 // AudioInputStream implementation and move out to this class. | |
| 18 class MEDIA_EXPORT AudioInputStreamImpl : public AudioInputStream { | |
| 19 public: | |
| 20 AudioInputStreamImpl(); | |
| 21 virtual ~AudioInputStreamImpl(); | |
| 22 | |
| 23 // Sets the automatic gain control (AGC) to on or off. When AGC is enabled, | |
| 24 // the microphone volume is queried periodically and the volume level is | |
| 25 // provided in each AudioInputCallback::OnData() callback and fed to the | |
| 26 // render-side AGC. | |
| 27 virtual void SetAutomaticGainControl(bool enabled) OVERRIDE; | |
| 28 | |
| 29 // Gets the current automatic gain control state. | |
| 30 virtual bool GetAutomaticGainControl() OVERRIDE; | |
| 31 | |
| 32 protected: | |
| 33 void UpdateAgcVolume(); | |
| 34 void QueryAgcVolume(double* normalized_volume); | |
| 35 | |
| 36 | |
|
tommi (sloooow) - chröme
2012/03/26 15:26:40
one empty line should be enough
henrika (OOO until Aug 14)
2012/03/27 09:20:38
Done.
| |
| 37 private: | |
| 38 // Takes a volume sample and stores it in |normalized_volume_|. | |
| 39 void GetNormalizedVolume(); | |
| 40 | |
| 41 // True when automatic gain control is enabled, false otherwise. | |
| 42 // Guarded by |lock_|. | |
| 43 bool agc_is_enabled_; | |
| 44 | |
| 45 // Stores the maximum volume which is used for normalization to a volume | |
| 46 // range of [0.0, 1.0]. | |
| 47 double max_volume_; | |
| 48 | |
| 49 // Contains last result of internal call to GetVolume(). We save resources | |
| 50 // but not querying the capture volume for each callback. Guarded by |lock_|. | |
| 51 // The range is normalized to [0.0, 1.0]. | |
| 52 double normalized_volume_; | |
| 53 | |
| 54 // Protects |agc_is_enabled_| and |volume_| . | |
| 55 base::Lock lock_; | |
| 56 | |
| 57 // Keeps track of the last time the microphone volume level was queried. | |
| 58 base::Time last_volume_update_time_; | |
| 59 | |
| 60 DISALLOW_COPY_AND_ASSIGN(AudioInputStreamImpl); | |
| 61 }; | |
| 62 | |
| 63 #endif // MEDIA_AUDIO_AUDIO_INPUT_STREAM_IMPL_H_ | |
| OLD | NEW |