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

Unified Diff: content/browser/renderer_host/media/audio_input_renderer_host.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 volume updating on Mac Created 8 years, 9 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
Index: content/browser/renderer_host/media/audio_input_renderer_host.cc
diff --git a/content/browser/renderer_host/media/audio_input_renderer_host.cc b/content/browser/renderer_host/media/audio_input_renderer_host.cc
index 149d4b8b12fd64f9a3f6913d8f75ed91a9567f27..8828b42d4ce31667dca1dc7ed62d8d417d78cc24 100644
--- a/content/browser/renderer_host/media/audio_input_renderer_host.cc
+++ b/content/browser/renderer_host/media/audio_input_renderer_host.cc
@@ -176,6 +176,8 @@ bool AudioInputRendererHost::OnMessageReceived(const IPC::Message& message,
IPC_MESSAGE_HANDLER(AudioInputHostMsg_CloseStream, OnCloseStream)
IPC_MESSAGE_HANDLER(AudioInputHostMsg_GetVolume, OnGetVolume)
IPC_MESSAGE_HANDLER(AudioInputHostMsg_SetVolume, OnSetVolume)
+ IPC_MESSAGE_HANDLER(AudioInputHostMsg_SetAutomaticGainControl,
+ OnSetAutomaticGainControl)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX()
@@ -200,7 +202,8 @@ void AudioInputRendererHost::OnStartDevice(int stream_id, int session_id) {
void AudioInputRendererHost::OnCreateStream(int stream_id,
const AudioParameters& params,
- const std::string& device_id) {
+ const std::string& device_id,
+ bool automatic_gain_control) {
VLOG(1) << "AudioInputRendererHost::OnCreateStream(stream_id="
<< stream_id << ")";
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
@@ -214,9 +217,11 @@ void AudioInputRendererHost::OnCreateStream(int stream_id,
// Create a new AudioEntry structure.
scoped_ptr<AudioEntry> entry(new AudioEntry());
+ uint32 mem_size = AudioInputBuffer::kSizeOfStructMinusArr + packet_size;
tommi (sloooow) - chröme 2012/03/16 13:31:05 nit: change kSizeOfStructMinusArr -> kSizeOfStruct
henrika (OOO until Aug 14) 2012/03/21 10:16:04 Done.
+
// Create the shared memory and share it with the renderer process
// using a new SyncWriter object.
- if (!entry->shared_memory.CreateAndMapAnonymous(packet_size)) {
+ if (!entry->shared_memory.CreateAndMapAnonymous(mem_size)) {
// If creation of shared memory failed then send an error message.
SendErrorMessage(stream_id);
return;
@@ -248,6 +253,9 @@ void AudioInputRendererHost::OnCreateStream(int stream_id,
return;
}
+ // Set the initial AGC state for the audio input stream.
+ entry->controller->SetAutomaticGainControl(automatic_gain_control);
+
// If we have created the controller successfully create a entry and add it
// to the map.
entry->stream_id = stream_id;
@@ -290,11 +298,15 @@ void AudioInputRendererHost::OnSetVolume(int stream_id, double volume) {
return;
}
- // TODO(henrika): TBI.
- NOTIMPLEMENTED();
+ entry->controller->SetVolume(volume);
}
void AudioInputRendererHost::OnGetVolume(int stream_id) {
+ NOTIMPLEMENTED();
tommi (sloooow) - chröme 2012/03/16 13:31:05 Do we need to implement this at some point or neve
scherkus (not reviewing) 2012/03/20 13:49:41 AFAIK GetVolume() is completely unused
henrika (OOO until Aug 14) 2012/03/21 10:16:04 Yeah, you are correct. I might as well drop it act
+}
+
+void AudioInputRendererHost::OnSetAutomaticGainControl(int stream_id,
+ bool enabled) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
AudioEntry* entry = LookupById(stream_id);
@@ -303,8 +315,7 @@ void AudioInputRendererHost::OnGetVolume(int stream_id) {
return;
}
- // TODO(henrika): TBI.
- NOTIMPLEMENTED();
+ entry->controller->SetAutomaticGainControl(enabled);
}
void AudioInputRendererHost::SendErrorMessage(int stream_id) {

Powered by Google App Engine
This is Rietveld 408576698