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

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

Issue 1316523002: Convert channel counts to size_t. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Fix compile Created 4 years, 11 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/voe_base_impl.h ('k') | webrtc/voice_engine/voe_codec_impl.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
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 if (voiceEngineObserverPtr_) { 76 if (voiceEngineObserverPtr_) {
77 // Deliver callback (-1 <=> no channel dependency) 77 // Deliver callback (-1 <=> no channel dependency)
78 voiceEngineObserverPtr_->CallbackOnError(-1, warningCode); 78 voiceEngineObserverPtr_->CallbackOnError(-1, warningCode);
79 } 79 }
80 } 80 }
81 81
82 int32_t VoEBaseImpl::RecordedDataIsAvailable(const void* audioSamples, 82 int32_t VoEBaseImpl::RecordedDataIsAvailable(const void* audioSamples,
83 const size_t nSamples, 83 const size_t nSamples,
84 const size_t nBytesPerSample, 84 const size_t nBytesPerSample,
85 const uint8_t nChannels, 85 const size_t nChannels,
86 const uint32_t samplesPerSec, 86 const uint32_t samplesPerSec,
87 const uint32_t totalDelayMS, 87 const uint32_t totalDelayMS,
88 const int32_t clockDrift, 88 const int32_t clockDrift,
89 const uint32_t currentMicLevel, 89 const uint32_t currentMicLevel,
90 const bool keyPressed, 90 const bool keyPressed,
91 uint32_t& newMicLevel) { 91 uint32_t& newMicLevel) {
92 newMicLevel = static_cast<uint32_t>(ProcessRecordedDataWithAPM( 92 newMicLevel = static_cast<uint32_t>(ProcessRecordedDataWithAPM(
93 nullptr, 0, audioSamples, samplesPerSec, nChannels, nSamples, 93 nullptr, 0, audioSamples, samplesPerSec, nChannels, nSamples,
94 totalDelayMS, clockDrift, currentMicLevel, keyPressed)); 94 totalDelayMS, clockDrift, currentMicLevel, keyPressed));
95 return 0; 95 return 0;
96 } 96 }
97 97
98 int32_t VoEBaseImpl::NeedMorePlayData(const size_t nSamples, 98 int32_t VoEBaseImpl::NeedMorePlayData(const size_t nSamples,
99 const size_t nBytesPerSample, 99 const size_t nBytesPerSample,
100 const uint8_t nChannels, 100 const size_t nChannels,
101 const uint32_t samplesPerSec, 101 const uint32_t samplesPerSec,
102 void* audioSamples, 102 void* audioSamples,
103 size_t& nSamplesOut, 103 size_t& nSamplesOut,
104 int64_t* elapsed_time_ms, 104 int64_t* elapsed_time_ms,
105 int64_t* ntp_time_ms) { 105 int64_t* ntp_time_ms) {
106 GetPlayoutData(static_cast<int>(samplesPerSec), static_cast<int>(nChannels), 106 GetPlayoutData(static_cast<int>(samplesPerSec), nChannels, nSamples, true,
107 nSamples, true, audioSamples, 107 audioSamples, elapsed_time_ms, ntp_time_ms);
108 elapsed_time_ms, ntp_time_ms);
109 nSamplesOut = audioFrame_.samples_per_channel_; 108 nSamplesOut = audioFrame_.samples_per_channel_;
110 return 0; 109 return 0;
111 } 110 }
112 111
113 int VoEBaseImpl::OnDataAvailable(const int voe_channels[], 112 int VoEBaseImpl::OnDataAvailable(const int voe_channels[],
114 int number_of_voe_channels, 113 size_t number_of_voe_channels,
115 const int16_t* audio_data, int sample_rate, 114 const int16_t* audio_data, int sample_rate,
116 int number_of_channels, 115 size_t number_of_channels,
117 size_t number_of_frames, 116 size_t number_of_frames,
118 int audio_delay_milliseconds, int volume, 117 int audio_delay_milliseconds, int volume,
119 bool key_pressed, bool need_audio_processing) { 118 bool key_pressed, bool need_audio_processing) {
120 if (number_of_voe_channels == 0) return 0; 119 if (number_of_voe_channels == 0) return 0;
121 120
122 if (need_audio_processing) { 121 if (need_audio_processing) {
123 return ProcessRecordedDataWithAPM( 122 return ProcessRecordedDataWithAPM(
124 voe_channels, number_of_voe_channels, audio_data, sample_rate, 123 voe_channels, number_of_voe_channels, audio_data, sample_rate,
125 number_of_channels, number_of_frames, audio_delay_milliseconds, 0, 124 number_of_channels, number_of_frames, audio_delay_milliseconds, 0,
126 volume, key_pressed); 125 volume, key_pressed);
127 } 126 }
128 127
129 // No need to go through the APM, demultiplex the data to each VoE channel, 128 // No need to go through the APM, demultiplex the data to each VoE channel,
130 // encode and send to the network. 129 // encode and send to the network.
131 for (int i = 0; i < number_of_voe_channels; ++i) { 130 for (size_t i = 0; i < number_of_voe_channels; ++i) {
132 // TODO(ajm): In the case where multiple channels are using the same codec 131 // TODO(ajm): In the case where multiple channels are using the same codec
133 // rate, this path needlessly does extra conversions. We should convert once 132 // rate, this path needlessly does extra conversions. We should convert once
134 // and share between channels. 133 // and share between channels.
135 PushCaptureData(voe_channels[i], audio_data, 16, sample_rate, 134 PushCaptureData(voe_channels[i], audio_data, 16, sample_rate,
136 number_of_channels, number_of_frames); 135 number_of_channels, number_of_frames);
137 } 136 }
138 137
139 // Return 0 to indicate no need to change the volume. 138 // Return 0 to indicate no need to change the volume.
140 return 0; 139 return 0;
141 } 140 }
142 141
143 void VoEBaseImpl::OnData(int voe_channel, const void* audio_data, 142 void VoEBaseImpl::OnData(int voe_channel, const void* audio_data,
144 int bits_per_sample, int sample_rate, 143 int bits_per_sample, int sample_rate,
145 int number_of_channels, size_t number_of_frames) { 144 size_t number_of_channels, size_t number_of_frames) {
146 PushCaptureData(voe_channel, audio_data, bits_per_sample, sample_rate, 145 PushCaptureData(voe_channel, audio_data, bits_per_sample, sample_rate,
147 number_of_channels, number_of_frames); 146 number_of_channels, number_of_frames);
148 } 147 }
149 148
150 void VoEBaseImpl::PushCaptureData(int voe_channel, const void* audio_data, 149 void VoEBaseImpl::PushCaptureData(int voe_channel, const void* audio_data,
151 int bits_per_sample, int sample_rate, 150 int bits_per_sample, int sample_rate,
152 int number_of_channels, 151 size_t number_of_channels,
153 size_t number_of_frames) { 152 size_t number_of_frames) {
154 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(voe_channel); 153 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(voe_channel);
155 voe::Channel* channel_ptr = ch.channel(); 154 voe::Channel* channel_ptr = ch.channel();
156 if (!channel_ptr) return; 155 if (!channel_ptr) return;
157 156
158 if (channel_ptr->Sending()) { 157 if (channel_ptr->Sending()) {
159 channel_ptr->Demultiplex(static_cast<const int16_t*>(audio_data), 158 channel_ptr->Demultiplex(static_cast<const int16_t*>(audio_data),
160 sample_rate, number_of_frames, number_of_channels); 159 sample_rate, number_of_frames, number_of_channels);
161 channel_ptr->PrepareEncodeAndSend(sample_rate); 160 channel_ptr->PrepareEncodeAndSend(sample_rate);
162 channel_ptr->EncodeAndSend(); 161 channel_ptr->EncodeAndSend();
163 } 162 }
164 } 163 }
165 164
166 void VoEBaseImpl::PullRenderData(int bits_per_sample, 165 void VoEBaseImpl::PullRenderData(int bits_per_sample,
167 int sample_rate, 166 int sample_rate,
168 int number_of_channels, 167 size_t number_of_channels,
169 size_t number_of_frames, 168 size_t number_of_frames,
170 void* audio_data, int64_t* elapsed_time_ms, 169 void* audio_data, int64_t* elapsed_time_ms,
171 int64_t* ntp_time_ms) { 170 int64_t* ntp_time_ms) {
172 assert(bits_per_sample == 16); 171 assert(bits_per_sample == 16);
173 assert(number_of_frames == static_cast<size_t>(sample_rate / 100)); 172 assert(number_of_frames == static_cast<size_t>(sample_rate / 100));
174 173
175 GetPlayoutData(sample_rate, number_of_channels, number_of_frames, false, 174 GetPlayoutData(sample_rate, number_of_channels, number_of_frames, false,
176 audio_data, elapsed_time_ms, ntp_time_ms); 175 audio_data, elapsed_time_ms, ntp_time_ms);
177 } 176 }
178 177
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 } 691 }
693 692
694 if (shared_->audio_processing()) { 693 if (shared_->audio_processing()) {
695 shared_->set_audio_processing(nullptr); 694 shared_->set_audio_processing(nullptr);
696 } 695 }
697 696
698 return shared_->statistics().SetUnInitialized(); 697 return shared_->statistics().SetUnInitialized();
699 } 698 }
700 699
701 int VoEBaseImpl::ProcessRecordedDataWithAPM( 700 int VoEBaseImpl::ProcessRecordedDataWithAPM(
702 const int voe_channels[], int number_of_voe_channels, 701 const int voe_channels[], size_t number_of_voe_channels,
703 const void* audio_data, uint32_t sample_rate, uint8_t number_of_channels, 702 const void* audio_data, uint32_t sample_rate, size_t number_of_channels,
704 size_t number_of_frames, uint32_t audio_delay_milliseconds, 703 size_t number_of_frames, uint32_t audio_delay_milliseconds,
705 int32_t clock_drift, uint32_t volume, bool key_pressed) { 704 int32_t clock_drift, uint32_t volume, bool key_pressed) {
706 assert(shared_->transmit_mixer() != nullptr); 705 assert(shared_->transmit_mixer() != nullptr);
707 assert(shared_->audio_device() != nullptr); 706 assert(shared_->audio_device() != nullptr);
708 707
709 uint32_t max_volume = 0; 708 uint32_t max_volume = 0;
710 uint16_t voe_mic_level = 0; 709 uint16_t voe_mic_level = 0;
711 // Check for zero to skip this calculation; the consumer may use this to 710 // Check for zero to skip this calculation; the consumer may use this to
712 // indicate no volume is available. 711 // indicate no volume is available.
713 if (volume != 0) { 712 if (volume != 0) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 // Return the new volume if AGC has changed the volume. 757 // Return the new volume if AGC has changed the volume.
759 return static_cast<int>((new_voe_mic_level * max_volume + 758 return static_cast<int>((new_voe_mic_level * max_volume +
760 static_cast<int>(kMaxVolumeLevel / 2)) / 759 static_cast<int>(kMaxVolumeLevel / 2)) /
761 kMaxVolumeLevel); 760 kMaxVolumeLevel);
762 } 761 }
763 762
764 // Return 0 to indicate no change on the volume. 763 // Return 0 to indicate no change on the volume.
765 return 0; 764 return 0;
766 } 765 }
767 766
768 void VoEBaseImpl::GetPlayoutData(int sample_rate, int number_of_channels, 767 void VoEBaseImpl::GetPlayoutData(int sample_rate, size_t number_of_channels,
769 size_t number_of_frames, bool feed_data_to_apm, 768 size_t number_of_frames, bool feed_data_to_apm,
770 void* audio_data, int64_t* elapsed_time_ms, 769 void* audio_data, int64_t* elapsed_time_ms,
771 int64_t* ntp_time_ms) { 770 int64_t* ntp_time_ms) {
772 assert(shared_->output_mixer() != nullptr); 771 assert(shared_->output_mixer() != nullptr);
773 772
774 // TODO(andrew): if the device is running in mono, we should tell the mixer 773 // TODO(andrew): if the device is running in mono, we should tell the mixer
775 // here so that it will only request mono from AudioCodingModule. 774 // here so that it will only request mono from AudioCodingModule.
776 // Perform mixing of all active participants (channel-based mixing) 775 // Perform mixing of all active participants (channel-based mixing)
777 shared_->output_mixer()->MixActiveChannels(); 776 shared_->output_mixer()->MixActiveChannels();
778 777
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, 816 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
818 "AssociateSendChannel() failed to locate accociate_send_channel"); 817 "AssociateSendChannel() failed to locate accociate_send_channel");
819 return -1; 818 return -1;
820 } 819 }
821 820
822 channel_ptr->set_associate_send_channel(ch); 821 channel_ptr->set_associate_send_channel(ch);
823 return 0; 822 return 0;
824 } 823 }
825 824
826 } // namespace webrtc 825 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/voice_engine/voe_base_impl.h ('k') | webrtc/voice_engine/voe_codec_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698