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

Side by Side Diff: content/browser/renderer_host/media/audio_input_renderer_host.cc

Issue 229573003: Adds more logging for audio input issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | content/renderer/media/webrtc_audio_capturer.h » ('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 #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/numerics/safe_math.h" 10 #include "base/numerics/safe_math.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 media::AudioInputController* controller) { 175 media::AudioInputController* controller) {
176 DCHECK_CURRENTLY_ON(BrowserThread::IO); 176 DCHECK_CURRENTLY_ON(BrowserThread::IO);
177 // TODO(henrika): See crbug.com/115262 for details on why this method 177 // TODO(henrika): See crbug.com/115262 for details on why this method
178 // should be implemented. 178 // should be implemented.
179 } 179 }
180 180
181 void AudioInputRendererHost::DoHandleError( 181 void AudioInputRendererHost::DoHandleError(
182 media::AudioInputController* controller, 182 media::AudioInputController* controller,
183 media::AudioInputController::ErrorCode error_code) { 183 media::AudioInputController::ErrorCode error_code) {
184 DCHECK_CURRENTLY_ON(BrowserThread::IO); 184 DCHECK_CURRENTLY_ON(BrowserThread::IO);
185 // Log all errors even it is ignored later.
185 MediaStreamManager::SendMessageToNativeLog( 186 MediaStreamManager::SendMessageToNativeLog(
186 base::StringPrintf("AudioInputController error: %d", error_code)); 187 base::StringPrintf("AudioInputController error: %d", error_code));
187 188
189 // This is a fix for crbug.com/357501. The error can be triggered when closing
190 // the lid on Macs, which causes more problems than it fixes.
191 // Also, in crbug.com/357569, the goal is to remove usage of the error since
192 // it was added to solve a crash on Windows that no longer can be reproduced.
193 if (error_code == media::AudioInputController::NO_DATA_ERROR) {
194 DVLOG(1) << "AudioInputRendererHost@" << this << "::DoHandleError: "
195 << "NO_DATA_ERROR ignored.";
196 return;
197 }
198
188 AudioEntry* entry = LookupByController(controller); 199 AudioEntry* entry = LookupByController(controller);
189 if (!entry) 200 if (!entry)
190 return; 201 return;
191 202
192 audio_log_->OnError(entry->stream_id); 203 audio_log_->OnError(entry->stream_id);
193 DeleteEntryOnError(entry, AUDIO_INPUT_CONTROLLER_ERROR); 204 DeleteEntryOnError(entry, AUDIO_INPUT_CONTROLLER_ERROR);
194 } 205 }
195 206
196 bool AudioInputRendererHost::OnMessageReceived(const IPC::Message& message, 207 bool AudioInputRendererHost::OnMessageReceived(const IPC::Message& message,
197 bool* message_was_ok) { 208 bool* message_was_ok) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 if (media_stream_manager_->audio_input_device_manager()-> 241 if (media_stream_manager_->audio_input_device_manager()->
231 ShouldUseFakeDevice()) { 242 ShouldUseFakeDevice()) {
232 audio_params.Reset( 243 audio_params.Reset(
233 media::AudioParameters::AUDIO_FAKE, 244 media::AudioParameters::AUDIO_FAKE,
234 config.params.channel_layout(), config.params.channels(), 0, 245 config.params.channel_layout(), config.params.channels(), 0,
235 config.params.sample_rate(), config.params.bits_per_sample(), 246 config.params.sample_rate(), config.params.bits_per_sample(),
236 config.params.frames_per_buffer()); 247 config.params.frames_per_buffer());
237 } 248 }
238 249
239 // Check if we have the permission to open the device and which device to use. 250 // Check if we have the permission to open the device and which device to use.
251 std::string device_name;
240 std::string device_id = media::AudioManagerBase::kDefaultDeviceId; 252 std::string device_id = media::AudioManagerBase::kDefaultDeviceId;
241 if (audio_params.format() != media::AudioParameters::AUDIO_FAKE) { 253 if (audio_params.format() != media::AudioParameters::AUDIO_FAKE) {
242 const StreamDeviceInfo* info = media_stream_manager_-> 254 const StreamDeviceInfo* info = media_stream_manager_->
243 audio_input_device_manager()->GetOpenedDeviceInfoById(session_id); 255 audio_input_device_manager()->GetOpenedDeviceInfoById(session_id);
244 if (!info) { 256 if (!info) {
245 SendErrorMessage(stream_id, PERMISSION_DENIED); 257 SendErrorMessage(stream_id, PERMISSION_DENIED);
246 DLOG(WARNING) << "No permission has been granted to input stream with " 258 DLOG(WARNING) << "No permission has been granted to input stream with "
247 << "session_id=" << session_id; 259 << "session_id=" << session_id;
248 return; 260 return;
249 } 261 }
250 262
251 device_id = info->device.id; 263 device_id = info->device.id;
264 device_name = info->device.name;
252 } 265 }
253 266
254 // Create a new AudioEntry structure. 267 // Create a new AudioEntry structure.
255 scoped_ptr<AudioEntry> entry(new AudioEntry()); 268 scoped_ptr<AudioEntry> entry(new AudioEntry());
256 269
257 const uint32 segment_size = (sizeof(media::AudioInputBufferParameters) + 270 const uint32 segment_size = (sizeof(media::AudioInputBufferParameters) +
258 audio_params.GetBytesPerBuffer()); 271 audio_params.GetBytesPerBuffer());
259 entry->shared_memory_segment_count = config.shared_memory_count; 272 entry->shared_memory_segment_count = config.shared_memory_count;
260 273
261 // Create the shared memory and share it with the renderer process 274 // Create the shared memory and share it with the renderer process
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 // is only supported in AUDIO_PCM_LOW_LATENCY mode. 327 // is only supported in AUDIO_PCM_LOW_LATENCY mode.
315 if (config.params.format() == media::AudioParameters::AUDIO_PCM_LOW_LATENCY) 328 if (config.params.format() == media::AudioParameters::AUDIO_PCM_LOW_LATENCY)
316 entry->controller->SetAutomaticGainControl(config.automatic_gain_control); 329 entry->controller->SetAutomaticGainControl(config.automatic_gain_control);
317 330
318 // Since the controller was created successfully, create an entry and add it 331 // Since the controller was created successfully, create an entry and add it
319 // to the map. 332 // to the map.
320 entry->stream_id = stream_id; 333 entry->stream_id = stream_id;
321 audio_entries_.insert(std::make_pair(stream_id, entry.release())); 334 audio_entries_.insert(std::make_pair(stream_id, entry.release()));
322 335
323 MediaStreamManager::SendMessageToNativeLog( 336 MediaStreamManager::SendMessageToNativeLog(
324 "Audio input stream created successfully."); 337 "Audio input stream created successfully. Device name: " + device_name);
325 audio_log_->OnCreated(stream_id, audio_params, device_id); 338 audio_log_->OnCreated(stream_id, audio_params, device_id);
326 } 339 }
327 340
328 void AudioInputRendererHost::OnRecordStream(int stream_id) { 341 void AudioInputRendererHost::OnRecordStream(int stream_id) {
329 DCHECK_CURRENTLY_ON(BrowserThread::IO); 342 DCHECK_CURRENTLY_ON(BrowserThread::IO);
330 343
331 AudioEntry* entry = LookupById(stream_id); 344 AudioEntry* entry = LookupById(stream_id);
332 if (!entry) { 345 if (!entry) {
333 SendErrorMessage(stream_id, INVALID_AUDIO_ENTRY); 346 SendErrorMessage(stream_id, INVALID_AUDIO_ENTRY);
334 return; 347 return;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 // TODO(hclam): Implement a faster look up method. 439 // TODO(hclam): Implement a faster look up method.
427 for (AudioEntryMap::iterator i = audio_entries_.begin(); 440 for (AudioEntryMap::iterator i = audio_entries_.begin();
428 i != audio_entries_.end(); ++i) { 441 i != audio_entries_.end(); ++i) {
429 if (controller == i->second->controller.get()) 442 if (controller == i->second->controller.get())
430 return i->second; 443 return i->second;
431 } 444 }
432 return NULL; 445 return NULL;
433 } 446 }
434 447
435 } // namespace content 448 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/webrtc_audio_capturer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698