From d2b7eaa551c7ef394cc6f601f486b2e3f73eda5b Mon Sep 17 00:00:00 2001 From: zhuxu Date: Tue, 27 Dec 2022 16:37:10 +0800 Subject: [PATCH] fix: modify distributed camera mutex Signed-off-by: zhuxu --- .../multimedia_codec/decoder/decode_data_process.h | 1 + .../multimedia_codec/decoder/decode_data_process.cpp | 7 ++++--- .../decoder/decode_data_process_common.cpp | 7 ++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/services/data_process/include/pipeline_node/multimedia_codec/decoder/decode_data_process.h b/services/data_process/include/pipeline_node/multimedia_codec/decoder/decode_data_process.h index 830fe626..7ac0c2bc 100644 --- a/services/data_process/include/pipeline_node/multimedia_codec/decoder/decode_data_process.h +++ b/services/data_process/include/pipeline_node/multimedia_codec/decoder/decode_data_process.h @@ -118,6 +118,7 @@ private: std::shared_ptr eventBusPipeline_; std::weak_ptr callbackPipelineSource_; + std::mutex mtxDecoderLock_; std::mutex mtxDecoderState_; std::mutex mtxHoldCount_; VideoConfigParams sourceConfig_; diff --git a/services/data_process/src/pipeline_node/multimedia_codec/decoder/decode_data_process.cpp b/services/data_process/src/pipeline_node/multimedia_codec/decoder/decode_data_process.cpp index 14158e7a..1eff94ef 100644 --- a/services/data_process/src/pipeline_node/multimedia_codec/decoder/decode_data_process.cpp +++ b/services/data_process/src/pipeline_node/multimedia_codec/decoder/decode_data_process.cpp @@ -272,8 +272,9 @@ int32_t DecodeDataProcess::StopVideoDecoder() void DecodeDataProcess::ReleaseVideoDecoder() { - std::lock_guard lck(mtxDecoderState_); DHLOGD("Start release videoDecoder."); + std::lock_guard inputLock(mtxDecoderLock_); + std::lock_guard outputLock(mtxDecoderState_); if (videoDecoder_ == nullptr) { DHLOGE("The video decoder does not exist before ReleaseVideoDecoder."); decodeVideoCallback_ = nullptr; @@ -405,7 +406,7 @@ int32_t DecodeDataProcess::FeedDecoderInputBuffer() } { - std::lock_guard lck(mtxDecoderState_); + std::lock_guard inputLock(mtxDecoderLock_); if (videoDecoder_ == nullptr) { DHLOGE("The video decoder does not exist before GetInputBuffer."); return DCAMERA_OK; @@ -769,7 +770,7 @@ void DecodeDataProcess::OnOutputBufferAvailable(uint32_t index, const Media::AVC info.presentationTimeUs, info.size, info.offset, flag); outputInfo_ = info; { - std::lock_guard lck(mtxDecoderState_); + std::lock_guard outputLock(mtxDecoderState_); if (videoDecoder_ == nullptr) { DHLOGE("The video decoder does not exist before decoding data."); return; diff --git a/services/data_process/src/pipeline_node/multimedia_codec/decoder/decode_data_process_common.cpp b/services/data_process/src/pipeline_node/multimedia_codec/decoder/decode_data_process_common.cpp index 6a42895d..d6c48932 100644 --- a/services/data_process/src/pipeline_node/multimedia_codec/decoder/decode_data_process_common.cpp +++ b/services/data_process/src/pipeline_node/multimedia_codec/decoder/decode_data_process_common.cpp @@ -261,8 +261,9 @@ int32_t DecodeDataProcess::StopVideoDecoder() void DecodeDataProcess::ReleaseVideoDecoder() { - std::lock_guard lck(mtxDecoderState_); DHLOGD("Start release videoDecoder."); + std::lock_guard inputLock(mtxDecoderLock_); + std::lock_guard outputLock(mtxDecoderState_); if (videoDecoder_ == nullptr) { DHLOGE("The video decoder does not exist before ReleaseVideoDecoder."); decodeVideoCallback_ = nullptr; @@ -394,7 +395,7 @@ int32_t DecodeDataProcess::FeedDecoderInputBuffer() } { - std::lock_guard lck(mtxDecoderState_); + std::lock_guard inputLock(mtxDecoderLock_); if (videoDecoder_ == nullptr) { DHLOGE("The video decoder does not exist before GetInputBuffer."); return DCAMERA_OK; @@ -652,7 +653,7 @@ void DecodeDataProcess::OnOutputBufferAvailable(uint32_t index, const Media::AVC info.presentationTimeUs, info.size, info.offset, flag); outputInfo_ = info; { - std::lock_guard lck(mtxDecoderState_); + std::lock_guard outputLock(mtxDecoderState_); if (videoDecoder_ == nullptr) { DHLOGE("The video decoder does not exist before decoding data."); return; -- Gitee