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

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

Issue 1547073003: Switch to standard integer types in content/renderer/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
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_local_audio_track.h" 5 #include "content/renderer/media/webrtc_local_audio_track.h"
6 6
7 #include <stdint.h>
8
7 #include <limits> 9 #include <limits>
8 10
9 #include "content/public/renderer/media_stream_audio_sink.h" 11 #include "content/public/renderer/media_stream_audio_sink.h"
10 #include "content/renderer/media/media_stream_audio_level_calculator.h" 12 #include "content/renderer/media/media_stream_audio_level_calculator.h"
11 #include "content/renderer/media/media_stream_audio_processor.h" 13 #include "content/renderer/media/media_stream_audio_processor.h"
12 #include "content/renderer/media/media_stream_audio_sink_owner.h" 14 #include "content/renderer/media/media_stream_audio_sink_owner.h"
13 #include "content/renderer/media/media_stream_audio_track_sink.h" 15 #include "content/renderer/media/media_stream_audio_track_sink.h"
14 #include "content/renderer/media/webaudio_capturer_source.h" 16 #include "content/renderer/media/webaudio_capturer_source.h"
15 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" 17 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h"
16 #include "content/renderer/media/webrtc_audio_capturer.h" 18 #include "content/renderer/media/webrtc_audio_capturer.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 base::TimeTicks estimated_capture_time, 55 base::TimeTicks estimated_capture_time,
54 bool force_report_nonzero_energy) { 56 bool force_report_nonzero_energy) {
55 DCHECK(capture_thread_checker_.CalledOnValidThread()); 57 DCHECK(capture_thread_checker_.CalledOnValidThread());
56 DCHECK(!estimated_capture_time.is_null()); 58 DCHECK(!estimated_capture_time.is_null());
57 59
58 // Calculate the signal level regardless of whether the track is disabled or 60 // Calculate the signal level regardless of whether the track is disabled or
59 // enabled. If |force_report_nonzero_energy| is true, |audio_bus| contains 61 // enabled. If |force_report_nonzero_energy| is true, |audio_bus| contains
60 // post-processed data that may be all zeros even though the signal contained 62 // post-processed data that may be all zeros even though the signal contained
61 // energy before the processing. In this case, report nonzero energy even if 63 // energy before the processing. In this case, report nonzero energy even if
62 // the energy of the data in |audio_bus| is zero. 64 // the energy of the data in |audio_bus| is zero.
63 const float minimum_signal_level = force_report_nonzero_energy ? 65 const float minimum_signal_level =
64 1.0f / std::numeric_limits<int16>::max() : 0.0f; 66 force_report_nonzero_energy ? 1.0f / std::numeric_limits<int16_t>::max()
67 : 0.0f;
65 const float signal_level = std::max( 68 const float signal_level = std::max(
66 minimum_signal_level, 69 minimum_signal_level,
67 std::min(1.0f, level_calculator_->Calculate(audio_bus))); 70 std::min(1.0f, level_calculator_->Calculate(audio_bus)));
68 const int signal_level_as_pcm16 = 71 const int signal_level_as_pcm16 =
69 static_cast<int>(signal_level * std::numeric_limits<int16>::max() + 72 static_cast<int>(signal_level * std::numeric_limits<int16_t>::max() +
70 0.5f /* rounding to nearest int */); 73 0.5f /* rounding to nearest int */);
71 adapter_->SetSignalLevel(signal_level_as_pcm16); 74 adapter_->SetSignalLevel(signal_level_as_pcm16);
72 75
73 scoped_refptr<WebRtcAudioCapturer> capturer; 76 scoped_refptr<WebRtcAudioCapturer> capturer;
74 SinkList::ItemList sinks; 77 SinkList::ItemList sinks;
75 SinkList::ItemList sinks_to_notify_format; 78 SinkList::ItemList sinks_to_notify_format;
76 { 79 {
77 base::AutoLock auto_lock(lock_); 80 base::AutoLock auto_lock(lock_);
78 capturer = capturer_; 81 capturer = capturer_;
79 sinks = sinks_.Items(); 82 sinks = sinks_.Items();
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 (*it)->Reset(); 232 (*it)->Reset();
230 } 233 }
231 } 234 }
232 235
233 webrtc::AudioTrackInterface* WebRtcLocalAudioTrack::GetAudioAdapter() { 236 webrtc::AudioTrackInterface* WebRtcLocalAudioTrack::GetAudioAdapter() {
234 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 237 DCHECK(main_render_thread_checker_.CalledOnValidThread());
235 return adapter_.get(); 238 return adapter_.get();
236 } 239 }
237 240
238 } // namespace content 241 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc_local_audio_track.h ('k') | content/renderer/media/webrtc_local_audio_track_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698