diff --git a/services/engine/codec/audio/audio_buffers_manager.cpp b/services/engine/codec/audio/audio_buffers_manager.cpp index 7c53886f4276f116c1f5b74ad7cd953dac1bcc3c..c537f8fc98e9455828cc89aa06becb3650bf30a0 100644 --- a/services/engine/codec/audio/audio_buffers_manager.cpp +++ b/services/engine/codec/audio/audio_buffers_manager.cpp @@ -47,18 +47,18 @@ AudioBuffersManager::AudioBuffersManager(const uint32_t &bufferSize, const std:: std::shared_ptr AudioBuffersManager::getMemory(const uint32_t &index) const noexcept { - std::unique_lock lock(stateMutex_); if (index >= bufferInfo_.size()) { return nullptr; } AVCODEC_LOGD_LIMIT(LOGD_FREQUENCY, "start get memory,name:%{public}s,index:%{public}u", name_.data(), index); + std::lock_guard lock(stateMutex_); return bufferInfo_[index]; } bool AudioBuffersManager::SetBufferBusy(const uint32_t &index) { - std::unique_lock lock(stateMutex_); if (index < bufferInfo_.size()) { + std::lock_guard lock(stateMutex_); bufferInfo_[index]->SetBufferOwned(); return true; } @@ -67,7 +67,7 @@ bool AudioBuffersManager::SetBufferBusy(const uint32_t &index) void AudioBuffersManager::initBuffers() { - std::unique_lock lock(stateMutex_); + std::lock_guard lock(stateMutex_); AVCODEC_LOGI("start allocate %{public}s buffers,each buffer size:%{public}d", name_.data(), bufferSize_); for (size_t i = 0; i < DEFAULT_BUFFER_LENGTH; i++) { bufferInfo_[i] = std::make_shared(bufferSize_, name_, metaSize_, align_); @@ -112,9 +112,11 @@ bool AudioBuffersManager::RequestAvailableIndex(uint32_t &index) if (!isRunning_) { return false; } - std::unique_lock lock(stateMutex_); - index = inBufIndexQue_.front(); - inBufIndexQue_.pop(); + { + std::lock_guard lock(stateMutex_); + index = inBufIndexQue_.front(); + inBufIndexQue_.pop(); + } if (index >= bufferInfo_.size()) { AVCODEC_LOGW("Request %{public}s buffer index is invalidate ,index:%{public}u.", name_.data(), index); return false; @@ -129,9 +131,11 @@ void AudioBuffersManager::ReleaseAll() { isRunning_ = false; availableCondition_.notify_all(); - std::unique_lock lock(stateMutex_); - while (!inBufIndexQue_.empty()) { - inBufIndexQue_.pop(); + { + std::lock_guard lock(stateMutex_); + while (!inBufIndexQue_.empty()) { + inBufIndexQue_.pop(); + } } for (uint32_t i = 0; i < bufferInfo_.size(); ++i) { bufferInfo_[i]->ResetBuffer(); @@ -150,7 +154,7 @@ bool AudioBuffersManager::ReleaseBuffer(const uint32_t &index) { if (index < bufferInfo_.size()) { AVCODEC_LOGD_LIMIT(LOGD_FREQUENCY, "ReleaseBuffer %{public}s buffer,index:%{public}u", name_.data(), index); - std::unique_lock lock(stateMutex_); + std::lock_guard lock(stateMutex_); bufferInfo_[index]->ResetBuffer(); if (!inBufIndexExist[index]) { inBufIndexQue_.emplace(index); @@ -164,7 +168,7 @@ bool AudioBuffersManager::ReleaseBuffer(const uint32_t &index) std::shared_ptr AudioBuffersManager::createNewBuffer() { - std::unique_lock lock(stateMutex_); + std::lock_guard lock(stateMutex_); std::shared_ptr buffer = std::make_shared(bufferSize_, name_, metaSize_, align_); bufferInfo_.emplace_back(buffer); return buffer; diff --git a/services/engine/codec/audio/audio_codec_adapter.cpp b/services/engine/codec/audio/audio_codec_adapter.cpp index 5887e244ce8fb8641e2d4369595b6b95984d49fd..610276d98e4933cae76c170284b245fb9668c400 100644 --- a/services/engine/codec/audio/audio_codec_adapter.cpp +++ b/services/engine/codec/audio/audio_codec_adapter.cpp @@ -258,32 +258,6 @@ int32_t AudioCodecAdapter::GetOutputFormat(Format &format) return AVCodecServiceErrCode::AVCS_ERR_OK; } -std::shared_ptr AudioCodecAdapter::GetInputBuffer(uint32_t index) -{ - AVCODEC_SYNC_TRACE; - AVCODEC_LOGD_LIMIT(LOGD_FREQUENCY, "adapter %{public}s get input,index:%{public}u", name_.data(), index); - if (!audioCodec) { - AVCODEC_LOGE("adapter GetInputBuffer error, audio codec not initialized ."); - return nullptr; - } - if (!callback_) { - AVCODEC_LOGE("adapter get input buffer error,index:%{public}u, call back not initialized .", index); - return nullptr; - } - std::shared_ptr result = worker_->GetInputBufferInfo(index); - if (result == nullptr) { - AVCODEC_LOGE("getMemory failed,index:%{public}u", index); - return nullptr; - } - - if (result->GetStatus() == BufferStatus::IDLE) { - AVCODEC_LOGE("GetStatus is IDLE,index:%{public}u", index); - return nullptr; - } - - return result->GetBuffer(); -} - int32_t AudioCodecAdapter::QueueInputBuffer(uint32_t index, const AVCodecBufferInfo &info, AVCodecBufferFlag flag) { AVCODEC_SYNC_TRACE; @@ -324,32 +298,6 @@ int32_t AudioCodecAdapter::QueueInputBuffer(uint32_t index, const AVCodecBufferI return AVCodecServiceErrCode::AVCS_ERR_OK; } -std::shared_ptr AudioCodecAdapter::GetOutputBuffer(uint32_t index) -{ - AVCODEC_SYNC_TRACE; - AVCODEC_LOGD_LIMIT(LOGD_FREQUENCY, "adapter %{public}s get output,index:%{public}u", name_.data(), index); - if (!audioCodec) { - AVCODEC_LOGE("adapter get output error, audio codec not initialized ."); - return nullptr; - } - if (!callback_) { - AVCODEC_LOGE("adapter get output buffer error, call back not initialized .index:%{public}u", index); - return nullptr; - } - - auto result = worker_->GetOutputBufferInfo(index); - if (result == nullptr) { - AVCODEC_LOGE("getMemory failed"); - return nullptr; - } - - if (result->GetStatus() == BufferStatus::IDLE) { - return nullptr; - } - - return result->GetBuffer(); -} - int32_t AudioCodecAdapter::ReleaseOutputBuffer(uint32_t index) { AVCODEC_SYNC_TRACE; diff --git a/services/engine/codec/audio/audio_codec_worker.cpp b/services/engine/codec/audio/audio_codec_worker.cpp index e1b5110cbc98b05232a4b2815c7162b60e6256e3..851235bc3cda7ac175bfc664dd171ed88e96f938 100644 --- a/services/engine/codec/audio/audio_codec_worker.cpp +++ b/services/engine/codec/audio/audio_codec_worker.cpp @@ -103,7 +103,7 @@ bool AudioCodecWorker::PushInputData(const uint32_t &index) } { - std::unique_lock lock(stateMutex_); + std::lock_guard lock(stateMutex_); inBufIndexQue_.push(index); } @@ -170,7 +170,7 @@ bool AudioCodecWorker::Stop() return false; } { - std::unique_lock lock(stateMutex_); + std::lock_guard lock(stateMutex_); while (!inBufIndexQue_.empty()) { inBufIndexQue_.pop(); } @@ -199,7 +199,7 @@ bool AudioCodecWorker::Pause() return false; } { - std::unique_lock lock(stateMutex_); + std::lock_guard lock(stateMutex_); while (!inBufIndexQue_.empty()) { inBufIndexQue_.pop(); } @@ -242,7 +242,7 @@ bool AudioCodecWorker::Release() outputTask_ = nullptr; } { - std::unique_lock lock(stateMutex_); + std::lock_guard lock(stateMutex_); while (!inBufIndexQue_.empty()) { inBufIndexQue_.pop(); } @@ -296,7 +296,7 @@ void AudioCodecWorker::ProduceInputBuffer() if (inputBuffer_->RequestAvailableIndex(index)) { AVCODEC_LOGD_LIMIT(LOGD_FREQUENCY, "produceInputBuffer %{public}s request success. index:%{public}u", name_.data(), index); - callback_->OnInputBufferAvailable(index); + callback_->OnInputBufferAvailable(index, GetInputBufferInfo(inputIndex)->GetBuffer()); } else { AVCODEC_LOGD("produceInputBuffer request failed."); SleepFor(DEFAULT_TRY_DECODE_TIME); @@ -312,9 +312,12 @@ void AudioCodecWorker::ProduceInputBuffer() bool AudioCodecWorker::HandInputBuffer(int32_t &ret) { - std::unique_lock lock(stateMutex_); - uint32_t inputIndex = inBufIndexQue_.front(); - inBufIndexQue_.pop(); + uint32_t inputIndex; + { + std::lock_guard lock(stateMutex_); + inputIndex = inBufIndexQue_.front(); + inBufIndexQue_.pop(); + } AVCODEC_LOGD_LIMIT(LOGD_FREQUENCY, "handle input buffer. index:%{public}u", inputIndex); auto inputBuffer = GetInputBufferInfo(inputIndex); bool isEos = inputBuffer->CheckIsEos(); @@ -374,7 +377,8 @@ void AudioCodecWorker::ConsumerOutputBuffer() } AVCODEC_LOGD_LIMIT(LOGD_FREQUENCY, "Work %{public}s consumerOutputBuffer callback_ index:%{public}u", name_.data(), index); - callback_->OnOutputBufferAvailable(index, outBuffer->GetBufferAttr(), outBuffer->GetFlag()); + callback_->OnOutputBufferAvailable(index, outBuffer->GetBufferAttr(), outBuffer->GetFlag(), + outBuffer->GetBuffer()); } } std::unique_lock lock(outputMutex_); diff --git a/services/engine/codec/audio/decoder/audio_ffmpeg_decoder_plugin.cpp b/services/engine/codec/audio/decoder/audio_ffmpeg_decoder_plugin.cpp index 141bdbb8f003a9a6aa3f48c89c8f0d37796a4705..483a2f35aa4440d648a17061a19a6cec7976df78 100644 --- a/services/engine/codec/audio/decoder/audio_ffmpeg_decoder_plugin.cpp +++ b/services/engine/codec/audio/decoder/audio_ffmpeg_decoder_plugin.cpp @@ -54,11 +54,11 @@ AudioFfmpegDecoderPlugin::~AudioFfmpegDecoderPlugin() int32_t AudioFfmpegDecoderPlugin::ProcessSendData(const std::shared_ptr &inputBuffer) { + std::lock_guard lock(avMutext_); if (avCodecContext_ == nullptr) { AVCODEC_LOGE("avCodecContext_ is nullptr"); return AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION; } - std::unique_lock lock(avMutext_); return SendBuffer(inputBuffer); } @@ -125,7 +125,7 @@ int32_t AudioFfmpegDecoderPlugin::SendBuffer(const std::shared_ptr &outBuffer) { - std::unique_lock l(avMutext_); + std::lock_guard l(avMutext_); if (!outBuffer) { AVCODEC_LOGE("outBuffer is nullptr"); return AVCodecServiceErrCode::AVCS_ERR_INVALID_VAL; @@ -221,6 +221,7 @@ int32_t AudioFfmpegDecoderPlugin::ReceiveFrameSucc(std::shared_ptr lock(avMutext_); CloseCtxLocked(); if (avCodecContext_ != nullptr) { avCodecContext_.reset(); @@ -231,7 +232,7 @@ int32_t AudioFfmpegDecoderPlugin::Reset() int32_t AudioFfmpegDecoderPlugin::Release() { - std::unique_lock lock(avMutext_); + std::lock_guard lock(avMutext_); auto ret = CloseCtxLocked(); if (avCodecContext_ != nullptr) { avCodecContext_.reset(); @@ -242,7 +243,7 @@ int32_t AudioFfmpegDecoderPlugin::Release() int32_t AudioFfmpegDecoderPlugin::Flush() { - std::unique_lock lock(avMutext_); + std::lock_guard lock(avMutext_); if (avCodecContext_ != nullptr) { avcodec_flush_buffers(avCodecContext_.get()); } @@ -252,7 +253,7 @@ int32_t AudioFfmpegDecoderPlugin::Flush() int32_t AudioFfmpegDecoderPlugin::AllocateContext(const std::string &name) { { - std::unique_lock lock(avMutext_); + std::lock_guard lock(avMutext_); avCodec_ = std::shared_ptr(const_cast(avcodec_find_decoder_by_name(name.c_str())), [](AVCodec *ptr) { (void)ptr; }); cachedFrame_ = std::shared_ptr(av_frame_alloc(), [](AVFrame *fp) { av_frame_free(&fp); }); @@ -264,7 +265,7 @@ int32_t AudioFfmpegDecoderPlugin::AllocateContext(const std::string &name) name_ = name; AVCodecContext *context = nullptr; { - std::unique_lock lock(avMutext_); + std::lock_guard lock(avMutext_); context = avcodec_alloc_context3(avCodec_.get()); avCodecContext_ = std::shared_ptr(context, [](AVCodecContext *ptr) { @@ -312,7 +313,7 @@ int32_t AudioFfmpegDecoderPlugin::OpenContext() { avPacket_ = std::shared_ptr(av_packet_alloc(), [](AVPacket *ptr) { av_packet_free(&ptr); }); { - std::unique_lock lock(avMutext_); + std::lock_guard lock(avMutext_); auto res = avcodec_open2(avCodecContext_.get(), avCodec_.get(), nullptr); if (res != 0) { AVCODEC_LOGE("avcodec open error %{public}s", AVStrError(res).c_str()); diff --git a/services/engine/codec/audio/encoder/audio_ffmpeg_encoder_plugin.cpp b/services/engine/codec/audio/encoder/audio_ffmpeg_encoder_plugin.cpp index 671d5bc6a567e3fac33c4bcf034ec7bebd568129..eaba96ba0612adf04e7f92159b106469febd6131 100644 --- a/services/engine/codec/audio/encoder/audio_ffmpeg_encoder_plugin.cpp +++ b/services/engine/codec/audio/encoder/audio_ffmpeg_encoder_plugin.cpp @@ -27,8 +27,13 @@ constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN, "AvCodec-Au namespace OHOS { namespace MediaAVCodec { AudioFfmpegEncoderPlugin::AudioFfmpegEncoderPlugin() - : maxInputSize_(-1), avCodec_(nullptr), avCodecContext_(nullptr), cachedFrame_(nullptr), avPacket_(nullptr), - prevPts_(0), codecContextValid_(false) + : maxInputSize_(-1), + avCodec_(nullptr), + avCodecContext_(nullptr), + cachedFrame_(nullptr), + avPacket_(nullptr), + prevPts_(0), + codecContextValid_(false) { } @@ -40,11 +45,11 @@ AudioFfmpegEncoderPlugin::~AudioFfmpegEncoderPlugin() int32_t AudioFfmpegEncoderPlugin::ProcessSendData(const std::shared_ptr &inputBuffer) { + std::lock_guard lock(avMutext_); if (avCodecContext_ == nullptr) { AVCODEC_LOGE("avCodecContext_ is nullptr"); return AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION; } - std::unique_lock lock(avMutext_); return SendBuffer(inputBuffer); } @@ -65,7 +70,8 @@ int32_t AudioFfmpegEncoderPlugin::PcmFillFrame(const std::shared_ptrsample_fmt)) { if (cachedFrame_->nb_samples > frameSize) { AVCODEC_LOGE("cachedFrame_->nb_samples is greater than frameSize, please enter a correct frameBytes." - "hint: nb_samples is %{public}d. frameSize is %{public}d.", cachedFrame_->nb_samples, frameSize); + "hint: nb_samples is %{public}d. frameSize is %{public}d.", + cachedFrame_->nb_samples, frameSize); return AVCodecServiceErrCode::AVCS_ERR_UNKNOWN; } cachedFrame_->data[0] = memory->GetBase(); @@ -115,7 +121,7 @@ int32_t AudioFfmpegEncoderPlugin::SendBuffer(const std::shared_ptr memory->GetSize()) { AVCODEC_LOGE("send input buffer is > allocate size. size : %{public}d, allocate size : %{public}d", - attr.size, memory->GetSize()); + attr.size, memory->GetSize()); return AVCodecServiceErrCode::AVCS_ERR_UNKNOWN; } auto errCode = PcmFillFrame(inputBuffer); @@ -148,7 +154,7 @@ int32_t AudioFfmpegEncoderPlugin::ProcessRecieveData(std::shared_ptr lock(avMutext_); if (avCodecContext_ == nullptr) { AVCODEC_LOGE("avCodecContext_ is nullptr"); return AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION; @@ -218,6 +224,7 @@ int32_t AudioFfmpegEncoderPlugin::ReceivePacketSucc(std::shared_ptr lock(avMutext_); auto ret = CloseCtxLocked(); avCodecContext_.reset(); prevPts_ = 0; @@ -226,7 +233,7 @@ int32_t AudioFfmpegEncoderPlugin::Reset() int32_t AudioFfmpegEncoderPlugin::Release() { - std::unique_lock lock(avMutext_); + std::lock_guard lock(avMutext_); auto ret = CloseCtxLocked(); avCodecContext_.reset(); return ret; @@ -234,7 +241,7 @@ int32_t AudioFfmpegEncoderPlugin::Release() int32_t AudioFfmpegEncoderPlugin::Flush() { - std::unique_lock lock(avMutext_); + std::lock_guard lock(avMutext_); if (avCodecContext_ != nullptr) { avcodec_flush_buffers(avCodecContext_.get()); } @@ -245,7 +252,7 @@ int32_t AudioFfmpegEncoderPlugin::Flush() int32_t AudioFfmpegEncoderPlugin::AllocateContext(const std::string &name) { { - std::unique_lock lock(avMutext_); + std::lock_guard lock(avMutext_); avCodec_ = std::shared_ptr(const_cast(avcodec_find_encoder_by_name(name.c_str())), [](AVCodec *ptr) {}); cachedFrame_ = std::shared_ptr(av_frame_alloc(), [](AVFrame *fp) { av_frame_free(&fp); }); @@ -257,7 +264,7 @@ int32_t AudioFfmpegEncoderPlugin::AllocateContext(const std::string &name) AVCodecContext *context = nullptr; { - std::unique_lock lock(avMutext_); + std::lock_guard lock(avMutext_); context = avcodec_alloc_context3(avCodec_.get()); avCodecContext_ = std::shared_ptr(context, [](AVCodecContext *ptr) { avcodec_free_context(&ptr); @@ -301,7 +308,7 @@ int32_t AudioFfmpegEncoderPlugin::InitContext(const Format &format) int32_t AudioFfmpegEncoderPlugin::OpenContext() { { - std::unique_lock lock(avMutext_); + std::lock_guard lock(avMutext_); auto res = avcodec_open2(avCodecContext_.get(), avCodec_.get(), nullptr); if (res != 0) { AVCODEC_LOGE("avcodec open error %{public}s", AVStrError(res).c_str()); diff --git a/services/engine/codec/include/audio/audio_codec_adapter.h b/services/engine/codec/include/audio/audio_codec_adapter.h index 51719e7b7571181fa832028e06a85449a20268a6..20ef66f4fa1a632da90e70f3976aaa9c81a61628 100644 --- a/services/engine/codec/include/audio/audio_codec_adapter.h +++ b/services/engine/codec/include/audio/audio_codec_adapter.h @@ -16,8 +16,8 @@ #ifndef CODEC_EENGIN_AUDIO_FFMPEG_ADAPTER_H #define CODEC_EENGIN_AUDIO_FFMPEG_ADAPTER_H -#include "audio_codec_worker.h" #include "audio_base_codec.h" +#include "audio_codec_worker.h" #include "avcodec_common.h" #include "codecbase.h" #include "nocopyable.h" @@ -50,12 +50,8 @@ public: int32_t GetOutputFormat(Format &format) override; - std::shared_ptr GetInputBuffer(uint32_t index) override; - int32_t QueueInputBuffer(uint32_t index, const AVCodecBufferInfo &info, AVCodecBufferFlag flag) override; - std::shared_ptr GetOutputBuffer(uint32_t index) override; - int32_t ReleaseOutputBuffer(uint32_t index) override; private: diff --git a/test/nativedemo/audio_demo/avcodec_audio_decoder_inner_demo.cpp b/test/nativedemo/audio_demo/avcodec_audio_decoder_inner_demo.cpp index f701d55bcb1140c3648dbcbfe3a5c12d0bd3f510..a40cad0443aa6e65052df3cecf07de62023a5603 100644 --- a/test/nativedemo/audio_demo/avcodec_audio_decoder_inner_demo.cpp +++ b/test/nativedemo/audio_demo/avcodec_audio_decoder_inner_demo.cpp @@ -63,7 +63,7 @@ void ADecInnerDemo::RunCase() DEMO_CHECK_AND_RETURN_LOG(Configure(format) == AVCS_ERR_OK, "Fatal: Configure fail"); DEMO_CHECK_AND_RETURN_LOG(Start() == AVCS_ERR_OK, "Fatal: Start fail"); - + unique_lock lock(signal_->startMutex_); signal_->startCond_.wait(lock, [this]() { return (!(isRunning_.load())); }); @@ -156,6 +156,7 @@ void ADecInnerDemo::HandleInputEOS(const uint32_t &index) flag = AVCodecBufferFlag::AVCODEC_BUFFER_FLAG_EOS; (void)audioDec_->QueueInputBuffer(index, attr, flag); signal_->inQueue_.pop(); + signal_->inBufferQueue_.pop(); std::cout << "end buffer\n"; } @@ -170,6 +171,7 @@ int32_t ADecInnerDemo::HandleNormalInput(const uint32_t &index, const int64_t &p frameCount_++; auto result = audioDec_->QueueInputBuffer(index, attr, flag); signal_->inQueue_.pop(); + signal_->inBufferQueue_.pop(); return result; } @@ -187,7 +189,7 @@ void ADecInnerDemo::InputFunc() break; } uint32_t index = signal_->inQueue_.front(); - std::shared_ptr buffer = audioDec_->GetInputBuffer(index); + std::shared_ptr buffer = signal_->inBufferQueue_.front(); if (buffer == nullptr) { isRunning_.store(false); std::cout << "buffer is null:" << index << "\n"; @@ -232,7 +234,7 @@ void ADecInnerDemo::OutputFunc() } uint32_t index = signal_->outQueue_.front(); - auto buffer = audioDec_->GetOutputBuffer(index); + auto buffer = signal_->outBufferQueue_.front(); if (buffer == nullptr) { cout << "get output buffer failed" << endl; isRunning_.store(false); @@ -254,6 +256,7 @@ void ADecInnerDemo::OutputFunc() signal_->outQueue_.pop(); signal_->infoQueue_.pop(); signal_->flagQueue_.pop(); + signal_->outBufferQueue_.pop(); } } @@ -270,15 +273,17 @@ void ADecDemoCallback::OnOutputFormatChanged(const Format &format) cout << "OnOutputFormatChanged received" << endl; } -void ADecDemoCallback::OnInputBufferAvailable(uint32_t index) +void ADecDemoCallback::OnInputBufferAvailable(uint32_t index, std::shared_ptr buffer) { cout << "OnInputBufferAvailable received, index:" << index << endl; unique_lock lock(signal_->inMutex_); signal_->inQueue_.push(index); + signal_->inBufferQueue_.push(buffer); signal_->inCond_.notify_all(); } -void ADecDemoCallback::OnOutputBufferAvailable(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag) +void ADecDemoCallback::OnOutputBufferAvailable(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag, + std::shared_ptr buffer) { (void)info; (void)flag; @@ -287,5 +292,6 @@ void ADecDemoCallback::OnOutputBufferAvailable(uint32_t index, AVCodecBufferInfo signal_->outQueue_.push(index); signal_->infoQueue_.push(info); signal_->flagQueue_.push(flag); + signal_->outBufferQueue_.push(buffer); signal_->outCond_.notify_all(); } \ No newline at end of file diff --git a/test/nativedemo/audio_demo/avcodec_audio_decoder_inner_demo.h b/test/nativedemo/audio_demo/avcodec_audio_decoder_inner_demo.h index 5a83622222ed5eb501ec1571346f96dcebf64627..a8f763d1814b5bfc39806ad3698e2b08f590d9e0 100644 --- a/test/nativedemo/audio_demo/avcodec_audio_decoder_inner_demo.h +++ b/test/nativedemo/audio_demo/avcodec_audio_decoder_inner_demo.h @@ -38,6 +38,8 @@ public: std::condition_variable startCond_; std::queue inQueue_; std::queue outQueue_; + std::queue> inBufferQueue_; + std::queue> outBufferQueue_; std::queue infoQueue_; std::queue flagQueue_; }; @@ -49,8 +51,9 @@ public: void OnError(AVCodecErrorType errorType, int32_t errorCode) override; void OnOutputFormatChanged(const Format &format) override; - void OnInputBufferAvailable(uint32_t index) override; - void OnOutputBufferAvailable(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag) override; + void OnInputBufferAvailable(uint32_t index, std::shared_ptr buffer) override; + void OnOutputBufferAvailable(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag, + std::shared_ptr buffer) override; private: std::shared_ptr signal_; diff --git a/test/nativedemo/audio_demo/avcodec_audio_encoder_inner_demo.cpp b/test/nativedemo/audio_demo/avcodec_audio_encoder_inner_demo.cpp index 0a1b0c6256fd58a54c5f300dc8491839b7fed886..ad4d18ce1c66013b434db92b8d7738aea9eb7827 100644 --- a/test/nativedemo/audio_demo/avcodec_audio_encoder_inner_demo.cpp +++ b/test/nativedemo/audio_demo/avcodec_audio_encoder_inner_demo.cpp @@ -162,7 +162,7 @@ void AEnInnerDemo::InputFunc() } uint32_t index = signal_->inQueue_.front(); - std::shared_ptr buffer = audioEn_->GetInputBuffer(index); + std::shared_ptr buffer = signal_->inBufferQueue_.front(); if (buffer == nullptr) { isRunning_.store(false); std::cout << "buffer is null:" << index << "\n"; @@ -176,11 +176,13 @@ void AEnInnerDemo::InputFunc() flag = AVCodecBufferFlag::AVCODEC_BUFFER_FLAG_EOS; (void)audioEn_->QueueInputBuffer(index, attr, flag); signal_->inQueue_.pop(); + signal_->inBufferQueue_.pop(); std::cout << "end buffer\n"; break; } auto result = audioEn_->QueueInputBuffer(index, attr, flag); signal_->inQueue_.pop(); + signal_->inBufferQueue_.pop(); if (result != AVCS_ERR_OK) { std::cout << "QueueInputBuffer error:\n"; isRunning_ = false; @@ -205,7 +207,7 @@ void AEnInnerDemo::OutputFunc() } uint32_t index = signal_->outQueue_.front(); - auto buffer = audioEn_->GetOutputBuffer(index); + auto buffer = signal_->outBufferQueue_.front(); if (buffer == nullptr) { cout << "get output buffer failed" << endl; isRunning_.store(false); @@ -221,6 +223,7 @@ void AEnInnerDemo::OutputFunc() signal_->outQueue_.pop(); signal_->sizeQueue_.pop(); + signal_->outBufferQueue_.pop(); } } @@ -237,15 +240,17 @@ void AEnDemoCallback::OnOutputFormatChanged(const Format &format) cout << "OnOutputFormatChanged received" << endl; } -void AEnDemoCallback::OnInputBufferAvailable(uint32_t index) +void AEnDemoCallback::OnInputBufferAvailable(uint32_t index, std::shared_ptr buffer) { cout << "OnInputBufferAvailable received, index:" << index << endl; unique_lock lock(signal_->inMutex_); signal_->inQueue_.push(index); + signal_->inBufferQueue_.push(buffer); signal_->inCond_.notify_all(); } -void AEnDemoCallback::OnOutputBufferAvailable(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag) +void AEnDemoCallback::OnOutputBufferAvailable(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag, + std::shared_ptr buffer) { (void)info; (void)flag; @@ -253,6 +258,7 @@ void AEnDemoCallback::OnOutputBufferAvailable(uint32_t index, AVCodecBufferInfo unique_lock lock(signal_->outMutex_); signal_->outQueue_.push(index); signal_->sizeQueue_.push(info); + signal_->outBufferQueue_.push(buffer); cout << "**********out info size = " << info.size << endl; signal_->outCond_.notify_all(); } \ No newline at end of file diff --git a/test/nativedemo/audio_demo/avcodec_audio_encoder_inner_demo.h b/test/nativedemo/audio_demo/avcodec_audio_encoder_inner_demo.h index 6e84b6116ad31f2e3d4b21d3a6812fabbab650b4..a3c0aa91a833c7cc997d4a71f43f399b8f96ae04 100644 --- a/test/nativedemo/audio_demo/avcodec_audio_encoder_inner_demo.h +++ b/test/nativedemo/audio_demo/avcodec_audio_encoder_inner_demo.h @@ -35,6 +35,8 @@ public: std::condition_variable inCond_; std::condition_variable outCond_; std::queue inQueue_; + std::queue> inBufferQueue_; + std::queue> outBufferQueue_; std::queue outQueue_; std::queue sizeQueue_; }; @@ -46,8 +48,9 @@ public: void OnError(AVCodecErrorType errorType, int32_t errorCode) override; void OnOutputFormatChanged(const Format &format) override; - void OnInputBufferAvailable(uint32_t index) override; - void OnOutputBufferAvailable(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag) override; + void OnInputBufferAvailable(uint32_t index, std::shared_ptr buffer) override; + void OnOutputBufferAvailable(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag, + std::shared_ptr buffer) override; private: std::shared_ptr signal_; diff --git a/test/unittest/audio_test/audio_decoder_codecbase_unit_test.cpp b/test/unittest/audio_test/audio_decoder_codecbase_unit_test.cpp index b6a25cf01cee2e494385e5f968a34ce6c7b1946f..439e94e48a08fab9f283f486450dccbe470b3dbe 100644 --- a/test/unittest/audio_test/audio_decoder_codecbase_unit_test.cpp +++ b/test/unittest/audio_test/audio_decoder_codecbase_unit_test.cpp @@ -112,15 +112,15 @@ public: protected: int32_t index_; - int64_t timeStamp_ {0}; + int64_t timeStamp_{0}; ADecSignal *signal_; - FILE *inFile_ {nullptr}; - FILE *dumpFd_ {nullptr}; + FILE *inFile_{nullptr}; + FILE *dumpFd_{nullptr}; OHOS::MediaAVCodec::Format format_; - std::shared_ptr adec_ {nullptr}; + std::shared_ptr adec_{nullptr}; }; void AudioCodeDecoderUnitTest::SetUpTestCase(void) @@ -149,8 +149,7 @@ int32_t AudioCodeDecoderUnitTest::CreateMp3CodecFunc(void) adec_ = std::make_shared(CODEC_MP3_NAME); signal_ = new ADecSignal(); - adec_->SetCallback( - std::shared_ptr(std::make_shared(signal_))); + adec_->SetCallback(std::shared_ptr(std::make_shared(signal_))); sleep(1); return AVCodecServiceErrCode::AVCS_ERR_OK; } @@ -160,8 +159,7 @@ int32_t AudioCodeDecoderUnitTest::CreateFlacCodecFunc(void) adec_ = std::make_shared(CODEC_FLAC_NAME); signal_ = new ADecSignal(); - adec_->SetCallback( - std::shared_ptr(std::make_shared(signal_))); + adec_->SetCallback(std::shared_ptr(std::make_shared(signal_))); sleep(1); return AVCodecServiceErrCode::AVCS_ERR_OK; } @@ -171,8 +169,7 @@ int32_t AudioCodeDecoderUnitTest::CreateAacCodecFunc(void) adec_ = std::make_shared(CODEC_AAC_NAME); signal_ = new ADecSignal(); - adec_->SetCallback( - std::shared_ptr(std::make_shared(signal_))); + adec_->SetCallback(std::shared_ptr(std::make_shared(signal_))); sleep(1); return AVCodecServiceErrCode::AVCS_ERR_OK; } @@ -220,7 +217,6 @@ int32_t AudioCodeDecoderUnitTest::ProceAacFunc(void) return AVCodecServiceErrCode::AVCS_ERR_OK; } - HWTEST_F(AudioCodeDecoderUnitTest, audioDecoder_Mp3_Configure_01, TestSize.Level1) { // lack of correct key @@ -425,25 +421,6 @@ HWTEST_F(AudioCodeDecoderUnitTest, audioDecoder_Mp3_GetOutputFormat_01, TestSize EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, adec_->GetOutputFormat(format_)); } -HWTEST_F(AudioCodeDecoderUnitTest, audioDecoder_Mp3_GetInputBuffer_01, TestSize.Level1) -{ - EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateMp3CodecFunc()); - EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, ProceMp3Func()); - sleep(1); - std::shared_ptr buffer = nullptr; - index_ = -1; - buffer = adec_->GetInputBuffer(index_); - EXPECT_EQ(nullptr, buffer); - - index_ = 1024; - buffer = adec_->GetInputBuffer(index_); - EXPECT_EQ(nullptr, buffer); - - index_ = signal_->inIdxQueue_.front(); - buffer = adec_->GetInputBuffer(index_); - EXPECT_NE(nullptr, buffer); -} - HWTEST_F(AudioCodeDecoderUnitTest, audioDecoder_Mp3_QueueInputBuffer_01, TestSize.Level1) { EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateMp3CodecFunc()); @@ -469,21 +446,6 @@ HWTEST_F(AudioCodeDecoderUnitTest, audioDecoder_Mp3_QueueInputBuffer_01, TestSiz sleep(1); } -HWTEST_F(AudioCodeDecoderUnitTest, audioDecoder_Mp3_GetOutputBuffer_01, TestSize.Level1) -{ - EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateMp3CodecFunc()); - EXPECT_EQ(AVCS_ERR_OK, ProceMp3Func()); - std::shared_ptr buffer = nullptr; - - // case1 传参异常 - index_ = -1; - buffer = adec_->GetOutputBuffer(index_); - EXPECT_EQ(nullptr, buffer); - index_ = 1024; - buffer = adec_->GetOutputBuffer(index_); - EXPECT_EQ(nullptr, buffer); -} - HWTEST_F(AudioCodeDecoderUnitTest, audioDecoder_Mp3_ReleaseOutputBuffer_01, TestSize.Level1) { EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateMp3CodecFunc()); @@ -698,25 +660,6 @@ HWTEST_F(AudioCodeDecoderUnitTest, audioDecoder_Flac_GetOutputFormat_01, TestSiz EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, adec_->GetOutputFormat(format_)); } -HWTEST_F(AudioCodeDecoderUnitTest, audioDecoder_Flac_GetInputBuffer_01, TestSize.Level1) -{ - EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateFlacCodecFunc()); - EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, ProceFlacFunc()); - sleep(1); - std::shared_ptr buffer = nullptr; - index_ = -1; - buffer = adec_->GetInputBuffer(index_); - EXPECT_EQ(nullptr, buffer); - - index_ = 1024; - buffer = adec_->GetInputBuffer(index_); - EXPECT_EQ(nullptr, buffer); - - index_ = signal_->inIdxQueue_.front(); - buffer = adec_->GetInputBuffer(index_); - EXPECT_NE(nullptr, buffer); -} - HWTEST_F(AudioCodeDecoderUnitTest, audioDecoder_Flac_QueueInputBuffer_01, TestSize.Level1) { EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateFlacCodecFunc()); @@ -742,21 +685,6 @@ HWTEST_F(AudioCodeDecoderUnitTest, audioDecoder_Flac_QueueInputBuffer_01, TestSi sleep(1); } -HWTEST_F(AudioCodeDecoderUnitTest, audioDecoder_Flac_GetOutputBuffer_01, TestSize.Level1) -{ - EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateFlacCodecFunc()); - EXPECT_EQ(AVCS_ERR_OK, ProceFlacFunc()); - std::shared_ptr buffer = nullptr; - - // case1 传参异常 - index_ = -1; - buffer = adec_->GetOutputBuffer(index_); - EXPECT_EQ(nullptr, buffer); - index_ = 1024; - buffer = adec_->GetOutputBuffer(index_); - EXPECT_EQ(nullptr, buffer); -} - HWTEST_F(AudioCodeDecoderUnitTest, audioDecoder_Flac_ReleaseOutputBuffer_01, TestSize.Level1) { EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateFlacCodecFunc()); @@ -1026,25 +954,6 @@ HWTEST_F(AudioCodeDecoderUnitTest, audioDecoder_Aac_GetOutputFormat_01, TestSize EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, adec_->GetOutputFormat(format_)); } -HWTEST_F(AudioCodeDecoderUnitTest, audioDecoder_Aac_GetInputBuffer_01, TestSize.Level1) -{ - EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateAacCodecFunc()); - EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, ProceAacFunc()); - sleep(1); - std::shared_ptr buffer = nullptr; - index_ = -1; - buffer = adec_->GetInputBuffer(index_); - EXPECT_EQ(nullptr, buffer); - - index_ = 1024; - buffer = adec_->GetInputBuffer(index_); - EXPECT_EQ(nullptr, buffer); - - index_ = signal_->inIdxQueue_.front(); - buffer = adec_->GetInputBuffer(index_); - EXPECT_NE(nullptr, buffer); -} - HWTEST_F(AudioCodeDecoderUnitTest, audioDecoder_Aac_QueueInputBuffer_01, TestSize.Level1) { EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateAacCodecFunc()); @@ -1070,21 +979,6 @@ HWTEST_F(AudioCodeDecoderUnitTest, audioDecoder_Aac_QueueInputBuffer_01, TestSiz sleep(1); } -HWTEST_F(AudioCodeDecoderUnitTest, audioDecoder_Aac_GetOutputBuffer_01, TestSize.Level1) -{ - EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateAacCodecFunc()); - EXPECT_EQ(AVCS_ERR_OK, ProceAacFunc()); - std::shared_ptr buffer = nullptr; - - // case1 传参异常 - index_ = -1; - buffer = adec_->GetOutputBuffer(index_); - EXPECT_EQ(nullptr, buffer); - index_ = 1024; - buffer = adec_->GetOutputBuffer(index_); - EXPECT_EQ(nullptr, buffer); -} - HWTEST_F(AudioCodeDecoderUnitTest, audioDecoder_Aac_ReleaseOutputBuffer_01, TestSize.Level1) { EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateAacCodecFunc()); diff --git a/test/unittest/audio_test/audio_decoder_inner_unit_test.cpp b/test/unittest/audio_test/audio_decoder_inner_unit_test.cpp index ddcf1097179c19b2df6c7527d56bc769969b49b4..c92e6c83341c9f2d3730ef1cfd5c702a82d5bb5b 100644 --- a/test/unittest/audio_test/audio_decoder_inner_unit_test.cpp +++ b/test/unittest/audio_test/audio_decoder_inner_unit_test.cpp @@ -53,6 +53,8 @@ public: std::condition_variable inCond_; std::condition_variable outCond_; std::queue inIdxQueue_; + std::queue> inBufferQueue_; + std::queue> outBufferQueue_; std::queue outIdxQueue_; std::queue infoQueue_; std::queue flagQueue_; @@ -65,8 +67,9 @@ public: ADecSignal *userData_; void OnError(AVCodecErrorType errorType, int32_t errorCode) override; void OnOutputFormatChanged(const Format &format) override; - void OnInputBufferAvailable(uint32_t index) override; - void OnOutputBufferAvailable(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag) override; + void OnInputBufferAvailable(uint32_t index, std::shared_ptr buffer) override; + void OnOutputBufferAvailable(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag, + std::shared_ptr buffer) override; }; void BufferCallback::OnError(AVCodecErrorType errorType, int32_t errorCode) @@ -81,19 +84,22 @@ void BufferCallback::OnOutputFormatChanged(const Format &format) cout << "Format Changed" << endl; } -void BufferCallback::OnInputBufferAvailable(uint32_t index) +void BufferCallback::OnInputBufferAvailable(uint32_t index, std::shared_ptr buffer) { unique_lock lock(userData_->inMutex_); userData_->inIdxQueue_.push(index); + userData_->inBufferQueue_.push(buffer); userData_->inCond_.notify_all(); } -void BufferCallback::OnOutputBufferAvailable(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag) +void BufferCallback::OnOutputBufferAvailable(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag, + std::shared_ptr buffer) { unique_lock lock(userData_->outMutex_); userData_->outIdxQueue_.push(index); userData_->infoQueue_.push(info); userData_->flagQueue_.push(flag); + userData_->outBufferQueue_.push(buffer); userData_->outCond_.notify_all(); (void)flag; } @@ -422,25 +428,6 @@ HWTEST_F(AudioCodeDecoderInnerUnitTest, audioDecoder_Mp3_GetOutputFormat_01, Tes EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, adec_->GetOutputFormat(format_)); } -HWTEST_F(AudioCodeDecoderInnerUnitTest, audioDecoder_Mp3_GetInputBuffer_01, TestSize.Level1) -{ - EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateMp3CodecFunc()); - EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, ProceMp3Func()); - sleep(1); - std::shared_ptr buffer = nullptr; - index_ = -1; - buffer = adec_->GetInputBuffer(index_); - EXPECT_EQ(nullptr, buffer); - - index_ = 1024; - buffer = adec_->GetInputBuffer(index_); - EXPECT_EQ(nullptr, buffer); - - index_ = signal_->inIdxQueue_.front(); - buffer = adec_->GetInputBuffer(index_); - EXPECT_NE(nullptr, buffer); -} - HWTEST_F(AudioCodeDecoderInnerUnitTest, audioDecoder_Mp3_QueueInputBuffer_01, TestSize.Level1) { EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateMp3CodecFunc()); @@ -466,21 +453,6 @@ HWTEST_F(AudioCodeDecoderInnerUnitTest, audioDecoder_Mp3_QueueInputBuffer_01, Te sleep(1); } -HWTEST_F(AudioCodeDecoderInnerUnitTest, audioDecoder_Mp3_GetOutputBuffer_01, TestSize.Level1) -{ - EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateMp3CodecFunc()); - EXPECT_EQ(AVCS_ERR_OK, ProceMp3Func()); - std::shared_ptr buffer = nullptr; - - // case1 传参异常 - index_ = -1; - buffer = adec_->GetOutputBuffer(index_); - EXPECT_EQ(nullptr, buffer); - index_ = 1024; - buffer = adec_->GetOutputBuffer(index_); - EXPECT_EQ(nullptr, buffer); -} - HWTEST_F(AudioCodeDecoderInnerUnitTest, audioDecoder_Mp3_ReleaseOutputBuffer_01, TestSize.Level1) { EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateMp3CodecFunc()); @@ -687,25 +659,6 @@ HWTEST_F(AudioCodeDecoderInnerUnitTest, audioDecoder_Flac_GetOutputFormat_01, Te EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, adec_->GetOutputFormat(format_)); } -HWTEST_F(AudioCodeDecoderInnerUnitTest, audioDecoder_Flac_GetInputBuffer_01, TestSize.Level1) -{ - EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateFlacCodecFunc()); - EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, ProceFlacFunc()); - sleep(1); - std::shared_ptr buffer = nullptr; - index_ = -1; - buffer = adec_->GetInputBuffer(index_); - EXPECT_EQ(nullptr, buffer); - - index_ = 1024; - buffer = adec_->GetInputBuffer(index_); - EXPECT_EQ(nullptr, buffer); - - index_ = signal_->inIdxQueue_.front(); - buffer = adec_->GetInputBuffer(index_); - EXPECT_NE(nullptr, buffer); -} - HWTEST_F(AudioCodeDecoderInnerUnitTest, audioDecoder_Flac_QueueInputBuffer_01, TestSize.Level1) { EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateFlacCodecFunc()); @@ -731,21 +684,6 @@ HWTEST_F(AudioCodeDecoderInnerUnitTest, audioDecoder_Flac_QueueInputBuffer_01, T sleep(1); } -HWTEST_F(AudioCodeDecoderInnerUnitTest, audioDecoder_Flac_GetOutputBuffer_01, TestSize.Level1) -{ - EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateFlacCodecFunc()); - EXPECT_EQ(AVCS_ERR_OK, ProceFlacFunc()); - std::shared_ptr buffer = nullptr; - - // case1 传参异常 - index_ = -1; - buffer = adec_->GetOutputBuffer(index_); - EXPECT_EQ(nullptr, buffer); - index_ = 1024; - buffer = adec_->GetOutputBuffer(index_); - EXPECT_EQ(nullptr, buffer); -} - HWTEST_F(AudioCodeDecoderInnerUnitTest, audioDecoder_Flac_ReleaseOutputBuffer_01, TestSize.Level1) { EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateFlacCodecFunc()); @@ -1007,25 +945,6 @@ HWTEST_F(AudioCodeDecoderInnerUnitTest, audioDecoder_Aac_GetOutputFormat_01, Tes EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, adec_->GetOutputFormat(format_)); } -HWTEST_F(AudioCodeDecoderInnerUnitTest, audioDecoder_Aac_GetInputBuffer_01, TestSize.Level1) -{ - EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateAacCodecFunc()); - EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, ProceAacFunc()); - sleep(1); - std::shared_ptr buffer = nullptr; - index_ = -1; - buffer = adec_->GetInputBuffer(index_); - EXPECT_EQ(nullptr, buffer); - - index_ = 1024; - buffer = adec_->GetInputBuffer(index_); - EXPECT_EQ(nullptr, buffer); - - index_ = signal_->inIdxQueue_.front(); - buffer = adec_->GetInputBuffer(index_); - EXPECT_NE(nullptr, buffer); -} - HWTEST_F(AudioCodeDecoderInnerUnitTest, audioDecoder_Aac_QueueInputBuffer_01, TestSize.Level1) { EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateAacCodecFunc()); @@ -1051,21 +970,6 @@ HWTEST_F(AudioCodeDecoderInnerUnitTest, audioDecoder_Aac_QueueInputBuffer_01, Te sleep(1); } -HWTEST_F(AudioCodeDecoderInnerUnitTest, audioDecoder_Aac_GetOutputBuffer_01, TestSize.Level1) -{ - EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateAacCodecFunc()); - EXPECT_EQ(AVCS_ERR_OK, ProceAacFunc()); - std::shared_ptr buffer = nullptr; - - // case1 传参异常 - index_ = -1; - buffer = adec_->GetOutputBuffer(index_); - EXPECT_EQ(nullptr, buffer); - index_ = 1024; - buffer = adec_->GetOutputBuffer(index_); - EXPECT_EQ(nullptr, buffer); -} - HWTEST_F(AudioCodeDecoderInnerUnitTest, audioDecoder_Aac_ReleaseOutputBuffer_01, TestSize.Level1) { EXPECT_EQ(AVCodecServiceErrCode::AVCS_ERR_OK, CreateAacCodecFunc());