| Index: media/audio/audio_input_stream_impl.h
|
| diff --git a/media/audio/audio_input_stream_impl.h b/media/audio/audio_input_stream_impl.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..0e45a9fdb4a952c6c42d978bddef8d0d7f9fbbec
|
| --- /dev/null
|
| +++ b/media/audio/audio_input_stream_impl.h
|
| @@ -0,0 +1,55 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef MEDIA_AUDIO_AUDIO_INPUT_STREAM_IMPL_H_
|
| +#define MEDIA_AUDIO_AUDIO_INPUT_STREAM_IMPL_H_
|
| +
|
| +#include "base/compiler_specific.h"
|
| +#include "base/synchronization/lock.h"
|
| +#include "base/time.h"
|
| +#include "media/audio/audio_io.h"
|
| +
|
| +// AudioInputStreamImpl implements platform-independent parts of the
|
| +// AudioInputStream interface. Each platform dependent implementation
|
| +// should derive from this class.
|
| +// TODO(henrika): we can probably break out more parts from our current
|
| +// AudioInputStream implementation and move out to this class.
|
| +class MEDIA_EXPORT AudioInputStreamImpl : public AudioInputStream {
|
| + public:
|
| + AudioInputStreamImpl();
|
| + virtual ~AudioInputStreamImpl();
|
| +
|
| + // Sets the automatic gain control (AGC) to on or off. When AGC is enabled,
|
| + // the microphone volume is queried periodically and the volume level is
|
| + // provided in each AudioInputCallback::OnData() callback and fed to the
|
| + // render-side AGC.
|
| + virtual void SetAutomaticGainControl(bool enabled) OVERRIDE;
|
| +
|
| + // Gets the current automatic gain control state.
|
| + virtual bool GetAutomaticGainControl() OVERRIDE;
|
| +
|
| + protected:
|
| + void UpdateAgcVolume();
|
| + void QueryAgcVolume(double* volume);
|
| +
|
| +
|
| + private:
|
| + // True when automatic gain control is enabled, false otherwise.
|
| + // Guarded by |lock_|.
|
| + bool agc_is_enabled_;
|
| +
|
| + // Contains last result of internal call to GetVolume(). We save resources
|
| + // but not querying the capture volume for each callback. Guarded by |lock_|.
|
| + double volume_;
|
| +
|
| + // Protects |agc_is_enabled_| and |volume_| .
|
| + base::Lock lock_;
|
| +
|
| + // Keeps track of the last time the microphone volume level was queried.
|
| + base::Time last_volume_update_time_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(AudioInputStreamImpl);
|
| +};
|
| +
|
| +#endif // MEDIA_AUDIO_AUDIO_INPUT_STREAM_IMPL_H_
|
|
|