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

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

Issue 1607353002: Swap use of CriticalSectionWrapper with rtc::CriticalSection in voice_engine/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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
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/voe_base_impl.h" 11 #include "webrtc/voice_engine/voe_base_impl.h"
12 12
13 #include "webrtc/base/format_macros.h" 13 #include "webrtc/base/format_macros.h"
14 #include "webrtc/base/logging.h" 14 #include "webrtc/base/logging.h"
15 #include "webrtc/common.h" 15 #include "webrtc/common.h"
16 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" 16 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h"
17 #include "webrtc/modules/audio_coding/include/audio_coding_module.h" 17 #include "webrtc/modules/audio_coding/include/audio_coding_module.h"
18 #include "webrtc/modules/audio_device/audio_device_impl.h" 18 #include "webrtc/modules/audio_device/audio_device_impl.h"
19 #include "webrtc/modules/audio_processing/include/audio_processing.h" 19 #include "webrtc/modules/audio_processing/include/audio_processing.h"
20 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
21 #include "webrtc/system_wrappers/include/file_wrapper.h" 20 #include "webrtc/system_wrappers/include/file_wrapper.h"
22 #include "webrtc/voice_engine/channel.h" 21 #include "webrtc/voice_engine/channel.h"
23 #include "webrtc/voice_engine/include/voe_errors.h" 22 #include "webrtc/voice_engine/include/voe_errors.h"
24 #include "webrtc/voice_engine/output_mixer.h" 23 #include "webrtc/voice_engine/output_mixer.h"
25 #include "webrtc/voice_engine/transmit_mixer.h" 24 #include "webrtc/voice_engine/transmit_mixer.h"
26 #include "webrtc/voice_engine/utility.h" 25 #include "webrtc/voice_engine/utility.h"
27 #include "webrtc/voice_engine/voice_engine_impl.h" 26 #include "webrtc/voice_engine/voice_engine_impl.h"
28 27
29 namespace webrtc { 28 namespace webrtc {
30 29
31 VoEBase* VoEBase::GetInterface(VoiceEngine* voiceEngine) { 30 VoEBase* VoEBase::GetInterface(VoiceEngine* voiceEngine) {
32 if (nullptr == voiceEngine) { 31 if (nullptr == voiceEngine) {
33 return nullptr; 32 return nullptr;
34 } 33 }
35 VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine); 34 VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
36 s->AddRef(); 35 s->AddRef();
37 return s; 36 return s;
38 } 37 }
39 38
40 VoEBaseImpl::VoEBaseImpl(voe::SharedData* shared) 39 VoEBaseImpl::VoEBaseImpl(voe::SharedData* shared)
41 : voiceEngineObserverPtr_(nullptr), 40 : voiceEngineObserverPtr_(nullptr),
42 callbackCritSect_(*CriticalSectionWrapper::CreateCriticalSection()),
43 shared_(shared) {} 41 shared_(shared) {}
44 42
45 VoEBaseImpl::~VoEBaseImpl() { 43 VoEBaseImpl::~VoEBaseImpl() {
46 TerminateInternal(); 44 TerminateInternal();
47 delete &callbackCritSect_;
48 } 45 }
49 46
50 void VoEBaseImpl::OnErrorIsReported(const ErrorCode error) { 47 void VoEBaseImpl::OnErrorIsReported(const ErrorCode error) {
51 CriticalSectionScoped cs(&callbackCritSect_); 48 rtc::CritScope cs(&callbackCritSect_);
52 int errCode = 0; 49 int errCode = 0;
53 if (error == AudioDeviceObserver::kRecordingError) { 50 if (error == AudioDeviceObserver::kRecordingError) {
54 errCode = VE_RUNTIME_REC_ERROR; 51 errCode = VE_RUNTIME_REC_ERROR;
55 LOG_F(LS_ERROR) << "VE_RUNTIME_REC_ERROR"; 52 LOG_F(LS_ERROR) << "VE_RUNTIME_REC_ERROR";
56 } else if (error == AudioDeviceObserver::kPlayoutError) { 53 } else if (error == AudioDeviceObserver::kPlayoutError) {
57 errCode = VE_RUNTIME_PLAY_ERROR; 54 errCode = VE_RUNTIME_PLAY_ERROR;
58 LOG_F(LS_ERROR) << "VE_RUNTIME_PLAY_ERROR"; 55 LOG_F(LS_ERROR) << "VE_RUNTIME_PLAY_ERROR";
59 } 56 }
60 if (voiceEngineObserverPtr_) { 57 if (voiceEngineObserverPtr_) {
61 // Deliver callback (-1 <=> no channel dependency) 58 // Deliver callback (-1 <=> no channel dependency)
62 voiceEngineObserverPtr_->CallbackOnError(-1, errCode); 59 voiceEngineObserverPtr_->CallbackOnError(-1, errCode);
63 } 60 }
64 } 61 }
65 62
66 void VoEBaseImpl::OnWarningIsReported(const WarningCode warning) { 63 void VoEBaseImpl::OnWarningIsReported(const WarningCode warning) {
67 CriticalSectionScoped cs(&callbackCritSect_); 64 rtc::CritScope cs(&callbackCritSect_);
68 int warningCode = 0; 65 int warningCode = 0;
69 if (warning == AudioDeviceObserver::kRecordingWarning) { 66 if (warning == AudioDeviceObserver::kRecordingWarning) {
70 warningCode = VE_RUNTIME_REC_WARNING; 67 warningCode = VE_RUNTIME_REC_WARNING;
71 LOG_F(LS_WARNING) << "VE_RUNTIME_REC_WARNING"; 68 LOG_F(LS_WARNING) << "VE_RUNTIME_REC_WARNING";
72 } else if (warning == AudioDeviceObserver::kPlayoutWarning) { 69 } else if (warning == AudioDeviceObserver::kPlayoutWarning) {
73 warningCode = VE_RUNTIME_PLAY_WARNING; 70 warningCode = VE_RUNTIME_PLAY_WARNING;
74 LOG_F(LS_WARNING) << "VE_RUNTIME_PLAY_WARNING"; 71 LOG_F(LS_WARNING) << "VE_RUNTIME_PLAY_WARNING";
75 } 72 }
76 if (voiceEngineObserverPtr_) { 73 if (voiceEngineObserverPtr_) {
77 // Deliver callback (-1 <=> no channel dependency) 74 // Deliver callback (-1 <=> no channel dependency)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 void* audio_data, int64_t* elapsed_time_ms, 166 void* audio_data, int64_t* elapsed_time_ms,
170 int64_t* ntp_time_ms) { 167 int64_t* ntp_time_ms) {
171 assert(bits_per_sample == 16); 168 assert(bits_per_sample == 16);
172 assert(number_of_frames == static_cast<size_t>(sample_rate / 100)); 169 assert(number_of_frames == static_cast<size_t>(sample_rate / 100));
173 170
174 GetPlayoutData(sample_rate, number_of_channels, number_of_frames, false, 171 GetPlayoutData(sample_rate, number_of_channels, number_of_frames, false,
175 audio_data, elapsed_time_ms, ntp_time_ms); 172 audio_data, elapsed_time_ms, ntp_time_ms);
176 } 173 }
177 174
178 int VoEBaseImpl::RegisterVoiceEngineObserver(VoiceEngineObserver& observer) { 175 int VoEBaseImpl::RegisterVoiceEngineObserver(VoiceEngineObserver& observer) {
179 CriticalSectionScoped cs(&callbackCritSect_); 176 rtc::CritScope cs(&callbackCritSect_);
180 if (voiceEngineObserverPtr_) { 177 if (voiceEngineObserverPtr_) {
181 shared_->SetLastError( 178 shared_->SetLastError(
182 VE_INVALID_OPERATION, kTraceError, 179 VE_INVALID_OPERATION, kTraceError,
183 "RegisterVoiceEngineObserver() observer already enabled"); 180 "RegisterVoiceEngineObserver() observer already enabled");
184 return -1; 181 return -1;
185 } 182 }
186 183
187 // Register the observer in all active channels 184 // Register the observer in all active channels
188 for (voe::ChannelManager::Iterator it(&shared_->channel_manager()); 185 for (voe::ChannelManager::Iterator it(&shared_->channel_manager());
189 it.IsValid(); it.Increment()) { 186 it.IsValid(); it.Increment()) {
190 it.GetChannel()->RegisterVoiceEngineObserver(observer); 187 it.GetChannel()->RegisterVoiceEngineObserver(observer);
191 } 188 }
192 189
193 shared_->transmit_mixer()->RegisterVoiceEngineObserver(observer); 190 shared_->transmit_mixer()->RegisterVoiceEngineObserver(observer);
194 voiceEngineObserverPtr_ = &observer; 191 voiceEngineObserverPtr_ = &observer;
195 return 0; 192 return 0;
196 } 193 }
197 194
198 int VoEBaseImpl::DeRegisterVoiceEngineObserver() { 195 int VoEBaseImpl::DeRegisterVoiceEngineObserver() {
199 CriticalSectionScoped cs(&callbackCritSect_); 196 rtc::CritScope cs(&callbackCritSect_);
200 if (!voiceEngineObserverPtr_) { 197 if (!voiceEngineObserverPtr_) {
201 shared_->SetLastError( 198 shared_->SetLastError(
202 VE_INVALID_OPERATION, kTraceError, 199 VE_INVALID_OPERATION, kTraceError,
203 "DeRegisterVoiceEngineObserver() observer already disabled"); 200 "DeRegisterVoiceEngineObserver() observer already disabled");
204 return 0; 201 return 0;
205 } 202 }
206 voiceEngineObserverPtr_ = nullptr; 203 voiceEngineObserverPtr_ = nullptr;
207 204
208 // Deregister the observer in all active channels 205 // Deregister the observer in all active channels
209 for (voe::ChannelManager::Iterator it(&shared_->channel_manager()); 206 for (voe::ChannelManager::Iterator it(&shared_->channel_manager());
210 it.IsValid(); it.Increment()) { 207 it.IsValid(); it.Increment()) {
211 it.GetChannel()->DeRegisterVoiceEngineObserver(); 208 it.GetChannel()->DeRegisterVoiceEngineObserver();
212 } 209 }
213 210
214 return 0; 211 return 0;
215 } 212 }
216 213
217 int VoEBaseImpl::Init(AudioDeviceModule* external_adm, 214 int VoEBaseImpl::Init(AudioDeviceModule* external_adm,
218 AudioProcessing* audioproc) { 215 AudioProcessing* audioproc) {
219 CriticalSectionScoped cs(shared_->crit_sec()); 216 rtc::CritScope cs(shared_->crit_sec());
220 WebRtcSpl_Init(); 217 WebRtcSpl_Init();
221 if (shared_->statistics().Initialized()) { 218 if (shared_->statistics().Initialized()) {
222 return 0; 219 return 0;
223 } 220 }
224 if (shared_->process_thread()) { 221 if (shared_->process_thread()) {
225 shared_->process_thread()->Start(); 222 shared_->process_thread()->Start();
226 } 223 }
227 224
228 // Create an internal ADM if the user has not added an external 225 // Create an internal ADM if the user has not added an external
229 // ADM implementation as input to Init(). 226 // ADM implementation as input to Init().
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR); 372 shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR);
376 // TODO(ajm): No error return here due to 373 // TODO(ajm): No error return here due to
377 // https://code.google.com/p/webrtc/issues/detail?id=1464 374 // https://code.google.com/p/webrtc/issues/detail?id=1464
378 } 375 }
379 #endif 376 #endif
380 377
381 return shared_->statistics().SetInitialized(); 378 return shared_->statistics().SetInitialized();
382 } 379 }
383 380
384 int VoEBaseImpl::Terminate() { 381 int VoEBaseImpl::Terminate() {
385 CriticalSectionScoped cs(shared_->crit_sec()); 382 rtc::CritScope cs(shared_->crit_sec());
386 return TerminateInternal(); 383 return TerminateInternal();
387 } 384 }
388 385
389 int VoEBaseImpl::CreateChannel() { 386 int VoEBaseImpl::CreateChannel() {
390 CriticalSectionScoped cs(shared_->crit_sec()); 387 rtc::CritScope cs(shared_->crit_sec());
391 if (!shared_->statistics().Initialized()) { 388 if (!shared_->statistics().Initialized()) {
392 shared_->SetLastError(VE_NOT_INITED, kTraceError); 389 shared_->SetLastError(VE_NOT_INITED, kTraceError);
393 return -1; 390 return -1;
394 } 391 }
395 392
396 voe::ChannelOwner channel_owner = shared_->channel_manager().CreateChannel(); 393 voe::ChannelOwner channel_owner = shared_->channel_manager().CreateChannel();
397 return InitializeChannel(&channel_owner); 394 return InitializeChannel(&channel_owner);
398 } 395 }
399 396
400 int VoEBaseImpl::CreateChannel(const Config& config) { 397 int VoEBaseImpl::CreateChannel(const Config& config) {
401 CriticalSectionScoped cs(shared_->crit_sec()); 398 rtc::CritScope cs(shared_->crit_sec());
402 if (!shared_->statistics().Initialized()) { 399 if (!shared_->statistics().Initialized()) {
403 shared_->SetLastError(VE_NOT_INITED, kTraceError); 400 shared_->SetLastError(VE_NOT_INITED, kTraceError);
404 return -1; 401 return -1;
405 } 402 }
406 voe::ChannelOwner channel_owner = 403 voe::ChannelOwner channel_owner =
407 shared_->channel_manager().CreateChannel(config); 404 shared_->channel_manager().CreateChannel(config);
408 return InitializeChannel(&channel_owner); 405 return InitializeChannel(&channel_owner);
409 } 406 }
410 407
411 int VoEBaseImpl::InitializeChannel(voe::ChannelOwner* channel_owner) { 408 int VoEBaseImpl::InitializeChannel(voe::ChannelOwner* channel_owner) {
(...skipping 15 matching lines...) Expand all
427 "CreateChannel() failed to initialize channel. Destroying" 424 "CreateChannel() failed to initialize channel. Destroying"
428 " channel."); 425 " channel.");
429 shared_->channel_manager().DestroyChannel( 426 shared_->channel_manager().DestroyChannel(
430 channel_owner->channel()->ChannelId()); 427 channel_owner->channel()->ChannelId());
431 return -1; 428 return -1;
432 } 429 }
433 return channel_owner->channel()->ChannelId(); 430 return channel_owner->channel()->ChannelId();
434 } 431 }
435 432
436 int VoEBaseImpl::DeleteChannel(int channel) { 433 int VoEBaseImpl::DeleteChannel(int channel) {
437 CriticalSectionScoped cs(shared_->crit_sec()); 434 rtc::CritScope cs(shared_->crit_sec());
438 if (!shared_->statistics().Initialized()) { 435 if (!shared_->statistics().Initialized()) {
439 shared_->SetLastError(VE_NOT_INITED, kTraceError); 436 shared_->SetLastError(VE_NOT_INITED, kTraceError);
440 return -1; 437 return -1;
441 } 438 }
442 439
443 { 440 {
444 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); 441 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel);
445 voe::Channel* channelPtr = ch.channel(); 442 voe::Channel* channelPtr = ch.channel();
446 if (channelPtr == nullptr) { 443 if (channelPtr == nullptr) {
447 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, 444 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
448 "DeleteChannel() failed to locate channel"); 445 "DeleteChannel() failed to locate channel");
449 return -1; 446 return -1;
450 } 447 }
451 } 448 }
452 449
453 shared_->channel_manager().DestroyChannel(channel); 450 shared_->channel_manager().DestroyChannel(channel);
454 if (StopSend() != 0) { 451 if (StopSend() != 0) {
455 return -1; 452 return -1;
456 } 453 }
457 if (StopPlayout() != 0) { 454 if (StopPlayout() != 0) {
458 return -1; 455 return -1;
459 } 456 }
460 return 0; 457 return 0;
461 } 458 }
462 459
463 int VoEBaseImpl::StartReceive(int channel) { 460 int VoEBaseImpl::StartReceive(int channel) {
464 CriticalSectionScoped cs(shared_->crit_sec()); 461 rtc::CritScope cs(shared_->crit_sec());
465 if (!shared_->statistics().Initialized()) { 462 if (!shared_->statistics().Initialized()) {
466 shared_->SetLastError(VE_NOT_INITED, kTraceError); 463 shared_->SetLastError(VE_NOT_INITED, kTraceError);
467 return -1; 464 return -1;
468 } 465 }
469 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); 466 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel);
470 voe::Channel* channelPtr = ch.channel(); 467 voe::Channel* channelPtr = ch.channel();
471 if (channelPtr == nullptr) { 468 if (channelPtr == nullptr) {
472 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, 469 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
473 "StartReceive() failed to locate channel"); 470 "StartReceive() failed to locate channel");
474 return -1; 471 return -1;
475 } 472 }
476 return channelPtr->StartReceiving(); 473 return channelPtr->StartReceiving();
477 } 474 }
478 475
479 int VoEBaseImpl::StopReceive(int channel) { 476 int VoEBaseImpl::StopReceive(int channel) {
480 CriticalSectionScoped cs(shared_->crit_sec()); 477 rtc::CritScope cs(shared_->crit_sec());
481 if (!shared_->statistics().Initialized()) { 478 if (!shared_->statistics().Initialized()) {
482 shared_->SetLastError(VE_NOT_INITED, kTraceError); 479 shared_->SetLastError(VE_NOT_INITED, kTraceError);
483 return -1; 480 return -1;
484 } 481 }
485 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); 482 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel);
486 voe::Channel* channelPtr = ch.channel(); 483 voe::Channel* channelPtr = ch.channel();
487 if (channelPtr == nullptr) { 484 if (channelPtr == nullptr) {
488 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, 485 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
489 "SetLocalReceiver() failed to locate channel"); 486 "SetLocalReceiver() failed to locate channel");
490 return -1; 487 return -1;
491 } 488 }
492 return channelPtr->StopReceiving(); 489 return channelPtr->StopReceiving();
493 } 490 }
494 491
495 int VoEBaseImpl::StartPlayout(int channel) { 492 int VoEBaseImpl::StartPlayout(int channel) {
496 CriticalSectionScoped cs(shared_->crit_sec()); 493 rtc::CritScope cs(shared_->crit_sec());
497 if (!shared_->statistics().Initialized()) { 494 if (!shared_->statistics().Initialized()) {
498 shared_->SetLastError(VE_NOT_INITED, kTraceError); 495 shared_->SetLastError(VE_NOT_INITED, kTraceError);
499 return -1; 496 return -1;
500 } 497 }
501 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); 498 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel);
502 voe::Channel* channelPtr = ch.channel(); 499 voe::Channel* channelPtr = ch.channel();
503 if (channelPtr == nullptr) { 500 if (channelPtr == nullptr) {
504 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, 501 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
505 "StartPlayout() failed to locate channel"); 502 "StartPlayout() failed to locate channel");
506 return -1; 503 return -1;
507 } 504 }
508 if (channelPtr->Playing()) { 505 if (channelPtr->Playing()) {
509 return 0; 506 return 0;
510 } 507 }
511 if (StartPlayout() != 0) { 508 if (StartPlayout() != 0) {
512 shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError, 509 shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError,
513 "StartPlayout() failed to start playout"); 510 "StartPlayout() failed to start playout");
514 return -1; 511 return -1;
515 } 512 }
516 return channelPtr->StartPlayout(); 513 return channelPtr->StartPlayout();
517 } 514 }
518 515
519 int VoEBaseImpl::StopPlayout(int channel) { 516 int VoEBaseImpl::StopPlayout(int channel) {
520 CriticalSectionScoped cs(shared_->crit_sec()); 517 rtc::CritScope cs(shared_->crit_sec());
521 if (!shared_->statistics().Initialized()) { 518 if (!shared_->statistics().Initialized()) {
522 shared_->SetLastError(VE_NOT_INITED, kTraceError); 519 shared_->SetLastError(VE_NOT_INITED, kTraceError);
523 return -1; 520 return -1;
524 } 521 }
525 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); 522 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel);
526 voe::Channel* channelPtr = ch.channel(); 523 voe::Channel* channelPtr = ch.channel();
527 if (channelPtr == nullptr) { 524 if (channelPtr == nullptr) {
528 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, 525 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
529 "StopPlayout() failed to locate channel"); 526 "StopPlayout() failed to locate channel");
530 return -1; 527 return -1;
531 } 528 }
532 if (channelPtr->StopPlayout() != 0) { 529 if (channelPtr->StopPlayout() != 0) {
533 LOG_F(LS_WARNING) << "StopPlayout() failed to stop playout for channel " 530 LOG_F(LS_WARNING) << "StopPlayout() failed to stop playout for channel "
534 << channel; 531 << channel;
535 } 532 }
536 return StopPlayout(); 533 return StopPlayout();
537 } 534 }
538 535
539 int VoEBaseImpl::StartSend(int channel) { 536 int VoEBaseImpl::StartSend(int channel) {
540 CriticalSectionScoped cs(shared_->crit_sec()); 537 rtc::CritScope cs(shared_->crit_sec());
541 if (!shared_->statistics().Initialized()) { 538 if (!shared_->statistics().Initialized()) {
542 shared_->SetLastError(VE_NOT_INITED, kTraceError); 539 shared_->SetLastError(VE_NOT_INITED, kTraceError);
543 return -1; 540 return -1;
544 } 541 }
545 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); 542 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel);
546 voe::Channel* channelPtr = ch.channel(); 543 voe::Channel* channelPtr = ch.channel();
547 if (channelPtr == nullptr) { 544 if (channelPtr == nullptr) {
548 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, 545 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
549 "StartSend() failed to locate channel"); 546 "StartSend() failed to locate channel");
550 return -1; 547 return -1;
551 } 548 }
552 if (channelPtr->Sending()) { 549 if (channelPtr->Sending()) {
553 return 0; 550 return 0;
554 } 551 }
555 if (StartSend() != 0) { 552 if (StartSend() != 0) {
556 shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError, 553 shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError,
557 "StartSend() failed to start recording"); 554 "StartSend() failed to start recording");
558 return -1; 555 return -1;
559 } 556 }
560 return channelPtr->StartSend(); 557 return channelPtr->StartSend();
561 } 558 }
562 559
563 int VoEBaseImpl::StopSend(int channel) { 560 int VoEBaseImpl::StopSend(int channel) {
564 CriticalSectionScoped cs(shared_->crit_sec()); 561 rtc::CritScope cs(shared_->crit_sec());
565 if (!shared_->statistics().Initialized()) { 562 if (!shared_->statistics().Initialized()) {
566 shared_->SetLastError(VE_NOT_INITED, kTraceError); 563 shared_->SetLastError(VE_NOT_INITED, kTraceError);
567 return -1; 564 return -1;
568 } 565 }
569 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); 566 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel);
570 voe::Channel* channelPtr = ch.channel(); 567 voe::Channel* channelPtr = ch.channel();
571 if (channelPtr == nullptr) { 568 if (channelPtr == nullptr) {
572 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, 569 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
573 "StopSend() failed to locate channel"); 570 "StopSend() failed to locate channel");
574 return -1; 571 return -1;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 // Deliver audio (PCM) samples to the ADM 785 // Deliver audio (PCM) samples to the ADM
789 memcpy(audio_data, audioFrame_.data_, 786 memcpy(audio_data, audioFrame_.data_,
790 sizeof(int16_t) * number_of_frames * number_of_channels); 787 sizeof(int16_t) * number_of_frames * number_of_channels);
791 788
792 *elapsed_time_ms = audioFrame_.elapsed_time_ms_; 789 *elapsed_time_ms = audioFrame_.elapsed_time_ms_;
793 *ntp_time_ms = audioFrame_.ntp_time_ms_; 790 *ntp_time_ms = audioFrame_.ntp_time_ms_;
794 } 791 }
795 792
796 int VoEBaseImpl::AssociateSendChannel(int channel, 793 int VoEBaseImpl::AssociateSendChannel(int channel,
797 int accociate_send_channel) { 794 int accociate_send_channel) {
798 CriticalSectionScoped cs(shared_->crit_sec()); 795 rtc::CritScope cs(shared_->crit_sec());
799 796
800 if (!shared_->statistics().Initialized()) { 797 if (!shared_->statistics().Initialized()) {
801 shared_->SetLastError(VE_NOT_INITED, kTraceError); 798 shared_->SetLastError(VE_NOT_INITED, kTraceError);
802 return -1; 799 return -1;
803 } 800 }
804 801
805 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); 802 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel);
806 voe::Channel* channel_ptr = ch.channel(); 803 voe::Channel* channel_ptr = ch.channel();
807 if (channel_ptr == NULL) { 804 if (channel_ptr == NULL) {
808 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, 805 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
809 "AssociateSendChannel() failed to locate channel"); 806 "AssociateSendChannel() failed to locate channel");
810 return -1; 807 return -1;
811 } 808 }
812 809
813 ch = shared_->channel_manager().GetChannel(accociate_send_channel); 810 ch = shared_->channel_manager().GetChannel(accociate_send_channel);
814 voe::Channel* accociate_send_channel_ptr = ch.channel(); 811 voe::Channel* accociate_send_channel_ptr = ch.channel();
815 if (accociate_send_channel_ptr == NULL) { 812 if (accociate_send_channel_ptr == NULL) {
816 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, 813 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
817 "AssociateSendChannel() failed to locate accociate_send_channel"); 814 "AssociateSendChannel() failed to locate accociate_send_channel");
818 return -1; 815 return -1;
819 } 816 }
820 817
821 channel_ptr->set_associate_send_channel(ch); 818 channel_ptr->set_associate_send_channel(ch);
822 return 0; 819 return 0;
823 } 820 }
824 821
825 } // namespace webrtc 822 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698