Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1919)

Unified Diff: media/audio/win/audio_low_latency_input_win.h

Issue 9702019: Adds Analog Gain Control (AGC) to the WebRTC client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improved volume updating on Mac Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/audio/win/audio_low_latency_input_win.h
diff --git a/media/audio/win/audio_low_latency_input_win.h b/media/audio/win/audio_low_latency_input_win.h
index d34c025cb30388c4296eb889465a131ddcda60df..587237c46f4b3ca4c60ceb9d3155bc2299918832 100644
--- a/media/audio/win/audio_low_latency_input_win.h
+++ b/media/audio/win/audio_low_latency_input_win.h
@@ -65,10 +65,12 @@
#include <string>
+#include "base/atomicops.h"
#include "base/compiler_specific.h"
#include "base/threading/non_thread_safe.h"
#include "base/threading/platform_thread.h"
#include "base/threading/simple_thread.h"
+#include "base/time.h"
#include "base/win/scoped_co_mem.h"
#include "base/win/scoped_com_initializer.h"
#include "base/win/scoped_comptr.h"
@@ -102,6 +104,8 @@ class MEDIA_EXPORT WASAPIAudioInputStream
virtual double GetMaxVolume() OVERRIDE;
virtual void SetVolume(double volume) OVERRIDE;
virtual double GetVolume() OVERRIDE;
+ virtual void SetAutomaticGainControl(bool enabled) OVERRIDE;
+ virtual bool GetAutomaticGainControl() OVERRIDE;
// Retrieves the sample rate used by the audio engine for its internal
// processing/mixing of shared-mode streams given a specifed device.
@@ -176,6 +180,19 @@ class MEDIA_EXPORT WASAPIAudioInputStream
// Converts from milliseconds to audio frames.
double ms_to_frame_count_;
+ // Keeps track of last time a new volume level was fed to the client in an
+ // OnData() callback.
+ base::Time last_volume_update_time_;
+
+ // Contains last result of internal call to GetVolume(). We save resources
+ // but not querying the capture volume for each callback.
+ double volume_;
+
+ // True when Automatic Gain Control is enabled, false otherwise.
+ // This member is modified on the audio thread and read on the internal
+ // WASAPI capture thread in each capture callback.
+ base::subtle::Atomic32 agc_is_enabled_;
+
// Pointer to the object that will receive the recorded audio samples.
AudioInputCallback* sink_;

Powered by Google App Engine
This is Rietveld 408576698