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

Side by Side Diff: media/audio/audio_input_controller.h

Issue 314713002: Modifies AudioInputCallback::OnData and use media::AudioBus instead of plain byte vector (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 | Annotate | Revision Log
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 #ifndef MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_
6 #define MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ 6 #define MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_
7 7
8 #include <string> 8 #include <string>
9 #include "base/atomicops.h" 9 #include "base/atomicops.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 class SyncWriter { 131 class SyncWriter {
132 public: 132 public:
133 virtual ~SyncWriter() {} 133 virtual ~SyncWriter() {}
134 134
135 // Notify the synchronous writer about the number of bytes in the 135 // Notify the synchronous writer about the number of bytes in the
136 // soundcard which has been recorded. 136 // soundcard which has been recorded.
137 virtual void UpdateRecordedBytes(uint32 bytes) = 0; 137 virtual void UpdateRecordedBytes(uint32 bytes) = 0;
138 138
139 // Write certain amount of data from |data|. This method returns 139 // Write certain amount of data from |data|. This method returns
140 // number of written bytes. 140 // number of written bytes.
141 virtual uint32 Write(const void* data, 141 virtual uint32 Write(const AudioBus* data,
142 uint32 size,
143 double volume, 142 double volume,
144 bool key_pressed) = 0; 143 bool key_pressed) = 0;
145 144
146 // Close this synchronous writer. 145 // Close this synchronous writer.
147 virtual void Close() = 0; 146 virtual void Close() = 0;
148 }; 147 };
149 148
150 // AudioInputController::Create() can use the currently registered Factory 149 // AudioInputController::Create() can use the currently registered Factory
151 // to create the AudioInputController. Factory is intended for testing only. 150 // to create the AudioInputController. Factory is intended for testing only.
152 // |user_input_monitor| is used for typing detection and can be NULL. 151 // |user_input_monitor| is used for typing detection and can be NULL.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 // Sets the capture volume of the input stream. The value 0.0 corresponds 222 // Sets the capture volume of the input stream. The value 0.0 corresponds
224 // to muted and 1.0 to maximum volume. 223 // to muted and 1.0 to maximum volume.
225 virtual void SetVolume(double volume); 224 virtual void SetVolume(double volume);
226 225
227 // Sets the Automatic Gain Control (AGC) state of the input stream. 226 // Sets the Automatic Gain Control (AGC) state of the input stream.
228 // Changing the AGC state is not supported while recording is active. 227 // Changing the AGC state is not supported while recording is active.
229 virtual void SetAutomaticGainControl(bool enabled); 228 virtual void SetAutomaticGainControl(bool enabled);
230 229
231 // AudioInputCallback implementation. Threading details depends on the 230 // AudioInputCallback implementation. Threading details depends on the
232 // device-specific implementation. 231 // device-specific implementation.
233 virtual void OnData(AudioInputStream* stream, const uint8* src, uint32 size, 232 virtual void OnData(AudioInputStream* stream,
234 uint32 hardware_delay_bytes, double volume) OVERRIDE; 233 const AudioBus* source,
234 uint32 hardware_delay_bytes,
235 double volume) OVERRIDE;
235 virtual void OnError(AudioInputStream* stream) OVERRIDE; 236 virtual void OnError(AudioInputStream* stream) OVERRIDE;
236 237
237 bool SharedMemoryAndSyncSocketMode() const { return sync_writer_ != NULL; } 238 bool SharedMemoryAndSyncSocketMode() const { return sync_writer_ != NULL; }
238 239
239 protected: 240 protected:
240 friend class base::RefCountedThreadSafe<AudioInputController>; 241 friend class base::RefCountedThreadSafe<AudioInputController>;
241 242
242 // Internal state of the source. 243 // Internal state of the source.
243 enum State { 244 enum State {
244 CREATED, 245 CREATED,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 319
319 double max_volume_; 320 double max_volume_;
320 321
321 UserInputMonitor* user_input_monitor_; 322 UserInputMonitor* user_input_monitor_;
322 323
323 #if defined(AUDIO_POWER_MONITORING) 324 #if defined(AUDIO_POWER_MONITORING)
324 // Scans audio samples from OnData() as input to compute audio levels. 325 // Scans audio samples from OnData() as input to compute audio levels.
325 scoped_ptr<AudioPowerMonitor> audio_level_; 326 scoped_ptr<AudioPowerMonitor> audio_level_;
326 327
327 // We need these to be able to feed data to the AudioPowerMonitor. 328 // We need these to be able to feed data to the AudioPowerMonitor.
328 scoped_ptr<AudioBus> audio_bus_;
329 media::AudioParameters audio_params_; 329 media::AudioParameters audio_params_;
330 base::TimeTicks last_audio_level_log_time_; 330 base::TimeTicks last_audio_level_log_time_;
331 #endif 331 #endif
332 332
333 size_t prev_key_down_count_; 333 size_t prev_key_down_count_;
334 334
335 DISALLOW_COPY_AND_ASSIGN(AudioInputController); 335 DISALLOW_COPY_AND_ASSIGN(AudioInputController);
336 }; 336 };
337 337
338 } // namespace media 338 } // namespace media
339 339
340 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ 340 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698