diff --git a/services/data_process/include/pipeline_node/multimedia_codec/decode_data_process.h b/services/data_process/include/pipeline_node/multimedia_codec/decode_data_process.h index 8843eaad67a2d6e287d5c1d3abf1295e8f09f86f..0695f92b39ab99c4a88f9b8522bb0d76d5212f31 100644 --- a/services/data_process/include/pipeline_node/multimedia_codec/decode_data_process.h +++ b/services/data_process/include/pipeline_node/multimedia_codec/decode_data_process.h @@ -78,7 +78,6 @@ private: int32_t InitDecoder(); int32_t InitDecoderMetadataFormat(); int32_t SetDecoderOutputSurface(); - void ReleaseDecoder(); int32_t FeedDecoderInputBuffer(); int64_t GetDecoderTimeStamp(); int32_t GetAlignedHeight(); @@ -113,6 +112,7 @@ private: std::shared_ptr decodeVideoCallback_ = nullptr; sptr decodeConsumerSurface_ = nullptr; sptr decodeProducerSurface_ = nullptr; + sptr decodeSurfaceListener_ = nullptr; bool isDecoderProcess_ = false; int32_t waitDecoderOutputCount_ = 0; @@ -131,7 +131,7 @@ class DecodeSurfaceListener : public IBufferConsumerListener { public: DecodeSurfaceListener(sptr surface, std::weak_ptr decodeVideoNode) : surface_(surface), decodeVideoNode_(decodeVideoNode) {} - ~DecodeSurfaceListener() = default; + ~DecodeSurfaceListener(); void OnBufferAvailable() override; void SetSurface(const sptr& surface); diff --git a/services/data_process/src/pipeline_node/multimedia_codec/decode_data_process.cpp b/services/data_process/src/pipeline_node/multimedia_codec/decode_data_process.cpp index 488dec5bf9580e5f4bfea1b593b854b0356cc4d8..52cb298fceaa1699458b2d243f0b5db9bab7034a 100644 --- a/services/data_process/src/pipeline_node/multimedia_codec/decode_data_process.cpp +++ b/services/data_process/src/pipeline_node/multimedia_codec/decode_data_process.cpp @@ -105,7 +105,7 @@ int32_t DecodeDataProcess::InitDecoder() return err; } - videoDecoder_ = Media::VideoDecoderFactory::CreateByName("OMX_hisi_video_decoder_avc"); + videoDecoder_ = Media::VideoDecoderFactory::CreateByMime(processType_); if (videoDecoder_ == nullptr) { DHLOGE("Create video decoder failed."); return DCAMERA_INIT_ERR; @@ -179,8 +179,7 @@ int32_t DecodeDataProcess::SetDecoderOutputSurface() } decodeConsumerSurface_->SetDefaultWidthAndHeight((int32_t)sourceConfig_.GetWidth(), (int32_t)sourceConfig_.GetHeight()); - sptr decodeSurfaceListener_ = new DecodeSurfaceListener(decodeConsumerSurface_, - shared_from_this()); + decodeSurfaceListener_ = new DecodeSurfaceListener(decodeConsumerSurface_, shared_from_this()); if (decodeConsumerSurface_->RegisterConsumerListener(decodeSurfaceListener_) != SURFACE_ERROR_OK) { DHLOGE("Register consumer listener fail."); @@ -230,12 +229,19 @@ void DecodeDataProcess::ReleaseProcessNode() videoDecoder_->Flush(); videoDecoder_->Stop(); videoDecoder_->Release(); - decodeConsumerSurface_ = nullptr; - decodeProducerSurface_ = nullptr; videoDecoder_ = nullptr; decodeVideoCallback_ = nullptr; } } + if (decodeConsumerSurface_ != nullptr) { + int32_t ret = decodeConsumerSurface_->UnregisterConsumerListener(); + if (ret != SURFACE_ERROR_OK) { + DHLOGE("Unregister consumer listener failed. Error type: %d.", ret); + } + decodeConsumerSurface_ = nullptr; + decodeProducerSurface_ = nullptr; + decodeSurfaceListener_ = nullptr; + } processType_ = ""; std::queue> emptyBuffersQueue; @@ -696,5 +702,11 @@ void DecodeSurfaceListener::SetDecodeVideoNode(const std::weak_ptr