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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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_PROXY_H_
6 #define MEDIA_AUDIO_AUDIO_INPUT_PROXY_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/threading/thread_checker.h"
13 #include "media/audio/audio_io.h"
14 #include "media/audio/audio_parameters.h"
15
16 namespace base {
17 class TimeDelta;
18 }
19
20 namespace media {
21
22 class AudioFifo;
23 class AudioManagerBase;
24
25 // AudioInputProxy is a proxy class between AudioInputStream and
26 // AudioInputController. The purpose of this class is to allow AudioManagerBase
27 // to restart the input streams when the required stream format has changed.
28 class MEDIA_EXPORT AudioInputProxy :
29 public AudioInputStream,
30 public AudioInputStream::AudioInputCallback {
31 public:
32 AudioInputProxy(AudioManagerBase* manager,
33 const AudioParameters& input_params,
34 const AudioParameters& output_params,
35 const std::string& device_id);
36 virtual ~AudioInputProxy();
37
38 void MaybeRestartStream(const AudioParameters& input_params);
39
40 bool is_idle() const { return stream_ != NULL; }
41
42 const AudioParameters& input_parameters() const { return input_params_; }
43
44 const std::string& device_id() const { return device_id_; }
45
46 private:
47 // Used to initialize and reinitialize |dispatcher_|.
48 void Initialize(const AudioParameters& input_params);
49
50 // AudioInputStream interface.
51 virtual bool Open() OVERRIDE;
52 virtual void Start(AudioInputStream::AudioInputCallback* callback) OVERRIDE;
53 virtual void Stop() OVERRIDE;
54 virtual void Close() OVERRIDE;
55 virtual double GetMaxVolume() OVERRIDE;
56 virtual void SetVolume(double volume) OVERRIDE;
57 virtual double GetVolume() OVERRIDE;
58 virtual void SetAutomaticGainControl(bool enabled) OVERRIDE;
59 virtual bool GetAutomaticGainControl() OVERRIDE;
60
61 // AudioInputCallback implementation.
62 virtual void OnData(AudioInputStream* stream,
63 const media::AudioBus* src,
64 uint32 hardware_delay_bytes,
65 double volume) OVERRIDE;
66 virtual void OnError(AudioInputStream* stream) OVERRIDE;
67
68 AudioManagerBase* audio_manager_;
69
70 // Raw pointer to the audio input stream object, which will be deleted by
71 // AudioManagerBase after calling Close().
72 AudioInputStream* stream_;
73
74 // AudioParameters used to setup the input stream.
75 AudioParameters input_params_;
76
77 // AudioParameters used to output the audio data via |callback_|.
78 const AudioParameters output_params_;
79
80 // Device id for the input stream.
81 const std::string device_id_;
82
83 // Raw pointer to the callback which receives audio data.
84 AudioInputStream::AudioInputCallback* callback_;
85
86 // FIFO used as a intermedia buffering when the |input_format_| and
87 // |output_format_| are different.
88 scoped_ptr<media::AudioFifo> fifo_;
89
90 // Used to read data from |fifo_|.
91 scoped_ptr<media::AudioBus> audio_bus_;
92
93 bool opened_;
94 bool agc_enabled_;
95
96 base::ThreadChecker thread_checker_;
97
98 DISALLOW_COPY_AND_ASSIGN(AudioInputProxy);
99 };
100
101 } // namespace media
102
103 #endif // MEDIA_AUDIO_AUDIO_INPUT_PROXY_H_
OLDNEW
« 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