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

Side by Side Diff: webrtc/modules/audio_coding/acm2/audio_coding_module_unittest_oldapi.cc

Issue 1610073003: Switch CriticalSectionWrapper->rtc::CriticalSection in modules/audio_coding. (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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 <stdio.h> 11 #include <stdio.h>
12 #include <string.h> 12 #include <string.h>
13 #include <vector> 13 #include <vector>
14 14
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "webrtc/base/criticalsection.h"
16 #include "webrtc/base/md5digest.h" 17 #include "webrtc/base/md5digest.h"
17 #include "webrtc/base/platform_thread.h" 18 #include "webrtc/base/platform_thread.h"
18 #include "webrtc/base/scoped_ptr.h" 19 #include "webrtc/base/scoped_ptr.h"
19 #include "webrtc/base/thread_annotations.h" 20 #include "webrtc/base/thread_annotations.h"
21 #include "webrtc/modules/audio_coding/acm2/acm_receive_test_oldapi.h"
22 #include "webrtc/modules/audio_coding/acm2/acm_send_test_oldapi.h"
20 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" 23 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
21 #include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h" 24 #include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h"
22 #include "webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h" 25 #include "webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h"
23 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isa c.h" 26 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isa c.h"
24 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h" 27 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h"
25 #include "webrtc/modules/audio_coding/acm2/acm_receive_test_oldapi.h"
26 #include "webrtc/modules/audio_coding/acm2/acm_send_test_oldapi.h"
27 #include "webrtc/modules/audio_coding/include/audio_coding_module.h" 28 #include "webrtc/modules/audio_coding/include/audio_coding_module.h"
28 #include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h" 29 #include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
29 #include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h" 30 #include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h"
30 #include "webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h" 31 #include "webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h"
31 #include "webrtc/modules/audio_coding/neteq/tools/audio_checksum.h" 32 #include "webrtc/modules/audio_coding/neteq/tools/audio_checksum.h"
32 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" 33 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h"
33 #include "webrtc/modules/audio_coding/neteq/tools/constant_pcm_packet_source.h" 34 #include "webrtc/modules/audio_coding/neteq/tools/constant_pcm_packet_source.h"
34 #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h" 35 #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h"
35 #include "webrtc/modules/audio_coding/neteq/tools/output_audio_file.h" 36 #include "webrtc/modules/audio_coding/neteq/tools/output_audio_file.h"
36 #include "webrtc/modules/audio_coding/neteq/tools/packet.h" 37 #include "webrtc/modules/audio_coding/neteq/tools/packet.h"
37 #include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h" 38 #include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h"
38 #include "webrtc/modules/include/module_common_types.h" 39 #include "webrtc/modules/include/module_common_types.h"
39 #include "webrtc/system_wrappers/include/clock.h" 40 #include "webrtc/system_wrappers/include/clock.h"
40 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
41 #include "webrtc/system_wrappers/include/event_wrapper.h" 41 #include "webrtc/system_wrappers/include/event_wrapper.h"
42 #include "webrtc/system_wrappers/include/sleep.h" 42 #include "webrtc/system_wrappers/include/sleep.h"
43 #include "webrtc/test/testsupport/fileutils.h" 43 #include "webrtc/test/testsupport/fileutils.h"
44 44
45 using ::testing::AtLeast; 45 using ::testing::AtLeast;
46 using ::testing::Invoke; 46 using ::testing::Invoke;
47 using ::testing::_; 47 using ::testing::_;
48 48
49 namespace webrtc { 49 namespace webrtc {
50 50
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 int samples_per_packet_; 87 int samples_per_packet_;
88 uint8_t payload_type_; 88 uint8_t payload_type_;
89 }; 89 };
90 90
91 class PacketizationCallbackStubOldApi : public AudioPacketizationCallback { 91 class PacketizationCallbackStubOldApi : public AudioPacketizationCallback {
92 public: 92 public:
93 PacketizationCallbackStubOldApi() 93 PacketizationCallbackStubOldApi()
94 : num_calls_(0), 94 : num_calls_(0),
95 last_frame_type_(kEmptyFrame), 95 last_frame_type_(kEmptyFrame),
96 last_payload_type_(-1), 96 last_payload_type_(-1),
97 last_timestamp_(0), 97 last_timestamp_(0) {}
98 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()) {}
99 98
100 int32_t SendData(FrameType frame_type, 99 int32_t SendData(FrameType frame_type,
101 uint8_t payload_type, 100 uint8_t payload_type,
102 uint32_t timestamp, 101 uint32_t timestamp,
103 const uint8_t* payload_data, 102 const uint8_t* payload_data,
104 size_t payload_len_bytes, 103 size_t payload_len_bytes,
105 const RTPFragmentationHeader* fragmentation) override { 104 const RTPFragmentationHeader* fragmentation) override {
106 CriticalSectionScoped lock(crit_sect_.get()); 105 rtc::CritScope lock(&crit_sect_);
107 ++num_calls_; 106 ++num_calls_;
108 last_frame_type_ = frame_type; 107 last_frame_type_ = frame_type;
109 last_payload_type_ = payload_type; 108 last_payload_type_ = payload_type;
110 last_timestamp_ = timestamp; 109 last_timestamp_ = timestamp;
111 last_payload_vec_.assign(payload_data, payload_data + payload_len_bytes); 110 last_payload_vec_.assign(payload_data, payload_data + payload_len_bytes);
112 return 0; 111 return 0;
113 } 112 }
114 113
115 int num_calls() const { 114 int num_calls() const {
116 CriticalSectionScoped lock(crit_sect_.get()); 115 rtc::CritScope lock(&crit_sect_);
117 return num_calls_; 116 return num_calls_;
118 } 117 }
119 118
120 int last_payload_len_bytes() const { 119 int last_payload_len_bytes() const {
121 CriticalSectionScoped lock(crit_sect_.get()); 120 rtc::CritScope lock(&crit_sect_);
122 return last_payload_vec_.size(); 121 return last_payload_vec_.size();
123 } 122 }
124 123
125 FrameType last_frame_type() const { 124 FrameType last_frame_type() const {
126 CriticalSectionScoped lock(crit_sect_.get()); 125 rtc::CritScope lock(&crit_sect_);
127 return last_frame_type_; 126 return last_frame_type_;
128 } 127 }
129 128
130 int last_payload_type() const { 129 int last_payload_type() const {
131 CriticalSectionScoped lock(crit_sect_.get()); 130 rtc::CritScope lock(&crit_sect_);
132 return last_payload_type_; 131 return last_payload_type_;
133 } 132 }
134 133
135 uint32_t last_timestamp() const { 134 uint32_t last_timestamp() const {
136 CriticalSectionScoped lock(crit_sect_.get()); 135 rtc::CritScope lock(&crit_sect_);
137 return last_timestamp_; 136 return last_timestamp_;
138 } 137 }
139 138
140 void SwapBuffers(std::vector<uint8_t>* payload) { 139 void SwapBuffers(std::vector<uint8_t>* payload) {
141 CriticalSectionScoped lock(crit_sect_.get()); 140 rtc::CritScope lock(&crit_sect_);
142 last_payload_vec_.swap(*payload); 141 last_payload_vec_.swap(*payload);
143 } 142 }
144 143
145 private: 144 private:
146 int num_calls_ GUARDED_BY(crit_sect_); 145 int num_calls_ GUARDED_BY(crit_sect_);
147 FrameType last_frame_type_ GUARDED_BY(crit_sect_); 146 FrameType last_frame_type_ GUARDED_BY(crit_sect_);
148 int last_payload_type_ GUARDED_BY(crit_sect_); 147 int last_payload_type_ GUARDED_BY(crit_sect_);
149 uint32_t last_timestamp_ GUARDED_BY(crit_sect_); 148 uint32_t last_timestamp_ GUARDED_BY(crit_sect_);
150 std::vector<uint8_t> last_payload_vec_ GUARDED_BY(crit_sect_); 149 std::vector<uint8_t> last_payload_vec_ GUARDED_BY(crit_sect_);
151 const rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_; 150 mutable rtc::CriticalSection crit_sect_;
152 }; 151 };
153 152
154 class AudioCodingModuleTestOldApi : public ::testing::Test { 153 class AudioCodingModuleTestOldApi : public ::testing::Test {
155 protected: 154 protected:
156 AudioCodingModuleTestOldApi() 155 AudioCodingModuleTestOldApi()
157 : id_(1), 156 : id_(1),
158 rtp_utility_(new RtpUtility(kFrameSizeSamples, kPayloadType)), 157 rtp_utility_(new RtpUtility(kFrameSizeSamples, kPayloadType)),
159 clock_(Clock::GetRealTimeClock()) {} 158 clock_(Clock::GetRealTimeClock()) {}
160 159
161 ~AudioCodingModuleTestOldApi() {} 160 ~AudioCodingModuleTestOldApi() {}
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 461
463 AudioCodingModuleMtTestOldApi() 462 AudioCodingModuleMtTestOldApi()
464 : AudioCodingModuleTestOldApi(), 463 : AudioCodingModuleTestOldApi(),
465 send_thread_(CbSendThread, this, "send"), 464 send_thread_(CbSendThread, this, "send"),
466 insert_packet_thread_(CbInsertPacketThread, this, "insert_packet"), 465 insert_packet_thread_(CbInsertPacketThread, this, "insert_packet"),
467 pull_audio_thread_(CbPullAudioThread, this, "pull_audio"), 466 pull_audio_thread_(CbPullAudioThread, this, "pull_audio"),
468 test_complete_(EventWrapper::Create()), 467 test_complete_(EventWrapper::Create()),
469 send_count_(0), 468 send_count_(0),
470 insert_packet_count_(0), 469 insert_packet_count_(0),
471 pull_audio_count_(0), 470 pull_audio_count_(0),
472 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
473 next_insert_packet_time_ms_(0), 471 next_insert_packet_time_ms_(0),
474 fake_clock_(new SimulatedClock(0)) { 472 fake_clock_(new SimulatedClock(0)) {
475 clock_ = fake_clock_.get(); 473 clock_ = fake_clock_.get();
476 } 474 }
477 475
478 void SetUp() { 476 void SetUp() {
479 AudioCodingModuleTestOldApi::SetUp(); 477 AudioCodingModuleTestOldApi::SetUp();
480 RegisterCodec(); // Must be called before the threads start below. 478 RegisterCodec(); // Must be called before the threads start below.
481 StartThreads(); 479 StartThreads();
482 } 480 }
(...skipping 13 matching lines...) Expand all
496 send_thread_.Stop(); 494 send_thread_.Stop();
497 insert_packet_thread_.Stop(); 495 insert_packet_thread_.Stop();
498 } 496 }
499 497
500 EventTypeWrapper RunTest() { 498 EventTypeWrapper RunTest() {
501 return test_complete_->Wait(10 * 60 * 1000); // 10 minutes' timeout. 499 return test_complete_->Wait(10 * 60 * 1000); // 10 minutes' timeout.
502 } 500 }
503 501
504 virtual bool TestDone() { 502 virtual bool TestDone() {
505 if (packet_cb_.num_calls() > kNumPackets) { 503 if (packet_cb_.num_calls() > kNumPackets) {
506 CriticalSectionScoped lock(crit_sect_.get()); 504 rtc::CritScope lock(&crit_sect_);
507 if (pull_audio_count_ > kNumPullCalls) { 505 if (pull_audio_count_ > kNumPullCalls) {
508 // Both conditions for completion are met. End the test. 506 // Both conditions for completion are met. End the test.
509 return true; 507 return true;
510 } 508 }
511 } 509 }
512 return false; 510 return false;
513 } 511 }
514 512
515 static bool CbSendThread(void* context) { 513 static bool CbSendThread(void* context) {
516 return reinterpret_cast<AudioCodingModuleMtTestOldApi*>(context) 514 return reinterpret_cast<AudioCodingModuleMtTestOldApi*>(context)
(...skipping 17 matching lines...) Expand all
534 } 532 }
535 533
536 static bool CbInsertPacketThread(void* context) { 534 static bool CbInsertPacketThread(void* context) {
537 return reinterpret_cast<AudioCodingModuleMtTestOldApi*>(context) 535 return reinterpret_cast<AudioCodingModuleMtTestOldApi*>(context)
538 ->CbInsertPacketImpl(); 536 ->CbInsertPacketImpl();
539 } 537 }
540 538
541 bool CbInsertPacketImpl() { 539 bool CbInsertPacketImpl() {
542 SleepMs(1); 540 SleepMs(1);
543 { 541 {
544 CriticalSectionScoped lock(crit_sect_.get()); 542 rtc::CritScope lock(&crit_sect_);
545 if (clock_->TimeInMilliseconds() < next_insert_packet_time_ms_) { 543 if (clock_->TimeInMilliseconds() < next_insert_packet_time_ms_) {
546 return true; 544 return true;
547 } 545 }
548 next_insert_packet_time_ms_ += 10; 546 next_insert_packet_time_ms_ += 10;
549 } 547 }
550 // Now we're not holding the crit sect when calling ACM. 548 // Now we're not holding the crit sect when calling ACM.
551 ++insert_packet_count_; 549 ++insert_packet_count_;
552 InsertPacket(); 550 InsertPacket();
553 return true; 551 return true;
554 } 552 }
555 553
556 static bool CbPullAudioThread(void* context) { 554 static bool CbPullAudioThread(void* context) {
557 return reinterpret_cast<AudioCodingModuleMtTestOldApi*>(context) 555 return reinterpret_cast<AudioCodingModuleMtTestOldApi*>(context)
558 ->CbPullAudioImpl(); 556 ->CbPullAudioImpl();
559 } 557 }
560 558
561 bool CbPullAudioImpl() { 559 bool CbPullAudioImpl() {
562 SleepMs(1); 560 SleepMs(1);
563 { 561 {
564 CriticalSectionScoped lock(crit_sect_.get()); 562 rtc::CritScope lock(&crit_sect_);
565 // Don't let the insert thread fall behind. 563 // Don't let the insert thread fall behind.
566 if (next_insert_packet_time_ms_ < clock_->TimeInMilliseconds()) { 564 if (next_insert_packet_time_ms_ < clock_->TimeInMilliseconds()) {
567 return true; 565 return true;
568 } 566 }
569 ++pull_audio_count_; 567 ++pull_audio_count_;
570 } 568 }
571 // Now we're not holding the crit sect when calling ACM. 569 // Now we're not holding the crit sect when calling ACM.
572 PullAudio(); 570 PullAudio();
573 fake_clock_->AdvanceTimeMilliseconds(10); 571 fake_clock_->AdvanceTimeMilliseconds(10);
574 return true; 572 return true;
575 } 573 }
576 574
577 rtc::PlatformThread send_thread_; 575 rtc::PlatformThread send_thread_;
578 rtc::PlatformThread insert_packet_thread_; 576 rtc::PlatformThread insert_packet_thread_;
579 rtc::PlatformThread pull_audio_thread_; 577 rtc::PlatformThread pull_audio_thread_;
580 const rtc::scoped_ptr<EventWrapper> test_complete_; 578 const rtc::scoped_ptr<EventWrapper> test_complete_;
581 int send_count_; 579 int send_count_;
582 int insert_packet_count_; 580 int insert_packet_count_;
583 int pull_audio_count_ GUARDED_BY(crit_sect_); 581 int pull_audio_count_ GUARDED_BY(crit_sect_);
584 const rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_; 582 mutable rtc::CriticalSection crit_sect_;
585 int64_t next_insert_packet_time_ms_ GUARDED_BY(crit_sect_); 583 int64_t next_insert_packet_time_ms_ GUARDED_BY(crit_sect_);
586 rtc::scoped_ptr<SimulatedClock> fake_clock_; 584 rtc::scoped_ptr<SimulatedClock> fake_clock_;
587 }; 585 };
588 586
589 #if defined(WEBRTC_IOS) 587 #if defined(WEBRTC_IOS)
590 #define MAYBE_DoTest DISABLED_DoTest 588 #define MAYBE_DoTest DISABLED_DoTest
591 #else 589 #else
592 #define MAYBE_DoTest DoTest 590 #define MAYBE_DoTest DoTest
593 #endif 591 #endif
594 TEST_F(AudioCodingModuleMtTestOldApi, MAYBE_DoTest) { 592 TEST_F(AudioCodingModuleMtTestOldApi, MAYBE_DoTest) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 672
675 // Override the verification function with no-op, since iSAC produces variable 673 // Override the verification function with no-op, since iSAC produces variable
676 // payload sizes. 674 // payload sizes.
677 void VerifyEncoding() override {} 675 void VerifyEncoding() override {}
678 676
679 // This method is the same as AudioCodingModuleMtTestOldApi::TestDone(), but 677 // This method is the same as AudioCodingModuleMtTestOldApi::TestDone(), but
680 // here it is using the constants defined in this class (i.e., shorter test 678 // here it is using the constants defined in this class (i.e., shorter test
681 // run). 679 // run).
682 virtual bool TestDone() { 680 virtual bool TestDone() {
683 if (packet_cb_.num_calls() > kNumPackets) { 681 if (packet_cb_.num_calls() > kNumPackets) {
684 CriticalSectionScoped lock(crit_sect_.get()); 682 rtc::CritScope lock(&crit_sect_);
685 if (pull_audio_count_ > kNumPullCalls) { 683 if (pull_audio_count_ > kNumPullCalls) {
686 // Both conditions for completion are met. End the test. 684 // Both conditions for completion are met. End the test.
687 return true; 685 return true;
688 } 686 }
689 } 687 }
690 return false; 688 return false;
691 } 689 }
692 690
693 int last_packet_number_; 691 int last_packet_number_;
694 std::vector<uint8_t> last_payload_vec_; 692 std::vector<uint8_t> last_payload_vec_;
(...skipping 18 matching lines...) Expand all
713 static const int kPacketSizeMs = 30; 711 static const int kPacketSizeMs = 30;
714 static const int kPacketSizeSamples = kPacketSizeMs * 16; 712 static const int kPacketSizeSamples = kPacketSizeMs * 16;
715 713
716 AcmReRegisterIsacMtTestOldApi() 714 AcmReRegisterIsacMtTestOldApi()
717 : AudioCodingModuleTestOldApi(), 715 : AudioCodingModuleTestOldApi(),
718 receive_thread_(CbReceiveThread, this, "receive"), 716 receive_thread_(CbReceiveThread, this, "receive"),
719 codec_registration_thread_(CbCodecRegistrationThread, 717 codec_registration_thread_(CbCodecRegistrationThread,
720 this, 718 this,
721 "codec_registration"), 719 "codec_registration"),
722 test_complete_(EventWrapper::Create()), 720 test_complete_(EventWrapper::Create()),
723 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
724 codec_registered_(false), 721 codec_registered_(false),
725 receive_packet_count_(0), 722 receive_packet_count_(0),
726 next_insert_packet_time_ms_(0), 723 next_insert_packet_time_ms_(0),
727 fake_clock_(new SimulatedClock(0)) { 724 fake_clock_(new SimulatedClock(0)) {
728 AudioEncoderIsac::Config config; 725 AudioEncoderIsac::Config config;
729 config.payload_type = kPayloadType; 726 config.payload_type = kPayloadType;
730 isac_encoder_.reset(new AudioEncoderIsac(config)); 727 isac_encoder_.reset(new AudioEncoderIsac(config));
731 clock_ = fake_clock_.get(); 728 clock_ = fake_clock_.get();
732 } 729 }
733 730
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 return reinterpret_cast<AcmReRegisterIsacMtTestOldApi*>(context) 771 return reinterpret_cast<AcmReRegisterIsacMtTestOldApi*>(context)
775 ->CbReceiveImpl(); 772 ->CbReceiveImpl();
776 } 773 }
777 774
778 bool CbReceiveImpl() { 775 bool CbReceiveImpl() {
779 SleepMs(1); 776 SleepMs(1);
780 const size_t max_encoded_bytes = isac_encoder_->MaxEncodedBytes(); 777 const size_t max_encoded_bytes = isac_encoder_->MaxEncodedBytes();
781 rtc::scoped_ptr<uint8_t[]> encoded(new uint8_t[max_encoded_bytes]); 778 rtc::scoped_ptr<uint8_t[]> encoded(new uint8_t[max_encoded_bytes]);
782 AudioEncoder::EncodedInfo info; 779 AudioEncoder::EncodedInfo info;
783 { 780 {
784 CriticalSectionScoped lock(crit_sect_.get()); 781 rtc::CritScope lock(&crit_sect_);
785 if (clock_->TimeInMilliseconds() < next_insert_packet_time_ms_) { 782 if (clock_->TimeInMilliseconds() < next_insert_packet_time_ms_) {
786 return true; 783 return true;
787 } 784 }
788 next_insert_packet_time_ms_ += kPacketSizeMs; 785 next_insert_packet_time_ms_ += kPacketSizeMs;
789 ++receive_packet_count_; 786 ++receive_packet_count_;
790 787
791 // Encode new frame. 788 // Encode new frame.
792 uint32_t input_timestamp = rtp_header_.header.timestamp; 789 uint32_t input_timestamp = rtp_header_.header.timestamp;
793 while (info.encoded_bytes == 0) { 790 while (info.encoded_bytes == 0) {
794 info = 791 info =
(...skipping 27 matching lines...) Expand all
822 return reinterpret_cast<AcmReRegisterIsacMtTestOldApi*>(context) 819 return reinterpret_cast<AcmReRegisterIsacMtTestOldApi*>(context)
823 ->CbCodecRegistrationImpl(); 820 ->CbCodecRegistrationImpl();
824 } 821 }
825 822
826 bool CbCodecRegistrationImpl() { 823 bool CbCodecRegistrationImpl() {
827 SleepMs(1); 824 SleepMs(1);
828 if (HasFatalFailure()) { 825 if (HasFatalFailure()) {
829 // End the test early if a fatal failure (ASSERT_*) has occurred. 826 // End the test early if a fatal failure (ASSERT_*) has occurred.
830 test_complete_->Set(); 827 test_complete_->Set();
831 } 828 }
832 CriticalSectionScoped lock(crit_sect_.get()); 829 rtc::CritScope lock(&crit_sect_);
833 if (!codec_registered_ && 830 if (!codec_registered_ &&
834 receive_packet_count_ > kRegisterAfterNumPackets) { 831 receive_packet_count_ > kRegisterAfterNumPackets) {
835 // Register the iSAC encoder. 832 // Register the iSAC encoder.
836 EXPECT_EQ(0, acm_->RegisterSendCodec(codec_)); 833 EXPECT_EQ(0, acm_->RegisterSendCodec(codec_));
837 codec_registered_ = true; 834 codec_registered_ = true;
838 } 835 }
839 if (codec_registered_ && receive_packet_count_ > kNumPackets) { 836 if (codec_registered_ && receive_packet_count_ > kNumPackets) {
840 test_complete_->Set(); 837 test_complete_->Set();
841 } 838 }
842 return true; 839 return true;
843 } 840 }
844 841
845 rtc::PlatformThread receive_thread_; 842 rtc::PlatformThread receive_thread_;
846 rtc::PlatformThread codec_registration_thread_; 843 rtc::PlatformThread codec_registration_thread_;
847 const rtc::scoped_ptr<EventWrapper> test_complete_; 844 const rtc::scoped_ptr<EventWrapper> test_complete_;
848 const rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_; 845 mutable rtc::CriticalSection crit_sect_;
849 bool codec_registered_ GUARDED_BY(crit_sect_); 846 bool codec_registered_ GUARDED_BY(crit_sect_);
850 int receive_packet_count_ GUARDED_BY(crit_sect_); 847 int receive_packet_count_ GUARDED_BY(crit_sect_);
851 int64_t next_insert_packet_time_ms_ GUARDED_BY(crit_sect_); 848 int64_t next_insert_packet_time_ms_ GUARDED_BY(crit_sect_);
852 rtc::scoped_ptr<AudioEncoderIsac> isac_encoder_; 849 rtc::scoped_ptr<AudioEncoderIsac> isac_encoder_;
853 rtc::scoped_ptr<SimulatedClock> fake_clock_; 850 rtc::scoped_ptr<SimulatedClock> fake_clock_;
854 test::AudioLoop audio_loop_; 851 test::AudioLoop audio_loop_;
855 }; 852 };
856 853
857 #if defined(WEBRTC_IOS) 854 #if defined(WEBRTC_IOS)
858 #define MAYBE_DoTest DISABLED_DoTest 855 #define MAYBE_DoTest DISABLED_DoTest
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 Run(16000, 8000, 1000); 1777 Run(16000, 8000, 1000);
1781 } 1778 }
1782 1779
1783 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) { 1780 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) {
1784 Run(8000, 16000, 1000); 1781 Run(8000, 16000, 1000);
1785 } 1782 }
1786 1783
1787 #endif 1784 #endif
1788 1785
1789 } // namespace webrtc 1786 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698