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

Side by Side Diff: media/audio/win/wavein_input_win.cc

Issue 9702019: Adds Analog Gain Control (AGC) to the WebRTC client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improved AGC comments Created 8 years, 8 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 #include "media/audio/win/wavein_input_win.h" 5 #include "media/audio/win/wavein_input_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <mmsystem.h> 8 #include <mmsystem.h>
9 #pragma comment(lib, "winmm.lib") 9 #pragma comment(lib, "winmm.lib")
10 10
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 void PCMWaveInAudioInputStream::SetVolume(double volume) { 195 void PCMWaveInAudioInputStream::SetVolume(double volume) {
196 // TODO(henrika): Add volume support using the Audio Mixer API. 196 // TODO(henrika): Add volume support using the Audio Mixer API.
197 } 197 }
198 198
199 double PCMWaveInAudioInputStream::GetVolume() { 199 double PCMWaveInAudioInputStream::GetVolume() {
200 // TODO(henrika): Add volume support using the Audio Mixer API. 200 // TODO(henrika): Add volume support using the Audio Mixer API.
201 return 0.0; 201 return 0.0;
202 } 202 }
203 203
204 void PCMWaveInAudioInputStream::SetAutomaticGainControl(bool enabled) {
205 // TODO(henrika): Add AGC support when volume control has been added.
206 NOTIMPLEMENTED();
207 }
208
209 bool PCMWaveInAudioInputStream::GetAutomaticGainControl() {
210 // TODO(henrika): Add AGC support when volume control has been added.
211 NOTIMPLEMENTED();
212 return false;
213 }
214
204 void PCMWaveInAudioInputStream::HandleError(MMRESULT error) { 215 void PCMWaveInAudioInputStream::HandleError(MMRESULT error) {
205 DLOG(WARNING) << "PCMWaveInAudio error " << error; 216 DLOG(WARNING) << "PCMWaveInAudio error " << error;
206 callback_->OnError(this, error); 217 callback_->OnError(this, error);
207 } 218 }
208 219
209 void PCMWaveInAudioInputStream::QueueNextPacket(WAVEHDR *buffer) { 220 void PCMWaveInAudioInputStream::QueueNextPacket(WAVEHDR *buffer) {
210 MMRESULT res = ::waveInAddBuffer(wavein_, buffer, sizeof(WAVEHDR)); 221 MMRESULT res = ::waveInAddBuffer(wavein_, buffer, sizeof(WAVEHDR));
211 if (res != MMSYSERR_NOERROR) 222 if (res != MMSYSERR_NOERROR)
212 HandleError(res); 223 HandleError(res);
213 } 224 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 DWORD_PTR instance, 264 DWORD_PTR instance,
254 DWORD_PTR param1, DWORD_PTR) { 265 DWORD_PTR param1, DWORD_PTR) {
255 PCMWaveInAudioInputStream* obj = 266 PCMWaveInAudioInputStream* obj =
256 reinterpret_cast<PCMWaveInAudioInputStream*>(instance); 267 reinterpret_cast<PCMWaveInAudioInputStream*>(instance);
257 268
258 if (msg == WIM_DATA) { 269 if (msg == WIM_DATA) {
259 // WIM_DONE indicates that the driver is done with our buffer. We pass it 270 // WIM_DONE indicates that the driver is done with our buffer. We pass it
260 // to the callback and check if we need to stop playing. 271 // to the callback and check if we need to stop playing.
261 // It should be OK to assume the data in the buffer is what has been 272 // It should be OK to assume the data in the buffer is what has been
262 // recorded in the soundcard. 273 // recorded in the soundcard.
274 // TODO(henrika): comment on volume = 0.0.
tommi (sloooow) - chröme 2012/03/26 15:26:40 ping
henrika (OOO until Aug 14) 2012/03/27 09:20:38 Done.
263 WAVEHDR* buffer = reinterpret_cast<WAVEHDR*>(param1); 275 WAVEHDR* buffer = reinterpret_cast<WAVEHDR*>(param1);
264 obj->callback_->OnData(obj, reinterpret_cast<const uint8*>(buffer->lpData), 276 obj->callback_->OnData(obj, reinterpret_cast<const uint8*>(buffer->lpData),
265 buffer->dwBytesRecorded, 277 buffer->dwBytesRecorded,
266 buffer->dwBytesRecorded); 278 buffer->dwBytesRecorded,
279 0.0);
267 280
268 if (obj->state_ == kStateStopping) { 281 if (obj->state_ == kStateStopping) {
269 // The main thread has called Stop() and is waiting to issue waveOutReset 282 // The main thread has called Stop() and is waiting to issue waveOutReset
270 // which will kill this thread. We should not enter AudioSourceCallback 283 // which will kill this thread. We should not enter AudioSourceCallback
271 // code anymore. 284 // code anymore.
272 ::SetEvent(obj->stopped_event_); 285 ::SetEvent(obj->stopped_event_);
273 } else if (obj->state_ == kStateStopped) { 286 } else if (obj->state_ == kStateStopped) {
274 // Not sure if ever hit this but just in case. 287 // Not sure if ever hit this but just in case.
275 } else { 288 } else {
276 // Queue the finished buffer back with the audio driver. Since we are 289 // Queue the finished buffer back with the audio driver. Since we are
277 // reusing the same buffers we can get away without calling 290 // reusing the same buffers we can get away without calling
278 // waveInPrepareHeader. 291 // waveInPrepareHeader.
279 obj->QueueNextPacket(buffer); 292 obj->QueueNextPacket(buffer);
280 } 293 }
281 } else if (msg == WIM_CLOSE) { 294 } else if (msg == WIM_CLOSE) {
282 // We can be closed before calling Start, so it is possible to have a 295 // We can be closed before calling Start, so it is possible to have a
283 // null callback at this point. 296 // null callback at this point.
284 if (obj->callback_) 297 if (obj->callback_)
285 obj->callback_->OnClose(obj); 298 obj->callback_->OnClose(obj);
286 } 299 }
287 } 300 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698