| OLD | NEW |
| 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 "content/browser/renderer_host/media/audio_input_renderer_host.h" | 5 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/process/process.h" | 10 #include "base/process/process.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 void AudioInputRendererHost::DoSendRecordingMessage( | 169 void AudioInputRendererHost::DoSendRecordingMessage( |
| 170 media::AudioInputController* controller) { | 170 media::AudioInputController* controller) { |
| 171 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 171 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 172 // TODO(henrika): See crbug.com/115262 for details on why this method | 172 // TODO(henrika): See crbug.com/115262 for details on why this method |
| 173 // should be implemented. | 173 // should be implemented. |
| 174 } | 174 } |
| 175 | 175 |
| 176 void AudioInputRendererHost::DoHandleError( | 176 void AudioInputRendererHost::DoHandleError( |
| 177 media::AudioInputController* controller) { | 177 media::AudioInputController* controller) { |
| 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 179 MediaStreamManager::SendMessageToNativeLog( |
| 180 "The AudioInputController signalled an error."); |
| 179 | 181 |
| 180 AudioEntry* entry = LookupByController(controller); | 182 AudioEntry* entry = LookupByController(controller); |
| 181 if (!entry) | 183 if (!entry) |
| 182 return; | 184 return; |
| 183 | 185 |
| 184 audio_log_->OnError(entry->stream_id); | 186 audio_log_->OnError(entry->stream_id); |
| 185 DeleteEntryOnError(entry); | 187 DeleteEntryOnError(entry); |
| 186 } | 188 } |
| 187 | 189 |
| 188 bool AudioInputRendererHost::OnMessageReceived(const IPC::Message& message, | 190 bool AudioInputRendererHost::OnMessageReceived(const IPC::Message& message, |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 // Set the initial AGC state for the audio input stream. Note that, the AGC | 305 // Set the initial AGC state for the audio input stream. Note that, the AGC |
| 304 // is only supported in AUDIO_PCM_LOW_LATENCY mode. | 306 // is only supported in AUDIO_PCM_LOW_LATENCY mode. |
| 305 if (config.params.format() == media::AudioParameters::AUDIO_PCM_LOW_LATENCY) | 307 if (config.params.format() == media::AudioParameters::AUDIO_PCM_LOW_LATENCY) |
| 306 entry->controller->SetAutomaticGainControl(config.automatic_gain_control); | 308 entry->controller->SetAutomaticGainControl(config.automatic_gain_control); |
| 307 | 309 |
| 308 // Since the controller was created successfully, create an entry and add it | 310 // Since the controller was created successfully, create an entry and add it |
| 309 // to the map. | 311 // to the map. |
| 310 entry->stream_id = stream_id; | 312 entry->stream_id = stream_id; |
| 311 audio_entries_.insert(std::make_pair(stream_id, entry.release())); | 313 audio_entries_.insert(std::make_pair(stream_id, entry.release())); |
| 312 | 314 |
| 315 MediaStreamManager::SendMessageToNativeLog( |
| 316 "Audio input stream created successfully."); |
| 313 audio_log_->OnCreated(stream_id, audio_params, device_id, std::string()); | 317 audio_log_->OnCreated(stream_id, audio_params, device_id, std::string()); |
| 314 } | 318 } |
| 315 | 319 |
| 316 void AudioInputRendererHost::OnRecordStream(int stream_id) { | 320 void AudioInputRendererHost::OnRecordStream(int stream_id) { |
| 317 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 321 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 318 | 322 |
| 319 AudioEntry* entry = LookupById(stream_id); | 323 AudioEntry* entry = LookupById(stream_id); |
| 320 if (!entry) { | 324 if (!entry) { |
| 321 SendErrorMessage(stream_id); | 325 SendErrorMessage(stream_id); |
| 322 return; | 326 return; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 342 if (!entry) { | 346 if (!entry) { |
| 343 SendErrorMessage(stream_id); | 347 SendErrorMessage(stream_id); |
| 344 return; | 348 return; |
| 345 } | 349 } |
| 346 | 350 |
| 347 entry->controller->SetVolume(volume); | 351 entry->controller->SetVolume(volume); |
| 348 audio_log_->OnSetVolume(stream_id, volume); | 352 audio_log_->OnSetVolume(stream_id, volume); |
| 349 } | 353 } |
| 350 | 354 |
| 351 void AudioInputRendererHost::SendErrorMessage(int stream_id) { | 355 void AudioInputRendererHost::SendErrorMessage(int stream_id) { |
| 356 MediaStreamManager::SendMessageToNativeLog( |
| 357 "An error occurred in AudioInputRendererHost."); |
| 352 Send(new AudioInputMsg_NotifyStreamStateChanged( | 358 Send(new AudioInputMsg_NotifyStreamStateChanged( |
| 353 stream_id, media::AudioInputIPCDelegate::kError)); | 359 stream_id, media::AudioInputIPCDelegate::kError)); |
| 354 } | 360 } |
| 355 | 361 |
| 356 void AudioInputRendererHost::DeleteEntries() { | 362 void AudioInputRendererHost::DeleteEntries() { |
| 357 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 363 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 358 | 364 |
| 359 for (AudioEntryMap::iterator i = audio_entries_.begin(); | 365 for (AudioEntryMap::iterator i = audio_entries_.begin(); |
| 360 i != audio_entries_.end(); ++i) { | 366 i != audio_entries_.end(); ++i) { |
| 361 CloseAndDeleteStream(i->second); | 367 CloseAndDeleteStream(i->second); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 // TODO(hclam): Implement a faster look up method. | 416 // TODO(hclam): Implement a faster look up method. |
| 411 for (AudioEntryMap::iterator i = audio_entries_.begin(); | 417 for (AudioEntryMap::iterator i = audio_entries_.begin(); |
| 412 i != audio_entries_.end(); ++i) { | 418 i != audio_entries_.end(); ++i) { |
| 413 if (controller == i->second->controller.get()) | 419 if (controller == i->second->controller.get()) |
| 414 return i->second; | 420 return i->second; |
| 415 } | 421 } |
| 416 return NULL; | 422 return NULL; |
| 417 } | 423 } |
| 418 | 424 |
| 419 } // namespace content | 425 } // namespace content |
| OLD | NEW |