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

Side by Side Diff: webrtc/voice_engine/transmit_mixer.cc

Issue 1230503003: Update a ton of audio code to use size_t more correctly and in general reduce (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync Created 5 years, 3 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 | « webrtc/voice_engine/transmit_mixer.h ('k') | webrtc/voice_engine/transmit_mixer_unittest.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 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/voice_engine/transmit_mixer.h" 11 #include "webrtc/voice_engine/transmit_mixer.h"
12 12
13 #include "webrtc/base/format_macros.h"
13 #include "webrtc/modules/utility/interface/audio_frame_operations.h" 14 #include "webrtc/modules/utility/interface/audio_frame_operations.h"
14 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" 15 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
15 #include "webrtc/system_wrappers/interface/event_wrapper.h" 16 #include "webrtc/system_wrappers/interface/event_wrapper.h"
16 #include "webrtc/system_wrappers/interface/logging.h" 17 #include "webrtc/system_wrappers/interface/logging.h"
17 #include "webrtc/system_wrappers/interface/trace.h" 18 #include "webrtc/system_wrappers/interface/trace.h"
18 #include "webrtc/voice_engine/channel.h" 19 #include "webrtc/voice_engine/channel.h"
19 #include "webrtc/voice_engine/channel_manager.h" 20 #include "webrtc/voice_engine/channel_manager.h"
20 #include "webrtc/voice_engine/include/voe_external_media.h" 21 #include "webrtc/voice_engine/include/voe_external_media.h"
21 #include "webrtc/voice_engine/statistics.h" 22 #include "webrtc/voice_engine/statistics.h"
22 #include "webrtc/voice_engine/utility.h" 23 #include "webrtc/voice_engine/utility.h"
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 CodecInst codec; 305 CodecInst codec;
305 channel->GetSendCodec(codec); 306 channel->GetSendCodec(codec);
306 *max_sample_rate = std::max(*max_sample_rate, codec.plfreq); 307 *max_sample_rate = std::max(*max_sample_rate, codec.plfreq);
307 *max_channels = std::max(*max_channels, codec.channels); 308 *max_channels = std::max(*max_channels, codec.channels);
308 } 309 }
309 } 310 }
310 } 311 }
311 312
312 int32_t 313 int32_t
313 TransmitMixer::PrepareDemux(const void* audioSamples, 314 TransmitMixer::PrepareDemux(const void* audioSamples,
314 uint32_t nSamples, 315 size_t nSamples,
315 uint8_t nChannels, 316 uint8_t nChannels,
316 uint32_t samplesPerSec, 317 uint32_t samplesPerSec,
317 uint16_t totalDelayMS, 318 uint16_t totalDelayMS,
318 int32_t clockDrift, 319 int32_t clockDrift,
319 uint16_t currentMicLevel, 320 uint16_t currentMicLevel,
320 bool keyPressed) 321 bool keyPressed)
321 { 322 {
322 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, -1), 323 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, -1),
323 "TransmitMixer::PrepareDemux(nSamples=%u, nChannels=%u," 324 "TransmitMixer::PrepareDemux(nSamples=%" PRIuS ", "
324 "samplesPerSec=%u, totalDelayMS=%u, clockDrift=%d," 325 "nChannels=%u, samplesPerSec=%u, totalDelayMS=%u, "
325 "currentMicLevel=%u)", nSamples, nChannels, samplesPerSec, 326 "clockDrift=%d, currentMicLevel=%u)",
326 totalDelayMS, clockDrift, currentMicLevel); 327 nSamples, nChannels, samplesPerSec, totalDelayMS, clockDrift,
328 currentMicLevel);
327 329
328 // --- Resample input audio and create/store the initial audio frame 330 // --- Resample input audio and create/store the initial audio frame
329 GenerateAudioFrame(static_cast<const int16_t*>(audioSamples), 331 GenerateAudioFrame(static_cast<const int16_t*>(audioSamples),
330 nSamples, 332 nSamples,
331 nChannels, 333 nChannels,
332 samplesPerSec); 334 samplesPerSec);
333 335
334 { 336 {
335 CriticalSectionScoped cs(&_callbackCritSect); 337 CriticalSectionScoped cs(&_callbackCritSect);
336 if (external_preproc_ptr_) { 338 if (external_preproc_ptr_) {
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 return _fileCallRecording; 1123 return _fileCallRecording;
1122 } 1124 }
1123 1125
1124 bool TransmitMixer::IsRecordingMic() 1126 bool TransmitMixer::IsRecordingMic()
1125 { 1127 {
1126 CriticalSectionScoped cs(&_critSect); 1128 CriticalSectionScoped cs(&_critSect);
1127 return _fileRecording; 1129 return _fileRecording;
1128 } 1130 }
1129 1131
1130 void TransmitMixer::GenerateAudioFrame(const int16_t* audio, 1132 void TransmitMixer::GenerateAudioFrame(const int16_t* audio,
1131 int samples_per_channel, 1133 size_t samples_per_channel,
1132 int num_channels, 1134 int num_channels,
1133 int sample_rate_hz) { 1135 int sample_rate_hz) {
1134 int codec_rate; 1136 int codec_rate;
1135 int num_codec_channels; 1137 int num_codec_channels;
1136 GetSendCodecInfo(&codec_rate, &num_codec_channels); 1138 GetSendCodecInfo(&codec_rate, &num_codec_channels);
1137 // TODO(ajm): This currently restricts the sample rate to 32 kHz. 1139 // TODO(ajm): This currently restricts the sample rate to 32 kHz.
1138 // See: https://code.google.com/p/webrtc/issues/detail?id=3146 1140 // See: https://code.google.com/p/webrtc/issues/detail?id=3146
1139 // When 48 kHz is supported natively by AudioProcessing, this will have 1141 // When 48 kHz is supported natively by AudioProcessing, this will have
1140 // to be changed to handle 44.1 kHz. 1142 // to be changed to handle 44.1 kHz.
1141 int max_sample_rate_hz = kAudioProcMaxNativeSampleRateHz; 1143 int max_sample_rate_hz = kAudioProcMaxNativeSampleRateHz;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 } 1184 }
1183 1185
1184 return 0; 1186 return 0;
1185 } 1187 }
1186 1188
1187 int32_t TransmitMixer::MixOrReplaceAudioWithFile( 1189 int32_t TransmitMixer::MixOrReplaceAudioWithFile(
1188 int mixingFrequency) 1190 int mixingFrequency)
1189 { 1191 {
1190 rtc::scoped_ptr<int16_t[]> fileBuffer(new int16_t[640]); 1192 rtc::scoped_ptr<int16_t[]> fileBuffer(new int16_t[640]);
1191 1193
1192 int fileSamples(0); 1194 size_t fileSamples(0);
1193 { 1195 {
1194 CriticalSectionScoped cs(&_critSect); 1196 CriticalSectionScoped cs(&_critSect);
1195 if (_filePlayerPtr == NULL) 1197 if (_filePlayerPtr == NULL)
1196 { 1198 {
1197 WEBRTC_TRACE(kTraceWarning, kTraceVoice, 1199 WEBRTC_TRACE(kTraceWarning, kTraceVoice,
1198 VoEId(_instanceId, -1), 1200 VoEId(_instanceId, -1),
1199 "TransmitMixer::MixOrReplaceAudioWithFile()" 1201 "TransmitMixer::MixOrReplaceAudioWithFile()"
1200 "fileplayer doesnot exist"); 1202 "fileplayer doesnot exist");
1201 return -1; 1203 return -1;
1202 } 1204 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 void TransmitMixer::EnableStereoChannelSwapping(bool enable) { 1337 void TransmitMixer::EnableStereoChannelSwapping(bool enable) {
1336 swap_stereo_channels_ = enable; 1338 swap_stereo_channels_ = enable;
1337 } 1339 }
1338 1340
1339 bool TransmitMixer::IsStereoChannelSwappingEnabled() { 1341 bool TransmitMixer::IsStereoChannelSwappingEnabled() {
1340 return swap_stereo_channels_; 1342 return swap_stereo_channels_;
1341 } 1343 }
1342 1344
1343 } // namespace voe 1345 } // namespace voe
1344 } // namespace webrtc 1346 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/voice_engine/transmit_mixer.h ('k') | webrtc/voice_engine/transmit_mixer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698