From 596e64e044925c5565ab766e3f4fdfb9500e7586 Mon Sep 17 00:00:00 2001 From: gao_ziyu Date: Tue, 9 Jan 2024 20:52:52 +0800 Subject: [PATCH 1/2] fix status error Signed-off-by: gao_ziyu --- .../native/avcodec/avcodec_audio_codec_impl.cpp | 12 ++++++------ services/services/codec/server/codec_server.cpp | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/frameworks/native/avcodec/avcodec_audio_codec_impl.cpp b/frameworks/native/avcodec/avcodec_audio_codec_impl.cpp index 0c32f3974..fec056f03 100644 --- a/frameworks/native/avcodec/avcodec_audio_codec_impl.cpp +++ b/frameworks/native/avcodec/avcodec_audio_codec_impl.cpp @@ -202,13 +202,7 @@ int32_t AVCodecAudioCodecImpl::QueueInputBuffer(uint32_t index) inputBufferObjMap_.erase(index); } CHECK_AND_RETURN_RET_LOG(buffer != nullptr, AVCS_ERR_INVALID_STATE, "buffer not found"); - if (buffer->flag_ == AVCODEC_BUFFER_FLAG_EOS) { - AVCODEC_LOGI("EOS detected, QueueInputBuffer set eos status."); - codecService_->NotifyEos(); - } - mediaCodecProducer_->PushBuffer(buffer, true); - return 0; } @@ -232,6 +226,12 @@ int32_t AVCodecAudioCodecImpl::ReleaseOutputBuffer(uint32_t index) buffer = outputBufferObjMap_[index]; outputBufferObjMap_.erase(index); } + CHECK_AND_RETURN_RET_LOG(buffer != nullptr, AVCS_ERR_INVALID_STATE, "buffer is nullptr"); + if (buffer->flag_ == AVCODEC_BUFFER_FLAG_EOS) { + AVCODEC_LOGI("EOS detected, QueueInputBuffer set eos status."); + codecService_->NotifyEos(); + } + Media::Status ret = implConsumer_->ReleaseBuffer(buffer); return static_cast(ret); } diff --git a/services/services/codec/server/codec_server.cpp b/services/services/codec/server/codec_server.cpp index e2669a263..943099d0b 100644 --- a/services/services/codec/server/codec_server.cpp +++ b/services/services/codec/server/codec_server.cpp @@ -433,7 +433,7 @@ int32_t CodecServer::ReleaseOutputBuffer(uint32_t index, bool render) int32_t CodecServer::SetParameter(const Format &format) { std::lock_guard lock(mutex_); - CHECK_AND_RETURN_RET_LOG(status_ != INITIALIZED && status_ != CONFIGURED, AVCS_ERR_INVALID_STATE, + CHECK_AND_RETURN_RET_LOG(status_ == RUNNING || status_ == FLUSHED || status_ == END_OF_STREAM, AVCS_ERR_INVALID_STATE, "In invalid state, %{public}s", GetStatusDescription(status_).data()); CHECK_AND_RETURN_RET_LOG(codecBase_ != nullptr, AVCS_ERR_NO_MEMORY, "Codecbase is nullptr"); return codecBase_->SetParameter(format); @@ -767,6 +767,8 @@ int32_t CodecServer::Configure(const std::shared_ptr &meta) int32_t CodecServer::SetParameter(const std::shared_ptr ¶meter) { std::lock_guard lock(mutex_); + CHECK_AND_RETURN_RET_LOG(status_ == RUNNING || status_ == FLUSHED || status_ == END_OF_STREAM, AVCS_ERR_INVALID_STATE, + "In invalid state, %{public}s", GetStatusDescription(status_).data()); CHECK_AND_RETURN_RET_LOG(parameter != nullptr, AVCS_ERR_NO_MEMORY, "Codecbase is nullptr"); return codecBase_->SetParameter(parameter); } -- Gitee From de85602192002370a805de0e5c1f65648e11a7ba Mon Sep 17 00:00:00 2001 From: gao_ziyu Date: Tue, 9 Jan 2024 21:12:00 +0800 Subject: [PATCH 2/2] fix status error Signed-off-by: gao_ziyu --- services/services/codec/server/codec_server.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/services/codec/server/codec_server.cpp b/services/services/codec/server/codec_server.cpp index 943099d0b..5245fc4cd 100644 --- a/services/services/codec/server/codec_server.cpp +++ b/services/services/codec/server/codec_server.cpp @@ -433,7 +433,7 @@ int32_t CodecServer::ReleaseOutputBuffer(uint32_t index, bool render) int32_t CodecServer::SetParameter(const Format &format) { std::lock_guard lock(mutex_); - CHECK_AND_RETURN_RET_LOG(status_ == RUNNING || status_ == FLUSHED || status_ == END_OF_STREAM, AVCS_ERR_INVALID_STATE, + CHECK_AND_RETURN_RET_LOG(status_ != INITIALIZED && status_ != CONFIGURED, AVCS_ERR_INVALID_STATE, "In invalid state, %{public}s", GetStatusDescription(status_).data()); CHECK_AND_RETURN_RET_LOG(codecBase_ != nullptr, AVCS_ERR_NO_MEMORY, "Codecbase is nullptr"); return codecBase_->SetParameter(format); @@ -767,9 +767,9 @@ int32_t CodecServer::Configure(const std::shared_ptr &meta) int32_t CodecServer::SetParameter(const std::shared_ptr ¶meter) { std::lock_guard lock(mutex_); - CHECK_AND_RETURN_RET_LOG(status_ == RUNNING || status_ == FLUSHED || status_ == END_OF_STREAM, AVCS_ERR_INVALID_STATE, - "In invalid state, %{public}s", GetStatusDescription(status_).data()); CHECK_AND_RETURN_RET_LOG(parameter != nullptr, AVCS_ERR_NO_MEMORY, "Codecbase is nullptr"); + CHECK_AND_RETURN_RET_LOG(status_ != INITIALIZED && status_ != CONFIGURED, AVCS_ERR_INVALID_STATE, + "In invalid state, %{public}s", GetStatusDescription(status_).data()); return codecBase_->SetParameter(parameter); } int32_t CodecServer::GetOutputFormat(std::shared_ptr ¶meter) -- Gitee