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

Side by Side Diff: media/audio/win/audio_low_latency_input_win.h

Issue 155863003: Add basic support for "googDucking" to getUserMedia on Windows. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Initialize enumeration flag in constructor Created 6 years, 10 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/audio_parameters.h ('k') | media/audio/win/audio_low_latency_input_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Implementation of AudioInputStream for Windows using Windows Core Audio 5 // Implementation of AudioInputStream for Windows using Windows Core Audio
6 // WASAPI for low latency capturing. 6 // WASAPI for low latency capturing.
7 // 7 //
8 // Overview of operation: 8 // Overview of operation:
9 // 9 //
10 // - An object of WASAPIAudioInputStream is created by the AudioManager 10 // - An object of WASAPIAudioInputStream is created by the AudioManager
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 class MEDIA_EXPORT WASAPIAudioInputStream 81 class MEDIA_EXPORT WASAPIAudioInputStream
82 : public AgcAudioStream<AudioInputStream>, 82 : public AgcAudioStream<AudioInputStream>,
83 public base::DelegateSimpleThread::Delegate, 83 public base::DelegateSimpleThread::Delegate,
84 NON_EXPORTED_BASE(public base::NonThreadSafe) { 84 NON_EXPORTED_BASE(public base::NonThreadSafe) {
85 public: 85 public:
86 // The ctor takes all the usual parameters, plus |manager| which is the 86 // The ctor takes all the usual parameters, plus |manager| which is the
87 // the audio manager who is creating this object. 87 // the audio manager who is creating this object.
88 WASAPIAudioInputStream(AudioManagerWin* manager, 88 WASAPIAudioInputStream(AudioManagerWin* manager,
89 const AudioParameters& params, 89 const AudioParameters& params,
90 const std::string& device_id); 90 const std::string& device_id);
91
91 // The dtor is typically called by the AudioManager only and it is usually 92 // The dtor is typically called by the AudioManager only and it is usually
92 // triggered by calling AudioInputStream::Close(). 93 // triggered by calling AudioInputStream::Close().
93 virtual ~WASAPIAudioInputStream(); 94 virtual ~WASAPIAudioInputStream();
94 95
95 // Implementation of AudioInputStream. 96 // Implementation of AudioInputStream.
96 virtual bool Open() OVERRIDE; 97 virtual bool Open() OVERRIDE;
97 virtual void Start(AudioInputCallback* callback) OVERRIDE; 98 virtual void Start(AudioInputCallback* callback) OVERRIDE;
98 virtual void Stop() OVERRIDE; 99 virtual void Stop() OVERRIDE;
99 virtual void Close() OVERRIDE; 100 virtual void Close() OVERRIDE;
100 virtual double GetMaxVolume() OVERRIDE; 101 virtual double GetMaxVolume() OVERRIDE;
101 virtual void SetVolume(double volume) OVERRIDE; 102 virtual void SetVolume(double volume) OVERRIDE;
102 virtual double GetVolume() OVERRIDE; 103 virtual double GetVolume() OVERRIDE;
103 104
104 // Retrieves the sample rate used by the audio engine for its internal 105 bool started() const { return started_; }
105 // processing/mixing of shared-mode streams given a specifed device.
106 static int HardwareSampleRate(const std::string& device_id);
107 106
108 // Retrieves the number of audio channels used by the audio engine for its 107 // Returns the default hardware audio parameters of the specific device.
109 // internal processing/mixing of shared-mode streams given a specified device. 108 static AudioParameters GetInputStreamParameters(const std::string& device_id);
110 static uint32 HardwareChannelCount(const std::string& device_id);
111
112 bool started() const { return started_; }
113 109
114 private: 110 private:
115 // DelegateSimpleThread::Delegate implementation. 111 // DelegateSimpleThread::Delegate implementation.
116 virtual void Run() OVERRIDE; 112 virtual void Run() OVERRIDE;
117 113
118 // Issues the OnError() callback to the |sink_|. 114 // Issues the OnError() callback to the |sink_|.
119 void HandleError(HRESULT err); 115 void HandleError(HRESULT err);
120 116
121 // The Open() method is divided into these sub methods. 117 // The Open() method is divided into these sub methods.
122 HRESULT SetCaptureDevice(); 118 HRESULT SetCaptureDevice();
(...skipping 27 matching lines...) Expand all
150 // is defined as the block of data which the user received in each 146 // is defined as the block of data which the user received in each
151 // OnData() callback. 147 // OnData() callback.
152 size_t packet_size_frames_; 148 size_t packet_size_frames_;
153 149
154 // Size in bytes of each audio packet. 150 // Size in bytes of each audio packet.
155 size_t packet_size_bytes_; 151 size_t packet_size_bytes_;
156 152
157 // Length of the audio endpoint buffer. 153 // Length of the audio endpoint buffer.
158 uint32 endpoint_buffer_size_frames_; 154 uint32 endpoint_buffer_size_frames_;
159 155
156 // A copy of the supplied AudioParameter's |effects|.
157 const int effects_;
158
160 // Contains the unique name of the selected endpoint device. 159 // Contains the unique name of the selected endpoint device.
161 // Note that AudioManagerBase::kDefaultDeviceId represents the default 160 // Note that AudioManagerBase::kDefaultDeviceId represents the default
162 // device role and is not a valid ID as such. 161 // device role and is not a valid ID as such.
163 std::string device_id_; 162 std::string device_id_;
164 163
165 // Conversion factor used in delay-estimation calculations. 164 // Conversion factor used in delay-estimation calculations.
166 // Converts a raw performance counter value to 100-nanosecond unit. 165 // Converts a raw performance counter value to 100-nanosecond unit.
167 double perf_count_to_100ns_units_; 166 double perf_count_to_100ns_units_;
168 167
169 // Conversion factor used in delay-estimation calculations. 168 // Conversion factor used in delay-estimation calculations.
170 // Converts from milliseconds to audio frames. 169 // Converts from milliseconds to audio frames.
171 double ms_to_frame_count_; 170 double ms_to_frame_count_;
172 171
173 // Pointer to the object that will receive the recorded audio samples. 172 // Pointer to the object that will receive the recorded audio samples.
174 AudioInputCallback* sink_; 173 AudioInputCallback* sink_;
175 174
176 // Windows Multimedia Device (MMDevice) API interfaces. 175 // Windows Multimedia Device (MMDevice) API interfaces.
177 176
178 // An IMMDevice interface which represents an audio endpoint device. 177 // An IMMDevice interface which represents an audio endpoint device.
179 base::win::ScopedComPtr<IMMDevice> endpoint_device_; 178 base::win::ScopedComPtr<IMMDevice> endpoint_device_;
180 179
181 // Windows Audio Session API (WASAP) interfaces. 180 // Windows Audio Session API (WASAPI) interfaces.
182 181
183 // An IAudioClient interface which enables a client to create and initialize 182 // An IAudioClient interface which enables a client to create and initialize
184 // an audio stream between an audio application and the audio engine. 183 // an audio stream between an audio application and the audio engine.
185 base::win::ScopedComPtr<IAudioClient> audio_client_; 184 base::win::ScopedComPtr<IAudioClient> audio_client_;
186 185
187 // Loopback IAudioClient doesn't support event-driven mode, so a separate 186 // Loopback IAudioClient doesn't support event-driven mode, so a separate
188 // IAudioClient is needed to receive notifications when data is available in 187 // IAudioClient is needed to receive notifications when data is available in
189 // the buffer. For loopback input |audio_client_| is used to receive data, 188 // the buffer. For loopback input |audio_client_| is used to receive data,
190 // while |audio_render_client_for_loopback_| is used to get notifications 189 // while |audio_render_client_for_loopback_| is used to get notifications
191 // when a new buffer is ready. See comment in InitializeAudioEngine() for 190 // when a new buffer is ready. See comment in InitializeAudioEngine() for
(...skipping 16 matching lines...) Expand all
208 207
209 // This event will be signaled when capturing shall stop. 208 // This event will be signaled when capturing shall stop.
210 base::win::ScopedHandle stop_capture_event_; 209 base::win::ScopedHandle stop_capture_event_;
211 210
212 DISALLOW_COPY_AND_ASSIGN(WASAPIAudioInputStream); 211 DISALLOW_COPY_AND_ASSIGN(WASAPIAudioInputStream);
213 }; 212 };
214 213
215 } // namespace media 214 } // namespace media
216 215
217 #endif // MEDIA_AUDIO_WIN_AUDIO_LOW_LATENCY_INPUT_WIN_H_ 216 #endif // MEDIA_AUDIO_WIN_AUDIO_LOW_LATENCY_INPUT_WIN_H_
OLDNEW
« no previous file with comments | « media/audio/audio_parameters.h ('k') | media/audio/win/audio_low_latency_input_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698