OLD | NEW |
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/voe_volume_control_impl.h" | 11 #include "webrtc/voice_engine/voe_volume_control_impl.h" |
12 | 12 |
13 #include "webrtc/system_wrappers/include/trace.h" | 13 #include "webrtc/system_wrappers/include/trace.h" |
14 #include "webrtc/voice_engine/channel.h" | 14 #include "webrtc/voice_engine/channel.h" |
15 #include "webrtc/voice_engine/include/voe_errors.h" | 15 #include "webrtc/voice_engine/include/voe_errors.h" |
16 #include "webrtc/voice_engine/output_mixer.h" | 16 #include "webrtc/voice_engine/output_mixer.h" |
17 #include "webrtc/voice_engine/transmit_mixer.h" | 17 #include "webrtc/voice_engine/transmit_mixer.h" |
18 #include "webrtc/voice_engine/voice_engine_impl.h" | 18 #include "webrtc/voice_engine/voice_engine_impl.h" |
19 | 19 |
20 namespace webrtc { | 20 namespace webrtc { |
21 | 21 |
22 VoEVolumeControl* VoEVolumeControl::GetInterface(VoiceEngine* voiceEngine) { | 22 VoEVolumeControl* VoEVolumeControl::GetInterface(VoiceEngine* voiceEngine) { |
23 if (NULL == voiceEngine) { | 23 if (nullptr == voiceEngine) { |
24 return NULL; | 24 return nullptr; |
25 } | 25 } |
26 VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine); | 26 VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine); |
27 s->AddRef(); | 27 s->AddRef(); |
28 return s; | 28 return s; |
29 } | 29 } |
30 | 30 |
31 VoEVolumeControlImpl::VoEVolumeControlImpl(voe::SharedData* shared) | 31 VoEVolumeControlImpl::VoEVolumeControlImpl(voe::SharedData* shared) |
32 : _shared(shared) { | 32 : _shared(shared) { |
33 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), | 33 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), |
34 "VoEVolumeControlImpl::VoEVolumeControlImpl() - ctor"); | 34 "VoEVolumeControlImpl::VoEVolumeControlImpl() - ctor"); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 197 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
198 return -1; | 198 return -1; |
199 } | 199 } |
200 if (channel == -1) { | 200 if (channel == -1) { |
201 // Mute before demultiplexing <=> affects all channels | 201 // Mute before demultiplexing <=> affects all channels |
202 return _shared->transmit_mixer()->SetMute(enable); | 202 return _shared->transmit_mixer()->SetMute(enable); |
203 } | 203 } |
204 // Mute after demultiplexing <=> affects one channel only | 204 // Mute after demultiplexing <=> affects one channel only |
205 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); | 205 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
206 voe::Channel* channelPtr = ch.channel(); | 206 voe::Channel* channelPtr = ch.channel(); |
207 if (channelPtr == NULL) { | 207 if (channelPtr == nullptr) { |
208 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 208 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
209 "SetInputMute() failed to locate channel"); | 209 "SetInputMute() failed to locate channel"); |
210 return -1; | 210 return -1; |
211 } | 211 } |
212 return channelPtr->SetInputMute(enable); | 212 return channelPtr->SetInputMute(enable); |
213 } | 213 } |
214 | 214 |
215 int VoEVolumeControlImpl::GetInputMute(int channel, bool& enabled) { | 215 int VoEVolumeControlImpl::GetInputMute(int channel, bool& enabled) { |
216 if (!_shared->statistics().Initialized()) { | 216 if (!_shared->statistics().Initialized()) { |
217 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 217 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
218 return -1; | 218 return -1; |
219 } | 219 } |
220 if (channel == -1) { | 220 if (channel == -1) { |
221 enabled = _shared->transmit_mixer()->Mute(); | 221 enabled = _shared->transmit_mixer()->Mute(); |
222 } else { | 222 } else { |
223 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); | 223 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
224 voe::Channel* channelPtr = ch.channel(); | 224 voe::Channel* channelPtr = ch.channel(); |
225 if (channelPtr == NULL) { | 225 if (channelPtr == nullptr) { |
226 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 226 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
227 "SetInputMute() failed to locate channel"); | 227 "SetInputMute() failed to locate channel"); |
228 return -1; | 228 return -1; |
229 } | 229 } |
230 enabled = channelPtr->InputMute(); | 230 enabled = channelPtr->InputMute(); |
231 } | 231 } |
232 return 0; | 232 return 0; |
233 } | 233 } |
234 | 234 |
235 int VoEVolumeControlImpl::GetSpeechInputLevel(unsigned int& level) { | 235 int VoEVolumeControlImpl::GetSpeechInputLevel(unsigned int& level) { |
(...skipping 10 matching lines...) Expand all Loading... |
246 unsigned int& level) { | 246 unsigned int& level) { |
247 if (!_shared->statistics().Initialized()) { | 247 if (!_shared->statistics().Initialized()) { |
248 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 248 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
249 return -1; | 249 return -1; |
250 } | 250 } |
251 if (channel == -1) { | 251 if (channel == -1) { |
252 return _shared->output_mixer()->GetSpeechOutputLevel((uint32_t&)level); | 252 return _shared->output_mixer()->GetSpeechOutputLevel((uint32_t&)level); |
253 } else { | 253 } else { |
254 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); | 254 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
255 voe::Channel* channelPtr = ch.channel(); | 255 voe::Channel* channelPtr = ch.channel(); |
256 if (channelPtr == NULL) { | 256 if (channelPtr == nullptr) { |
257 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 257 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
258 "GetSpeechOutputLevel() failed to locate channel"); | 258 "GetSpeechOutputLevel() failed to locate channel"); |
259 return -1; | 259 return -1; |
260 } | 260 } |
261 channelPtr->GetSpeechOutputLevel((uint32_t&)level); | 261 channelPtr->GetSpeechOutputLevel((uint32_t&)level); |
262 } | 262 } |
263 return 0; | 263 return 0; |
264 } | 264 } |
265 | 265 |
266 int VoEVolumeControlImpl::GetSpeechInputLevelFullRange(unsigned int& level) { | 266 int VoEVolumeControlImpl::GetSpeechInputLevelFullRange(unsigned int& level) { |
(...skipping 11 matching lines...) Expand all Loading... |
278 if (!_shared->statistics().Initialized()) { | 278 if (!_shared->statistics().Initialized()) { |
279 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 279 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
280 return -1; | 280 return -1; |
281 } | 281 } |
282 if (channel == -1) { | 282 if (channel == -1) { |
283 return _shared->output_mixer()->GetSpeechOutputLevelFullRange( | 283 return _shared->output_mixer()->GetSpeechOutputLevelFullRange( |
284 (uint32_t&)level); | 284 (uint32_t&)level); |
285 } else { | 285 } else { |
286 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); | 286 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
287 voe::Channel* channelPtr = ch.channel(); | 287 voe::Channel* channelPtr = ch.channel(); |
288 if (channelPtr == NULL) { | 288 if (channelPtr == nullptr) { |
289 _shared->SetLastError( | 289 _shared->SetLastError( |
290 VE_CHANNEL_NOT_VALID, kTraceError, | 290 VE_CHANNEL_NOT_VALID, kTraceError, |
291 "GetSpeechOutputLevelFullRange() failed to locate channel"); | 291 "GetSpeechOutputLevelFullRange() failed to locate channel"); |
292 return -1; | 292 return -1; |
293 } | 293 } |
294 channelPtr->GetSpeechOutputLevelFullRange((uint32_t&)level); | 294 channelPtr->GetSpeechOutputLevelFullRange((uint32_t&)level); |
295 } | 295 } |
296 return 0; | 296 return 0; |
297 } | 297 } |
298 | 298 |
299 int VoEVolumeControlImpl::SetChannelOutputVolumeScaling(int channel, | 299 int VoEVolumeControlImpl::SetChannelOutputVolumeScaling(int channel, |
300 float scaling) { | 300 float scaling) { |
301 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), | 301 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
302 "SetChannelOutputVolumeScaling(channel=%d, scaling=%3.2f)", | 302 "SetChannelOutputVolumeScaling(channel=%d, scaling=%3.2f)", |
303 channel, scaling); | 303 channel, scaling); |
304 if (!_shared->statistics().Initialized()) { | 304 if (!_shared->statistics().Initialized()) { |
305 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 305 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
306 return -1; | 306 return -1; |
307 } | 307 } |
308 if (scaling < kMinOutputVolumeScaling || scaling > kMaxOutputVolumeScaling) { | 308 if (scaling < kMinOutputVolumeScaling || scaling > kMaxOutputVolumeScaling) { |
309 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, | 309 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, |
310 "SetChannelOutputVolumeScaling() invalid parameter"); | 310 "SetChannelOutputVolumeScaling() invalid parameter"); |
311 return -1; | 311 return -1; |
312 } | 312 } |
313 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); | 313 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
314 voe::Channel* channelPtr = ch.channel(); | 314 voe::Channel* channelPtr = ch.channel(); |
315 if (channelPtr == NULL) { | 315 if (channelPtr == nullptr) { |
316 _shared->SetLastError( | 316 _shared->SetLastError( |
317 VE_CHANNEL_NOT_VALID, kTraceError, | 317 VE_CHANNEL_NOT_VALID, kTraceError, |
318 "SetChannelOutputVolumeScaling() failed to locate channel"); | 318 "SetChannelOutputVolumeScaling() failed to locate channel"); |
319 return -1; | 319 return -1; |
320 } | 320 } |
321 return channelPtr->SetChannelOutputVolumeScaling(scaling); | 321 return channelPtr->SetChannelOutputVolumeScaling(scaling); |
322 } | 322 } |
323 | 323 |
324 int VoEVolumeControlImpl::GetChannelOutputVolumeScaling(int channel, | 324 int VoEVolumeControlImpl::GetChannelOutputVolumeScaling(int channel, |
325 float& scaling) { | 325 float& scaling) { |
326 if (!_shared->statistics().Initialized()) { | 326 if (!_shared->statistics().Initialized()) { |
327 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 327 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
328 return -1; | 328 return -1; |
329 } | 329 } |
330 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); | 330 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
331 voe::Channel* channelPtr = ch.channel(); | 331 voe::Channel* channelPtr = ch.channel(); |
332 if (channelPtr == NULL) { | 332 if (channelPtr == nullptr) { |
333 _shared->SetLastError( | 333 _shared->SetLastError( |
334 VE_CHANNEL_NOT_VALID, kTraceError, | 334 VE_CHANNEL_NOT_VALID, kTraceError, |
335 "GetChannelOutputVolumeScaling() failed to locate channel"); | 335 "GetChannelOutputVolumeScaling() failed to locate channel"); |
336 return -1; | 336 return -1; |
337 } | 337 } |
338 return channelPtr->GetChannelOutputVolumeScaling(scaling); | 338 return channelPtr->GetChannelOutputVolumeScaling(scaling); |
339 } | 339 } |
340 | 340 |
341 int VoEVolumeControlImpl::SetOutputVolumePan(int channel, | 341 int VoEVolumeControlImpl::SetOutputVolumePan(int channel, |
342 float left, | 342 float left, |
(...skipping 21 matching lines...) Expand all Loading... |
364 return -1; | 364 return -1; |
365 } | 365 } |
366 | 366 |
367 if (channel == -1) { | 367 if (channel == -1) { |
368 // Master balance (affectes the signal after output mixing) | 368 // Master balance (affectes the signal after output mixing) |
369 return _shared->output_mixer()->SetOutputVolumePan(left, right); | 369 return _shared->output_mixer()->SetOutputVolumePan(left, right); |
370 } | 370 } |
371 // Per-channel balance (affects the signal before output mixing) | 371 // Per-channel balance (affects the signal before output mixing) |
372 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); | 372 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
373 voe::Channel* channelPtr = ch.channel(); | 373 voe::Channel* channelPtr = ch.channel(); |
374 if (channelPtr == NULL) { | 374 if (channelPtr == nullptr) { |
375 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 375 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
376 "SetOutputVolumePan() failed to locate channel"); | 376 "SetOutputVolumePan() failed to locate channel"); |
377 return -1; | 377 return -1; |
378 } | 378 } |
379 return channelPtr->SetOutputVolumePan(left, right); | 379 return channelPtr->SetOutputVolumePan(left, right); |
380 } | 380 } |
381 | 381 |
382 int VoEVolumeControlImpl::GetOutputVolumePan(int channel, | 382 int VoEVolumeControlImpl::GetOutputVolumePan(int channel, |
383 float& left, | 383 float& left, |
384 float& right) { | 384 float& right) { |
385 if (!_shared->statistics().Initialized()) { | 385 if (!_shared->statistics().Initialized()) { |
386 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 386 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
387 return -1; | 387 return -1; |
388 } | 388 } |
389 | 389 |
390 bool available(false); | 390 bool available(false); |
391 _shared->audio_device()->StereoPlayoutIsAvailable(&available); | 391 _shared->audio_device()->StereoPlayoutIsAvailable(&available); |
392 if (!available) { | 392 if (!available) { |
393 _shared->SetLastError(VE_FUNC_NO_STEREO, kTraceError, | 393 _shared->SetLastError(VE_FUNC_NO_STEREO, kTraceError, |
394 "GetOutputVolumePan() stereo playout not supported"); | 394 "GetOutputVolumePan() stereo playout not supported"); |
395 return -1; | 395 return -1; |
396 } | 396 } |
397 | 397 |
398 if (channel == -1) { | 398 if (channel == -1) { |
399 return _shared->output_mixer()->GetOutputVolumePan(left, right); | 399 return _shared->output_mixer()->GetOutputVolumePan(left, right); |
400 } | 400 } |
401 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); | 401 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
402 voe::Channel* channelPtr = ch.channel(); | 402 voe::Channel* channelPtr = ch.channel(); |
403 if (channelPtr == NULL) { | 403 if (channelPtr == nullptr) { |
404 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 404 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
405 "GetOutputVolumePan() failed to locate channel"); | 405 "GetOutputVolumePan() failed to locate channel"); |
406 return -1; | 406 return -1; |
407 } | 407 } |
408 return channelPtr->GetOutputVolumePan(left, right); | 408 return channelPtr->GetOutputVolumePan(left, right); |
409 } | 409 } |
410 | 410 |
411 } // namespace webrtc | 411 } // namespace webrtc |
OLD | NEW |