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

Side by Side Diff: content/renderer/media/webrtc_audio_capturer.cc

Issue 225143006: Limit the max volume to 255 before pass it to APM. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fixed the comment 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/media_stream_audio_processor.cc ('k') | no next file » | 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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 TrackList::ItemList tracks; 453 TrackList::ItemList tracks;
454 TrackList::ItemList tracks_to_notify_format; 454 TrackList::ItemList tracks_to_notify_format;
455 int current_volume = 0; 455 int current_volume = 0;
456 base::TimeDelta audio_delay; 456 base::TimeDelta audio_delay;
457 bool need_audio_processing = true; 457 bool need_audio_processing = true;
458 { 458 {
459 base::AutoLock auto_lock(lock_); 459 base::AutoLock auto_lock(lock_);
460 if (!running_) 460 if (!running_)
461 return; 461 return;
462 462
463 // Map internal volume range of [0.0, 1.0] into [0, 255] used by the 463 // Map internal volume range of [0.0, 1.0] into [0, 255] used by AGC.
464 // webrtc::VoiceEngine. webrtc::VoiceEngine will handle the case when the 464 // The volume can be higher than 255 on Linux, and it will be cropped to
465 // volume is higher than 255. 465 // 255 since AGC does not allow values out of range.
466 volume_ = static_cast<int>((volume * MaxVolume()) + 0.5); 466 volume_ = static_cast<int>((volume * MaxVolume()) + 0.5);
467 current_volume = volume_; 467 current_volume = volume_ > MaxVolume() ? MaxVolume() : volume_;
468 audio_delay = base::TimeDelta::FromMilliseconds(audio_delay_milliseconds); 468 audio_delay = base::TimeDelta::FromMilliseconds(audio_delay_milliseconds);
469 audio_delay_ = audio_delay; 469 audio_delay_ = audio_delay;
470 key_pressed_ = key_pressed; 470 key_pressed_ = key_pressed;
471 tracks = tracks_.Items(); 471 tracks = tracks_.Items();
472 tracks_.RetrieveAndClearTags(&tracks_to_notify_format); 472 tracks_.RetrieveAndClearTags(&tracks_to_notify_format);
473 473
474 // Set the flag to turn on the audio processing in PeerConnection level. 474 // Set the flag to turn on the audio processing in PeerConnection level.
475 // Note that, we turn off the audio processing in PeerConnection if the 475 // Note that, we turn off the audio processing in PeerConnection if the
476 // processor has already processed the data. 476 // processor has already processed the data.
477 need_audio_processing = need_audio_processing_ ? 477 need_audio_processing = need_audio_processing_ ?
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 DCHECK_NE(aec_dump_file, base::kInvalidPlatformFileValue); 605 DCHECK_NE(aec_dump_file, base::kInvalidPlatformFileValue);
606 audio_processor_->StartAecDump(aec_dump_file); 606 audio_processor_->StartAecDump(aec_dump_file);
607 } 607 }
608 608
609 void WebRtcAudioCapturer::StopAecDump() { 609 void WebRtcAudioCapturer::StopAecDump() {
610 DCHECK(thread_checker_.CalledOnValidThread()); 610 DCHECK(thread_checker_.CalledOnValidThread());
611 audio_processor_->StopAecDump(); 611 audio_processor_->StopAecDump();
612 } 612 }
613 613
614 } // namespace content 614 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_audio_processor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698