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

Unified Diff: media/audio/audio_input_proxy.h

Issue 285233005: add audio-buffer-size command line flag support to the input audio for all the platforms (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 years, 6 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
« no previous file with comments | « media/audio/android/audio_manager_android.cc ('k') | media/audio/audio_input_proxy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_input_proxy.h
diff --git a/media/audio/audio_input_proxy.h b/media/audio/audio_input_proxy.h
new file mode 100644
index 0000000000000000000000000000000000000000..0fcd128b20376535c05848939c44b679ca408663
--- /dev/null
+++ b/media/audio/audio_input_proxy.h
@@ -0,0 +1,103 @@
+// Copyright 2014 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_PROXY_H_
+#define MEDIA_AUDIO_AUDIO_INPUT_PROXY_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/threading/thread_checker.h"
+#include "media/audio/audio_io.h"
+#include "media/audio/audio_parameters.h"
+
+namespace base {
+class TimeDelta;
+}
+
+namespace media {
+
+class AudioFifo;
+class AudioManagerBase;
+
+// AudioInputProxy is a proxy class between AudioInputStream and
+// AudioInputController. The purpose of this class is to allow AudioManagerBase
+// to restart the input streams when the required stream format has changed.
+class MEDIA_EXPORT AudioInputProxy :
+ public AudioInputStream,
+ public AudioInputStream::AudioInputCallback {
+ public:
+ AudioInputProxy(AudioManagerBase* manager,
+ const AudioParameters& input_params,
+ const AudioParameters& output_params,
+ const std::string& device_id);
+ virtual ~AudioInputProxy();
+
+ void MaybeRestartStream(const AudioParameters& input_params);
+
+ bool is_idle() const { return stream_ != NULL; }
+
+ const AudioParameters& input_parameters() const { return input_params_; }
+
+ const std::string& device_id() const { return device_id_; }
+
+ private:
+ // Used to initialize and reinitialize |dispatcher_|.
+ void Initialize(const AudioParameters& input_params);
+
+ // AudioInputStream interface.
+ virtual bool Open() OVERRIDE;
+ virtual void Start(AudioInputStream::AudioInputCallback* callback) OVERRIDE;
+ virtual void Stop() OVERRIDE;
+ virtual void Close() OVERRIDE;
+ virtual double GetMaxVolume() OVERRIDE;
+ virtual void SetVolume(double volume) OVERRIDE;
+ virtual double GetVolume() OVERRIDE;
+ virtual void SetAutomaticGainControl(bool enabled) OVERRIDE;
+ virtual bool GetAutomaticGainControl() OVERRIDE;
+
+ // AudioInputCallback implementation.
+ virtual void OnData(AudioInputStream* stream,
+ const media::AudioBus* src,
+ uint32 hardware_delay_bytes,
+ double volume) OVERRIDE;
+ virtual void OnError(AudioInputStream* stream) OVERRIDE;
+
+ AudioManagerBase* audio_manager_;
+
+ // Raw pointer to the audio input stream object, which will be deleted by
+ // AudioManagerBase after calling Close().
+ AudioInputStream* stream_;
+
+ // AudioParameters used to setup the input stream.
+ AudioParameters input_params_;
+
+ // AudioParameters used to output the audio data via |callback_|.
+ const AudioParameters output_params_;
+
+ // Device id for the input stream.
+ const std::string device_id_;
+
+ // Raw pointer to the callback which receives audio data.
+ AudioInputStream::AudioInputCallback* callback_;
+
+ // FIFO used as a intermedia buffering when the |input_format_| and
+ // |output_format_| are different.
+ scoped_ptr<media::AudioFifo> fifo_;
+
+ // Used to read data from |fifo_|.
+ scoped_ptr<media::AudioBus> audio_bus_;
+
+ bool opened_;
+ bool agc_enabled_;
+
+ base::ThreadChecker thread_checker_;
+
+ DISALLOW_COPY_AND_ASSIGN(AudioInputProxy);
+};
+
+} // namespace media
+
+#endif // MEDIA_AUDIO_AUDIO_INPUT_PROXY_H_
« no previous file with comments | « media/audio/android/audio_manager_android.cc ('k') | media/audio/audio_input_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698