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

Side by Side Diff: content/renderer/media/webrtc_audio_capturer.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 | « content/renderer/media/webrtc_audio_capturer.h ('k') | media/audio/audio_input_controller.cc » ('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/renderer/media/webrtc_audio_capturer.h" 5 #include "content/renderer/media/webrtc_audio_capturer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 20 matching lines...) Expand all
31 const int kValidInputRates[] = 31 const int kValidInputRates[] =
32 {192000, 96000, 48000, 44100, 32000, 16000, 8000}; 32 {192000, 96000, 48000, 44100, 32000, 16000, 8000};
33 #elif defined(OS_LINUX) || defined(OS_OPENBSD) 33 #elif defined(OS_LINUX) || defined(OS_OPENBSD)
34 const int kValidInputRates[] = {48000, 44100}; 34 const int kValidInputRates[] = {48000, 44100};
35 #elif defined(OS_ANDROID) 35 #elif defined(OS_ANDROID)
36 const int kValidInputRates[] = {48000, 44100}; 36 const int kValidInputRates[] = {48000, 44100};
37 #else 37 #else
38 const int kValidInputRates[] = {44100}; 38 const int kValidInputRates[] = {44100};
39 #endif 39 #endif
40 40
41 // Time constant for AudioPowerMonitor. See AudioPowerMonitor ctor comments
42 // for semantics. This value was arbitrarily chosen, but seems to work well.
43 const int kPowerMonitorTimeConstantMs = 10;
44
45 // The time between two audio power level samples.
46 const int kPowerMonitorLogIntervalSeconds = 10;
47
41 } // namespace 48 } // namespace
42 49
43 // Reference counted container of WebRtcLocalAudioTrack delegate. 50 // Reference counted container of WebRtcLocalAudioTrack delegate.
44 // TODO(xians): Switch to MediaStreamAudioSinkOwner. 51 // TODO(xians): Switch to MediaStreamAudioSinkOwner.
45 class WebRtcAudioCapturer::TrackOwner 52 class WebRtcAudioCapturer::TrackOwner
46 : public base::RefCountedThreadSafe<WebRtcAudioCapturer::TrackOwner> { 53 : public base::RefCountedThreadSafe<WebRtcAudioCapturer::TrackOwner> {
47 public: 54 public:
48 explicit TrackOwner(WebRtcLocalAudioTrack* track) 55 explicit TrackOwner(WebRtcLocalAudioTrack* track)
49 : delegate_(track) {} 56 : delegate_(track) {}
50 57
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( 222 new talk_base::RefCountedObject<MediaStreamAudioProcessor>(
216 constraints, device_info.device.input.effects, 223 constraints, device_info.device.input.effects,
217 device_info.device.type, audio_device)), 224 device_info.device.type, audio_device)),
218 running_(false), 225 running_(false),
219 render_view_id_(render_view_id), 226 render_view_id_(render_view_id),
220 device_info_(device_info), 227 device_info_(device_info),
221 volume_(0), 228 volume_(0),
222 peer_connection_mode_(false), 229 peer_connection_mode_(false),
223 key_pressed_(false), 230 key_pressed_(false),
224 need_audio_processing_(false), 231 need_audio_processing_(false),
225 audio_device_(audio_device) { 232 audio_device_(audio_device),
233 audio_power_monitor_(
234 device_info_.device.input.sample_rate,
235 base::TimeDelta::FromMilliseconds(kPowerMonitorTimeConstantMs)) {
226 DVLOG(1) << "WebRtcAudioCapturer::WebRtcAudioCapturer()"; 236 DVLOG(1) << "WebRtcAudioCapturer::WebRtcAudioCapturer()";
227 } 237 }
228 238
229 WebRtcAudioCapturer::~WebRtcAudioCapturer() { 239 WebRtcAudioCapturer::~WebRtcAudioCapturer() {
230 DCHECK(thread_checker_.CalledOnValidThread()); 240 DCHECK(thread_checker_.CalledOnValidThread());
231 DCHECK(tracks_.IsEmpty()); 241 DCHECK(tracks_.IsEmpty());
232 DCHECK(!running_); 242 DCHECK(!running_);
233 DVLOG(1) << "WebRtcAudioCapturer::~WebRtcAudioCapturer()"; 243 DVLOG(1) << "WebRtcAudioCapturer::~WebRtcAudioCapturer()";
234 } 244 }
235 245
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 486
477 // Notify the tracks on when the format changes. This will do nothing if 487 // Notify the tracks on when the format changes. This will do nothing if
478 // |tracks_to_notify_format| is empty. 488 // |tracks_to_notify_format| is empty.
479 media::AudioParameters output_params = audio_processor_->OutputFormat(); 489 media::AudioParameters output_params = audio_processor_->OutputFormat();
480 for (TrackList::ItemList::const_iterator it = tracks_to_notify_format.begin(); 490 for (TrackList::ItemList::const_iterator it = tracks_to_notify_format.begin();
481 it != tracks_to_notify_format.end(); ++it) { 491 it != tracks_to_notify_format.end(); ++it) {
482 (*it)->OnSetFormat(output_params); 492 (*it)->OnSetFormat(output_params);
483 (*it)->SetAudioProcessor(audio_processor_); 493 (*it)->SetAudioProcessor(audio_processor_);
484 } 494 }
485 495
496 if ((base::TimeTicks::Now() - last_audio_level_log_time_).InSeconds() >
497 kPowerMonitorLogIntervalSeconds) {
498 audio_power_monitor_.Scan(*audio_source, audio_source->frames());
499
500 last_audio_level_log_time_ = base::TimeTicks::Now();
501
502 std::pair<float, bool> result =
503 audio_power_monitor_.ReadCurrentPowerAndClip();
504 WebRtcLogMessage(base::StringPrintf(
505 "WAC::Capture: current_audio_power=%.2fdBFS.", result.first));
506
507 audio_power_monitor_.Reset();
508 }
509
486 // Push the data to the processor for processing. 510 // Push the data to the processor for processing.
487 audio_processor_->PushCaptureData(audio_source); 511 audio_processor_->PushCaptureData(audio_source);
488 512
489 // Process and consume the data in the processor until there is not enough 513 // Process and consume the data in the processor until there is not enough
490 // data in the processor. 514 // data in the processor.
491 int16* output = NULL; 515 int16* output = NULL;
492 int new_volume = 0; 516 int new_volume = 0;
493 while (audio_processor_->ProcessAndConsumeData( 517 while (audio_processor_->ProcessAndConsumeData(
494 audio_delay, current_volume, key_pressed, &new_volume, &output)) { 518 audio_delay, current_volume, key_pressed, &new_volume, &output)) {
495 // Feed the post-processed data to the tracks. 519 // Feed the post-processed data to the tracks.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 DCHECK_NE(aec_dump_file, base::kInvalidPlatformFileValue); 605 DCHECK_NE(aec_dump_file, base::kInvalidPlatformFileValue);
582 audio_processor_->StartAecDump(aec_dump_file); 606 audio_processor_->StartAecDump(aec_dump_file);
583 } 607 }
584 608
585 void WebRtcAudioCapturer::StopAecDump() { 609 void WebRtcAudioCapturer::StopAecDump() {
586 DCHECK(thread_checker_.CalledOnValidThread()); 610 DCHECK(thread_checker_.CalledOnValidThread());
587 audio_processor_->StopAecDump(); 611 audio_processor_->StopAecDump();
588 } 612 }
589 613
590 } // namespace content 614 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc_audio_capturer.h ('k') | media/audio/audio_input_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698