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

Unified Diff: media/audio/mac/audio_low_latency_input_mac.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/mac/audio_low_latency_input_mac.h
diff --git a/media/audio/mac/audio_low_latency_input_mac.h b/media/audio/mac/audio_low_latency_input_mac.h
index baea80160e7ee18ac94f6c1c317c5d0702167df4..cab1b6d9f9fda747d8e1936471f593948a68fc72 100644
--- a/media/audio/mac/audio_low_latency_input_mac.h
+++ b/media/audio/mac/audio_low_latency_input_mac.h
@@ -38,8 +38,10 @@
#include <AudioUnit/AudioUnit.h>
+#include "base/atomicops.h"
#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
+#include "base/time.h"
#include "media/audio/audio_io.h"
#include "media/audio/audio_parameters.h"
@@ -64,6 +66,8 @@ class AUAudioInputStream : public AudioInputStream {
virtual double GetMaxVolume() OVERRIDE;
virtual void SetVolume(double volume) OVERRIDE;
virtual double GetVolume() OVERRIDE;
+ virtual void SetAutomaticGainControl(bool enabled) OVERRIDE;
+ virtual bool GetAutomaticGainControl() OVERRIDE;
// Returns the current hardware sample rate for the default input device.
static double HardwareSampleRate();
@@ -140,6 +144,19 @@ class AUAudioInputStream : public AudioInputStream {
// when querying the volume of each channel.
int number_of_channels_in_frame_;
+ // 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
+ // by not quering 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
+ // Audio Unit thread in each capture callback.
+ base::subtle::Atomic32 agc_is_enabled_;
scherkus (not reviewing) 2012/03/21 09:21:21 please avoid using base::subtle -- it's intended t
henrika (OOO until Aug 14) 2012/03/21 10:16:04 Good idea. I'll come back with a new version and w
+
DISALLOW_COPY_AND_ASSIGN(AUAudioInputStream);
};

Powered by Google App Engine
This is Rietveld 408576698