From f56c1623103e3f72198d6b0f50de9f0585b6f52f Mon Sep 17 00:00:00 2001 From: "henrik.lundin@webrtc.org" Date: Mon, 2 Mar 2015 12:29:30 +0000 Subject: [PATCH] Remove AudioCodingModule::Process() An earlier change moved the encoding work from Process to Add10MsData; process was just a no-op. BUG=3520 COAUTHOR=kwiberg@webrtc.org R=henrika@webrtc.org, minyue@webrtc.org, tina.legrand@webrtc.org Review URL: https://webrtc-codereview.appspot.com/43439004 Cr-Commit-Position: refs/heads/master@{#8553} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8553 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../main/acm2/acm_receiver_unittest_oldapi.cc | 8 ++--- .../main/acm2/acm_send_test_oldapi.cc | 7 ++-- .../main/acm2/acm_send_test_oldapi.h | 1 + .../main/acm2/audio_coding_module_impl.cc | 21 ++---------- .../main/acm2/audio_coding_module_impl.h | 7 ++-- .../audio_coding_module_unittest_oldapi.cc | 33 +++++++++---------- .../main/interface/audio_coding_module.h | 15 ++++----- .../modules/audio_coding/main/test/APITest.cc | 22 ------------- .../main/test/EncodeDecodeTest.cc | 8 ++--- .../audio_coding/main/test/SpatialAudio.cc | 5 --- .../audio_coding/main/test/TestAllCodecs.cc | 3 -- .../audio_coding/main/test/TestRedFec.cc | 3 +- .../audio_coding/main/test/TestStereo.cc | 5 +-- .../audio_coding/main/test/TestVADDTX.cc | 3 +- .../main/test/TwoWayCommunication.cc | 21 +++--------- .../audio_coding/main/test/delay_test.cc | 3 +- .../audio_coding/main/test/iSACTest.cc | 6 ++-- .../main/test/initial_delay_unittest.cc | 3 +- .../main/test/insert_packet_with_timing.cc | 6 +--- webrtc/modules/utility/source/coder.cc | 4 --- webrtc/voice_engine/channel.cc | 12 +++---- 21 files changed, 54 insertions(+), 142 deletions(-) diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc index c1b16365e..e9096ff93 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc @@ -96,17 +96,13 @@ class AcmReceiverTestOldApi : public AudioPacketizationCallback, frame.num_channels_ = codec.channels; memset(frame.data_, 0, frame.samples_per_channel_ * frame.num_channels_ * sizeof(int16_t)); - int num_bytes = 0; packet_sent_ = false; last_packet_send_timestamp_ = timestamp_; - while (num_bytes == 0) { + while (!packet_sent_) { frame.timestamp_ = timestamp_; timestamp_ += frame.samples_per_channel_; - ASSERT_EQ(0, acm_->Add10MsData(frame)); - num_bytes = acm_->Process(); - ASSERT_GE(num_bytes, 0); + ASSERT_GE(acm_->Add10MsData(frame), 0); } - ASSERT_TRUE(packet_sent_); // Sanity check. } // Last element of id should be negative. diff --git a/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.cc b/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.cc index 6749e12f9..41e0feb5f 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.cc @@ -80,10 +80,10 @@ Packet* AcmSendTestOldApi::NextPacket() { input_frame_.num_channels_, input_frame_.data_); } - CHECK_EQ(0, acm_->Add10MsData(input_frame_)); + data_to_send_ = false; + CHECK_GE(acm_->Add10MsData(input_frame_), 0); input_frame_.timestamp_ += input_block_size_samples_; - int32_t encoded_bytes = acm_->Process(); - if (encoded_bytes > 0) { + if (data_to_send_) { // Encoded packet received. return CreatePacket(); } @@ -106,6 +106,7 @@ int32_t AcmSendTestOldApi::SendData( timestamp_ = timestamp; last_payload_vec_.assign(payload_data, payload_data + payload_len_bytes); assert(last_payload_vec_.size() == payload_len_bytes); + data_to_send_ = true; return 0; } diff --git a/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h b/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h index 80aaf360d..05a29df2b 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h +++ b/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h @@ -79,6 +79,7 @@ class AcmSendTestOldApi : public AudioPacketizationCallback, uint32_t timestamp_; uint16_t sequence_number_; std::vector last_payload_vec_; + bool data_to_send_; DISALLOW_COPY_AND_ASSIGN(AcmSendTestOldApi); }; diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc index 542aabab9..62287a4ab 100644 --- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc +++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc @@ -145,7 +145,6 @@ AudioCodingModuleImpl::AudioCodingModuleImpl( aux_rtp_header_(NULL), receiver_initialized_(false), first_10ms_data_(false), - last_encode_value_(0), callback_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), packetization_callback_(NULL), vad_callback_(NULL) { @@ -218,11 +217,6 @@ AudioCodingModuleImpl::~AudioCodingModuleImpl() { "Destroyed"); } -int32_t AudioCodingModuleImpl::Process() { - CriticalSectionScoped lock(acm_crit_sect_); - return last_encode_value_; -} - int32_t AudioCodingModuleImpl::Encode() { // Make room for 1 RED payload. uint8_t stream[2 * MAX_PAYLOAD_SIZE_BYTE]; @@ -752,15 +746,7 @@ int AudioCodingModuleImpl::RegisterTransportCallback( // Add 10MS of raw (PCM) audio data to the encoder. int AudioCodingModuleImpl::Add10MsData(const AudioFrame& audio_frame) { int r = Add10MsDataInternal(audio_frame); - if (r < 0) { - CriticalSectionScoped lock(acm_crit_sect_); - last_encode_value_ = -1; - } else { - int r_encode = Encode(); - CriticalSectionScoped lock(acm_crit_sect_); - last_encode_value_ = r_encode; - } - return r; + return r < 0 ? r : Encode(); } int AudioCodingModuleImpl::Add10MsDataInternal(const AudioFrame& audio_frame) { @@ -1563,10 +1549,9 @@ const CodecInst* AudioCodingImpl::GetSenderCodecInst() { } int AudioCodingImpl::Add10MsAudio(const AudioFrame& audio_frame) { - if (acm_old_->Add10MsData(audio_frame) != 0) { + if (acm_old_->Add10MsDataInternal(audio_frame) != 0) return -1; - } - return acm_old_->Process(); + return acm_old_->Encode(); } const ReceiverInfo* AudioCodingImpl::GetReceiverInfo() const { diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h index 3450194ac..76d1e363a 100644 --- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h +++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h @@ -24,6 +24,7 @@ namespace webrtc { class CriticalSectionWrapper; +class AudioCodingImpl; namespace acm2 { @@ -32,12 +33,11 @@ class ACMGenericCodec; class AudioCodingModuleImpl : public AudioCodingModule { public: + friend webrtc::AudioCodingImpl; + explicit AudioCodingModuleImpl(const AudioCodingModule::Config& config); ~AudioCodingModuleImpl(); - // Process any pending tasks such as timeouts. - virtual int32_t Process() OVERRIDE; - ///////////////////////////////////////// // Sender // @@ -335,7 +335,6 @@ class AudioCodingModuleImpl : public AudioCodingModule { AudioFrame preprocess_frame_ GUARDED_BY(acm_crit_sect_); bool first_10ms_data_ GUARDED_BY(acm_crit_sect_); - int last_encode_value_ GUARDED_BY(acm_crit_sect_); CriticalSectionWrapper* callback_crit_sect_; AudioPacketizationCallback* packetization_callback_ diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc index a1ea179bd..122d0272b 100644 --- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc +++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc @@ -193,15 +193,15 @@ class AudioCodingModuleTestOldApi : public ::testing::Test { } virtual void InsertAudio() { - ASSERT_EQ(0, acm_->Add10MsData(input_frame_)); + ASSERT_GE(acm_->Add10MsData(input_frame_), 0); + VerifyEncoding(); input_frame_.timestamp_ += kNumSamples10ms; } - virtual void Encode() { - int32_t encoded_bytes = acm_->Process(); - // Expect to get one packet with two bytes per sample, or no packet at all, - // depending on how many 10 ms blocks go into |codec_.pacsize|. - EXPECT_TRUE(encoded_bytes == 2 * codec_.pacsize || encoded_bytes == 0); + virtual void VerifyEncoding() { + int last_length = packet_cb_.last_payload_len_bytes(); + EXPECT_TRUE(last_length == 2 * codec_.pacsize || last_length == 0) + << "Last encoded packet was " << last_length << " bytes."; } const int id_; @@ -316,7 +316,6 @@ TEST_F(AudioCodingModuleTestOldApi, TransportCallbackIsInvokedForEachPacket) { if (packet_cb_.num_calls() > 0) EXPECT_EQ(kAudioFrameSpeech, packet_cb_.last_frame_type()); InsertAudio(); - Encode(); } EXPECT_EQ(kLoops / k10MsBlocksPerPacket, packet_cb_.num_calls()); EXPECT_EQ(kAudioFrameSpeech, packet_cb_.last_frame_type()); @@ -330,13 +329,6 @@ TEST_F(AudioCodingModuleTestOldApi, TransportCallbackIsInvokedForEachPacket) { class AudioCodingModuleTestWithComfortNoiseOldApi : public AudioCodingModuleTestOldApi { protected: - void Encode() override { - int32_t encoded_bytes = acm_->Process(); - // Expect either one packet with 9 comfort noise parameters, or no packet - // at all. - EXPECT_TRUE(encoded_bytes == 9 || encoded_bytes == 0); - } - void RegisterCngCodec(int rtp_payload_type) { CodecInst codec; AudioCodingModule::Codec("CN", &codec, kSampleRateHz, 1); @@ -345,6 +337,12 @@ class AudioCodingModuleTestWithComfortNoiseOldApi ASSERT_EQ(0, acm_->RegisterSendCodec(codec)); } + void VerifyEncoding() override { + int last_length = packet_cb_.last_payload_len_bytes(); + EXPECT_TRUE(last_length == 9 || last_length == 0) + << "Last encoded packet was " << last_length << " bytes."; + } + void DoTest(int blocks_per_packet, int cng_pt) { const int kLoops = 40; // This array defines the expected frame types, and when they should arrive. @@ -371,7 +369,6 @@ class AudioCodingModuleTestWithComfortNoiseOldApi int num_calls_before = packet_cb_.num_calls(); EXPECT_EQ(i / blocks_per_packet, num_calls_before); InsertAudio(); - Encode(); int num_calls = packet_cb_.num_calls(); if (num_calls == num_calls_before + 1) { EXPECT_EQ(expectation[num_calls - 1].ix, i); @@ -493,7 +490,6 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi { } ++send_count_; InsertAudio(); - Encode(); if (TestDone()) { test_complete_->Set(); } @@ -586,7 +582,6 @@ class AcmIsacMtTestOldApi : public AudioCodingModuleMtTestOldApi { int loop_counter = 0; while (packet_cb_.last_payload_len_bytes() == 0) { InsertAudio(); - Encode(); ASSERT_LT(loop_counter++, 10); } // Set |last_packet_number_| to one less that |num_calls| so that the packet @@ -632,7 +627,9 @@ class AcmIsacMtTestOldApi : public AudioCodingModuleMtTestOldApi { AudioCodingModuleTestOldApi::InsertAudio(); } - void Encode() { ASSERT_GE(acm_->Process(), 0); } + // Override the verification function with no-op, since iSAC produces variable + // payload sizes. + void VerifyEncoding() override {} // This method is the same as AudioCodingModuleMtTestOldApi::TestDone(), but // here it is using the constants defined in this class (i.e., shorter test diff --git a/webrtc/modules/audio_coding/main/interface/audio_coding_module.h b/webrtc/modules/audio_coding/main/interface/audio_coding_module.h index f14ff8090..72e00cdfa 100644 --- a/webrtc/modules/audio_coding/main/interface/audio_coding_module.h +++ b/webrtc/modules/audio_coding/main/interface/audio_coding_module.h @@ -101,8 +101,6 @@ class AudioCodingModule { static AudioCodingModule* Create(int id, Clock* clock); virtual ~AudioCodingModule() {}; - virtual int32_t Process() = 0; - /////////////////////////////////////////////////////////////////////////// // Utility functions // @@ -317,9 +315,12 @@ class AudioCodingModule { /////////////////////////////////////////////////////////////////////////// // int32_t Add10MsData() - // Add 10MS of raw (PCM) audio data to the encoder. If the sampling + // Add 10MS of raw (PCM) audio data and encode it. If the sampling // frequency of the audio does not match the sampling frequency of the - // current encoder ACM will resample the audio. + // current encoder ACM will resample the audio. If an encoded packet was + // produced, it will be delivered via the callback object registered using + // RegisterTransportCallback, and the return value from this function will + // be the number of bytes encoded. // // Input: // -audio_frame : the input audio frame, containing raw audio @@ -328,10 +329,8 @@ class AudioCodingModule { // AudioFrame. // // Return value: - // 0 successfully added the frame. - // -1 some error occurred and data is not added. - // < -1 to add the frame to the buffer n samples had to be - // overwritten, -n is the return value in this case. + // >= 0 number of bytes encoded. + // -1 some error occurred. // virtual int32_t Add10MsData(const AudioFrame& audio_frame) = 0; diff --git a/webrtc/modules/audio_coding/main/test/APITest.cc b/webrtc/modules/audio_coding/main/test/APITest.cc index 6893587d5..cf213433d 100644 --- a/webrtc/modules/audio_coding/main/test/APITest.cc +++ b/webrtc/modules/audio_coding/main/test/APITest.cc @@ -411,33 +411,11 @@ bool APITest::PushAudioRunB() { bool APITest::ProcessRunA() { _processEventA->Wait(100); - if (_acmA->Process() < 0) { - // do not print error message if there is no encoder - bool thereIsEncoder; - { - ReadLockScoped rl(_apiTestRWLock); - thereIsEncoder = _thereIsEncoderA; - } - - if (thereIsEncoder) { - fprintf(stderr, "\n>>>>> Process Failed at A <<<<<\n"); - } - } return true; } bool APITest::ProcessRunB() { _processEventB->Wait(100); - if (_acmB->Process() < 0) { - bool thereIsEncoder; - { - ReadLockScoped rl(_apiTestRWLock); - thereIsEncoder = _thereIsEncoderB; - } - if (thereIsEncoder) { - fprintf(stderr, "\n>>>>> Process Failed at B <<<<<\n"); - } - } return true; } diff --git a/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.cc b/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.cc index eff458b4e..b785cc301 100644 --- a/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.cc +++ b/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.cc @@ -100,11 +100,8 @@ bool Sender::Add10MsData() { if (!_pcmFile.EndOfFile()) { EXPECT_GT(_pcmFile.Read10MsData(_audioFrame), 0); int32_t ok = _acm->Add10MsData(_audioFrame); - EXPECT_EQ(0, ok); - if (ok != 0) { - return false; - } - return true; + EXPECT_GE(ok, 0); + return ok >= 0 ? true : false; } return false; } @@ -114,7 +111,6 @@ void Sender::Run() { if (!Add10MsData()) { break; } - EXPECT_GT(_acm->Process(), -1); } } diff --git a/webrtc/modules/audio_coding/main/test/SpatialAudio.cc b/webrtc/modules/audio_coding/main/test/SpatialAudio.cc index 7286fc172..b28c510a5 100644 --- a/webrtc/modules/audio_coding/main/test/SpatialAudio.cc +++ b/webrtc/modules/audio_coding/main/test/SpatialAudio.cc @@ -171,9 +171,6 @@ void SpatialAudio::EncodeDecode(const double leftPanning, } CHECK_ERROR(_acmRight->Add10MsData(audioFrame)); - CHECK_ERROR(_acmLeft->Process()); - CHECK_ERROR(_acmRight->Process()); - CHECK_ERROR(_acmReceiver->PlayoutData10Ms(outFileSampFreq, &audioFrame)); _outFile.Write10MsData(audioFrame); } @@ -190,8 +187,6 @@ void SpatialAudio::EncodeDecode() { _inFile.Read10MsData(audioFrame); CHECK_ERROR(_acmLeft->Add10MsData(audioFrame)); - CHECK_ERROR(_acmLeft->Process()); - CHECK_ERROR(_acmReceiver->PlayoutData10Ms(outFileSampFreq, &audioFrame)); _outFile.Write10MsData(audioFrame); } diff --git a/webrtc/modules/audio_coding/main/test/TestAllCodecs.cc b/webrtc/modules/audio_coding/main/test/TestAllCodecs.cc index 17186b364..b1badb636 100644 --- a/webrtc/modules/audio_coding/main/test/TestAllCodecs.cc +++ b/webrtc/modules/audio_coding/main/test/TestAllCodecs.cc @@ -434,9 +434,6 @@ void TestAllCodecs::Run(TestPack* channel) { infile_a_.Read10MsData(audio_frame); CHECK_ERROR(acm_a_->Add10MsData(audio_frame)); - // Run sender side of ACM. - CHECK_ERROR(acm_a_->Process()); - // Verify that the received packet size matches the settings. receive_size = channel->payload_size(); if (receive_size) { diff --git a/webrtc/modules/audio_coding/main/test/TestRedFec.cc b/webrtc/modules/audio_coding/main/test/TestRedFec.cc index b69a1ed02..8f6ef9d89 100644 --- a/webrtc/modules/audio_coding/main/test/TestRedFec.cc +++ b/webrtc/modules/audio_coding/main/test/TestRedFec.cc @@ -311,8 +311,7 @@ void TestRedFec::Run() { while (!_inFileA.EndOfFile()) { EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0); - EXPECT_EQ(0, _acmA->Add10MsData(audioFrame)); - EXPECT_GT(_acmA->Process(), -1); + EXPECT_GE(_acmA->Add10MsData(audioFrame), 0); EXPECT_EQ(0, _acmB->PlayoutData10Ms(outFreqHzB, &audioFrame)); _outFileB.Write10MsData(audioFrame.data_, audioFrame.samples_per_channel_); msecPassed += 10; diff --git a/webrtc/modules/audio_coding/main/test/TestStereo.cc b/webrtc/modules/audio_coding/main/test/TestStereo.cc index 5e7bc51eb..72ae25ea1 100644 --- a/webrtc/modules/audio_coding/main/test/TestStereo.cc +++ b/webrtc/modules/audio_coding/main/test/TestStereo.cc @@ -779,10 +779,7 @@ void TestStereo::Run(TestPackStereo* channel, int in_channels, int out_channels, } in_file_stereo_->Read10MsData(audio_frame); } - EXPECT_EQ(0, acm_a_->Add10MsData(audio_frame)); - - // Run sender side of ACM - EXPECT_GT(acm_a_->Process(), -1); + EXPECT_GE(acm_a_->Add10MsData(audio_frame), 0); // Verify that the received packet size matches the settings. rec_size = channel->payload_size(); diff --git a/webrtc/modules/audio_coding/main/test/TestVADDTX.cc b/webrtc/modules/audio_coding/main/test/TestVADDTX.cc index 1e05be264..20ccde6e6 100644 --- a/webrtc/modules/audio_coding/main/test/TestVADDTX.cc +++ b/webrtc/modules/audio_coding/main/test/TestVADDTX.cc @@ -242,8 +242,7 @@ void TestVADDTX::Run() { _inFileA.Read10MsData(audioFrame); audioFrame.timestamp_ = timestampA; timestampA += SamplesIn10MsecA; - EXPECT_EQ(0, _acmA->Add10MsData(audioFrame)); - EXPECT_GT(_acmA->Process(), -1); + EXPECT_GE(_acmA->Add10MsData(audioFrame), 0); EXPECT_EQ(0, _acmB->PlayoutData10Ms(outFreqHzB, &audioFrame)); _outFileB.Write10MsData(audioFrame.data_, audioFrame.samples_per_channel_); } diff --git a/webrtc/modules/audio_coding/main/test/TwoWayCommunication.cc b/webrtc/modules/audio_coding/main/test/TwoWayCommunication.cc index cc0fc206e..f4db1db3d 100644 --- a/webrtc/modules/audio_coding/main/test/TwoWayCommunication.cc +++ b/webrtc/modules/audio_coding/main/test/TwoWayCommunication.cc @@ -282,32 +282,21 @@ void TwoWayCommunication::Perform() { // and B, APIs will be called, like ResetEncoder(), and the code should // continue to run, and be able to recover. bool expect_error_add = false; - bool expect_error_process = false; while (!_inFileA.EndOfFile() && !_inFileB.EndOfFile()) { msecPassed += 10; EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0); - EXPECT_EQ(0, _acmA->Add10MsData(audioFrame)); - EXPECT_EQ(0, _acmRefA->Add10MsData(audioFrame)); + EXPECT_GE(_acmA->Add10MsData(audioFrame), 0); + EXPECT_GE(_acmRefA->Add10MsData(audioFrame), 0); EXPECT_GT(_inFileB.Read10MsData(audioFrame), 0); // Expect call to pass except for the time when no send codec is registered. if (!expect_error_add) { - EXPECT_EQ(0, _acmB->Add10MsData(audioFrame)); + EXPECT_GE(_acmB->Add10MsData(audioFrame), 0); } else { EXPECT_EQ(-1, _acmB->Add10MsData(audioFrame)); } - // Expect to pass except for the time when there either is no send codec - // registered, or no receive codec. - if (!expect_error_process) { - EXPECT_GT(_acmB->Process(), -1); - } else { - EXPECT_EQ(_acmB->Process(), -1); - } - EXPECT_EQ(0, _acmRefB->Add10MsData(audioFrame)); - EXPECT_GT(_acmA->Process(), -1); - EXPECT_GT(_acmRefA->Process(), -1); - EXPECT_GT(_acmRefB->Process(), -1); + EXPECT_GE(_acmRefB->Add10MsData(audioFrame), 0); EXPECT_EQ(0, _acmA->PlayoutData10Ms(outFreqHzA, &audioFrame)); _outFileA.Write10MsData(audioFrame); EXPECT_EQ(0, _acmRefA->PlayoutData10Ms(outFreqHzA, &audioFrame)); @@ -328,14 +317,12 @@ void TwoWayCommunication::Perform() { EXPECT_EQ(0, _acmA->ResetEncoder()); EXPECT_EQ(0, _acmB->InitializeSender()); expect_error_add = true; - expect_error_process = true; } // Re-register send codec on side B. if (((secPassed % 5) == 4) && (msecPassed >= 990)) { EXPECT_EQ(0, _acmB->RegisterSendCodec(codecInst_B)); EXPECT_EQ(0, _acmB->SendCodec(&dummy)); expect_error_add = false; - expect_error_process = false; } // Reset decoder on side B, and initialize receiver on side A. if (((secPassed % 7) == 6) && (msecPassed == 0)) { diff --git a/webrtc/modules/audio_coding/main/test/delay_test.cc b/webrtc/modules/audio_coding/main/test/delay_test.cc index 55dfd936c..0f9e8b07f 100644 --- a/webrtc/modules/audio_coding/main/test/delay_test.cc +++ b/webrtc/modules/audio_coding/main/test/delay_test.cc @@ -209,8 +209,7 @@ class DelayTest { } in_file_a_.Read10MsData(audio_frame); - ASSERT_EQ(0, acm_a_->Add10MsData(audio_frame)); - ASSERT_LE(0, acm_a_->Process()); + ASSERT_GE(acm_a_->Add10MsData(audio_frame), 0); ASSERT_EQ(0, acm_b_->PlayoutData10Ms(out_freq_hz_b, &audio_frame)); out_file_b_.Write10MsData( audio_frame.data_, diff --git a/webrtc/modules/audio_coding/main/test/iSACTest.cc b/webrtc/modules/audio_coding/main/test/iSACTest.cc index c5da92e1e..26236f2ca 100644 --- a/webrtc/modules/audio_coding/main/test/iSACTest.cc +++ b/webrtc/modules/audio_coding/main/test/iSACTest.cc @@ -246,10 +246,8 @@ void ISACTest::Perform() { void ISACTest::Run10ms() { AudioFrame audioFrame; EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0); - EXPECT_EQ(0, _acmA->Add10MsData(audioFrame)); - EXPECT_EQ(0, _acmB->Add10MsData(audioFrame)); - EXPECT_GT(_acmA->Process(), -1); - EXPECT_GT(_acmB->Process(), -1); + EXPECT_GE(_acmA->Add10MsData(audioFrame), 0); + EXPECT_GE(_acmB->Add10MsData(audioFrame), 0); EXPECT_EQ(0, _acmA->PlayoutData10Ms(32000, &audioFrame)); _outFileA.Write10MsData(audioFrame); EXPECT_EQ(0, _acmB->PlayoutData10Ms(32000, &audioFrame)); diff --git a/webrtc/modules/audio_coding/main/test/initial_delay_unittest.cc b/webrtc/modules/audio_coding/main/test/initial_delay_unittest.cc index de87b5133..3d0d312f5 100644 --- a/webrtc/modules/audio_coding/main/test/initial_delay_unittest.cc +++ b/webrtc/modules/audio_coding/main/test/initial_delay_unittest.cc @@ -145,8 +145,7 @@ class InitialPlayoutDelayTest : public ::testing::Test { while (rms < kAmp / 2) { in_audio_frame.timestamp_ = timestamp; timestamp += in_audio_frame.samples_per_channel_; - ASSERT_EQ(0, acm_a_->Add10MsData(in_audio_frame)); - ASSERT_LE(0, acm_a_->Process()); + ASSERT_GE(acm_a_->Add10MsData(in_audio_frame), 0); ASSERT_EQ(0, acm_b_->PlayoutData10Ms(codec.plfreq, &out_audio_frame)); rms = FrameRms(out_audio_frame); ++num_frames; diff --git a/webrtc/modules/audio_coding/main/test/insert_packet_with_timing.cc b/webrtc/modules/audio_coding/main/test/insert_packet_with_timing.cc index 94b093d75..7331696c2 100644 --- a/webrtc/modules/audio_coding/main/test/insert_packet_with_timing.cc +++ b/webrtc/modules/audio_coding/main/test/insert_packet_with_timing.cc @@ -164,7 +164,7 @@ class InsertPacketWithTiming { // Push in just enough audio. for (int n = 0; n < num_10ms_in_codec_frame_; n++) { pcm_in_fid_.Read10MsData(frame_); - EXPECT_EQ(0, send_acm_->Add10MsData(frame_)); + EXPECT_GE(send_acm_->Add10MsData(frame_), 0); } // Set the parameters for the packet to be pushed in receiver ACM right @@ -179,10 +179,6 @@ class InsertPacketWithTiming { lost = true; } - // Process audio in send ACM, this should result in generation of a - // packet. - EXPECT_GT(send_acm_->Process(), 0); - if (FLAGS_verbose) { if (!lost) { std::cout << "\nInserting packet number " << seq_num diff --git a/webrtc/modules/utility/source/coder.cc b/webrtc/modules/utility/source/coder.cc index 5a3974820..b106c7524 100644 --- a/webrtc/modules/utility/source/coder.cc +++ b/webrtc/modules/utility/source/coder.cc @@ -96,10 +96,6 @@ int32_t AudioCoder::Encode(const AudioFrame& audio, return -1; } _encodedData = encodedData; - if(_acm->Process() == -1) - { - return -1; - } encodedLengthInBytes = _encodedLengthInBytes; return 0; } diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc index 927440a88..0a5d8e607 100644 --- a/webrtc/voice_engine/channel.cc +++ b/webrtc/voice_engine/channel.cc @@ -3560,7 +3560,10 @@ Channel::EncodeAndSend() // The ACM resamples internally. _audioFrame.timestamp_ = _timeStamp; - if (audio_coding_->Add10MsData((AudioFrame&)_audioFrame) != 0) + // This call will trigger AudioPacketizationCallback::SendData if encoding + // is done and payload is ready for packetization and transmission. + // Otherwise, it will return without invoking the callback. + if (audio_coding_->Add10MsData((AudioFrame&)_audioFrame) < 0) { WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,_channelId), "Channel::EncodeAndSend() ACM encoding failed"); @@ -3568,12 +3571,7 @@ Channel::EncodeAndSend() } _timeStamp += _audioFrame.samples_per_channel_; - - // --- Encode if complete frame is ready - - // This call will trigger AudioPacketizationCallback::SendData if encoding - // is done and payload is ready for packetization and transmission. - return audio_coding_->Process(); + return 0; } int Channel::RegisterExternalMediaProcessing(