From 3599573a571f29c5ee9c439af1d4c61e9556f763 Mon Sep 17 00:00:00 2001 From: lishigao Date: Wed, 6 Sep 2023 06:49:03 +0000 Subject: [PATCH 1/4] first modify Signed-off-by: lishigao --- .../idl_service/include/codec_component_config.h | 4 ++-- .../idl_service/include/codec_component_service.h | 2 +- codec/hal/idl_service/include/codec_dfx_service.h | 4 ++-- codec/hal/idl_service/include/codec_dyna_buffer.h | 2 +- codec/hal/idl_service/include/component_node.h | 2 +- codec/hal/idl_service/include/icodec_buffer.h | 5 +++++ .../hal/idl_service/src/codec_component_config.cpp | 7 ++++++- codec/hal/idl_service/src/codec_dfx_service.cpp | 14 +++++++++----- codec/hal/v2.0/hdi_impl/src/codec_omx_core.cpp | 10 ++++++++++ 9 files changed, 37 insertions(+), 13 deletions(-) diff --git a/codec/hal/idl_service/include/codec_component_config.h b/codec/hal/idl_service/include/codec_component_config.h index 47f20ed8d3..29cf4d44e6 100644 --- a/codec/hal/idl_service/include/codec_component_config.h +++ b/codec/hal/idl_service/include/codec_component_config.h @@ -14,6 +14,7 @@ */ #ifndef CODEC_CONFIG_H +#define CODEC_CONFIG_H #include #include "v1_0/codec_types.h" #include "device_resource_if.h" @@ -23,7 +24,7 @@ namespace Codec { namespace Omx { typedef struct { std::string attrName; - int32_t &value; + int32_t value; uint32_t defaultValue; } ConfigUintNodeAttr; typedef struct { @@ -66,5 +67,4 @@ private: } // namespace Omx } // namespace Codec } // namespace OHOS -#define CODEC_CONFIG_H #endif // CODEC_CONFIG_H \ No newline at end of file diff --git a/codec/hal/idl_service/include/codec_component_service.h b/codec/hal/idl_service/include/codec_component_service.h index d25c01758c..ba1ba4092d 100644 --- a/codec/hal/idl_service/include/codec_component_service.h +++ b/codec/hal/idl_service/include/codec_component_service.h @@ -51,7 +51,7 @@ public: const std::vector &eglImage) override; int32_t ComponentRoleEnum(std::vector &role, uint32_t index) override; - std::string &GetComponentCompName(); + const std::string &GetComponentCompName() const; void GetComponentNode(std::shared_ptr &dumpNode_); private: void SetComponentRole(); diff --git a/codec/hal/idl_service/include/codec_dfx_service.h b/codec/hal/idl_service/include/codec_dfx_service.h index a1f622cac4..1066e2048f 100644 --- a/codec/hal/idl_service/include/codec_dfx_service.h +++ b/codec/hal/idl_service/include/codec_dfx_service.h @@ -29,7 +29,6 @@ namespace Codec { namespace V1_0 { class CodecDfxService : public RefBase { public: - ~CodecDfxService() = default; static CodecDfxService &GetInstance(); static HdfSBuf* GetReply(); void SetComponentManager(sptr manager); @@ -40,12 +39,13 @@ public: protected: CodecDfxService() = default; + ~CodecDfxService() = default; private: static uint32_t inputBuffCount; static uint32_t outputBuffCount; sptr managerService_; - static std::shared_ptr dumpNode; + static std::shared_ptr dumpNode_; static CodecDfxService dfxInstance_; static HdfSBuf *reply_; }; diff --git a/codec/hal/idl_service/include/codec_dyna_buffer.h b/codec/hal/idl_service/include/codec_dyna_buffer.h index 89215b2afb..a82a5de3af 100644 --- a/codec/hal/idl_service/include/codec_dyna_buffer.h +++ b/codec/hal/idl_service/include/codec_dyna_buffer.h @@ -20,7 +20,7 @@ namespace OHOS { namespace Codec { namespace Omx { -class CodecDynaBuffer : ICodecBuffer { +class CodecDynaBuffer : public ICodecBuffer { public: ~CodecDynaBuffer(); sptr static Create(struct OmxCodecBuffer &codecBuffer); diff --git a/codec/hal/idl_service/include/component_node.h b/codec/hal/idl_service/include/component_node.h index e6eb96a032..ba1889bace 100644 --- a/codec/hal/idl_service/include/component_node.h +++ b/codec/hal/idl_service/include/component_node.h @@ -62,7 +62,7 @@ public: uint32_t data2, void *eventData); OMX_ERRORTYPE static OnEmptyBufferDone(OMX_HANDLETYPE component, void *appData, OMX_BUFFERHEADERTYPE *buffer); OMX_ERRORTYPE static OnFillBufferDone(OMX_HANDLETYPE component, void *appData, OMX_BUFFERHEADERTYPE *buffer); - std::map &GetBufferMapCount(); + std::map &GetBufferMapCount() const; public: static OMX_CALLBACKTYPE callbacks_; // callbacks diff --git a/codec/hal/idl_service/include/icodec_buffer.h b/codec/hal/idl_service/include/icodec_buffer.h index bfa51e0160..398f4638d6 100644 --- a/codec/hal/idl_service/include/icodec_buffer.h +++ b/codec/hal/idl_service/include/icodec_buffer.h @@ -43,6 +43,11 @@ struct DynamicBuffer { } bufferHandle = nullptr; } + + DynamicBuffer(const DynamicBuffer& other) = delete; + DynamicBuffer(DynamicBuffer&& other) = delete; + DynamicBuffer& operator=(const DynamicBuffer& other) = delete; + DynamicBuffer& operator=(DynamicBuffer&& other) = delete; }; class ICodecBuffer : public RefBase { diff --git a/codec/hal/idl_service/src/codec_component_config.cpp b/codec/hal/idl_service/src/codec_component_config.cpp index 471cdfb6bf..c64428de3f 100644 --- a/codec/hal/idl_service/src/codec_component_config.cpp +++ b/codec/hal/idl_service/src/codec_component_config.cpp @@ -85,7 +85,7 @@ CodecComponentConfig::CodecComponentConfig() void CodecComponentConfig::Init(const DeviceResourceNode &node) { node_ = node; - std::string codecGroupsNodeName[] = {NODE_VIDEO_HARDWARE_ENCODERS, NODE_VIDEO_HARDWARE_DECODERS, + const std::string codecGroupsNodeName[] = {NODE_VIDEO_HARDWARE_ENCODERS, NODE_VIDEO_HARDWARE_DECODERS, NODE_VIDEO_SOFTWARE_ENCODERS, NODE_VIDEO_SOFTWARE_DECODERS, NODE_AUDIO_HARDWARE_ENCODERS, NODE_AUDIO_HARDWARE_DECODERS, NODE_AUDIO_SOFTWARE_ENCODERS, NODE_AUDIO_SOFTWARE_DECODERS}; @@ -180,6 +180,11 @@ int32_t CodecComponentConfig::GetOneCapability(const struct DeviceResourceIface const struct DeviceResourceNode &childNode, CodecCompCapability &cap, bool isVideoGroup) { + + if(iface.GetUint32 == NULL || iface.GetBool == NULL){ + CODEC_LOGE("iface GetUint32 or GetBool is NULL"); + return HDF_FAILURE; + } if (iface.GetUint32(&childNode, CODEC_CONFIG_KEY_ROLE, reinterpret_cast(&cap.role), MEDIA_ROLETYPE_INVALID) != HDF_SUCCESS) { cap.role = MEDIA_ROLETYPE_INVALID; diff --git a/codec/hal/idl_service/src/codec_dfx_service.cpp b/codec/hal/idl_service/src/codec_dfx_service.cpp index 394a0b48d5..8fda5d0216 100644 --- a/codec/hal/idl_service/src/codec_dfx_service.cpp +++ b/codec/hal/idl_service/src/codec_dfx_service.cpp @@ -26,12 +26,12 @@ namespace V1_0 { CodecDfxService CodecDfxService::dfxInstance_; uint32_t CodecDfxService::inputBuffCount; uint32_t CodecDfxService::outputBuffCount; -std::shared_ptr CodecDfxService::dumpNode; +std::shared_ptr CodecDfxService::dumpNode_; HdfSBuf *CodecDfxService::reply_; void CodecDfxService::GetBuffCount() { - auto iter = dumpNode->GetBufferMapCount().begin(); - while (iter != dumpNode->GetBufferMapCount().end()) { + auto iter = dumpNode_->GetBufferMapCount().begin(); + while (iter != dumpNode_->GetBufferMapCount().end()) { if (iter->second == INPUT_PORT_INDEX) { inputBuffCount++; } else { @@ -58,8 +58,8 @@ int32_t CodecDfxService::GetCodecComponentListInfo(struct HdfSBuf *reply) .append(", compId = ") .append(std::to_string(it.first)) .append(", state = "); - componentService->GetComponentNode(dumpNode); - dumpNode->GetState(state); + componentService->GetComponentNode(dumpNode_); + dumpNode_->GetState(state); dump.append(std::to_string(state)); GetInstance().GetBuffCount(); dump.append(", inputPortIndex = ") @@ -130,6 +130,10 @@ int32_t CodecDfxService::DevCodecHostDump(struct HdfSBuf *data, struct HdfSBuf * } const char *para = HdfSbufReadString(data); + if (para == NULL) { + CODEC_LOGE("failed, invalid para!"); + return HDF_ERR_INVALID_PARAM; + } if (strcmp(para, "-h") == EOK) { if (!HdfSbufWriteString(reply, "-h: codec dump help! \n")) { CODEC_LOGE("-h write Fail!"); diff --git a/codec/hal/v2.0/hdi_impl/src/codec_omx_core.cpp b/codec/hal/v2.0/hdi_impl/src/codec_omx_core.cpp index 2bf54461a7..a9af91792b 100644 --- a/codec/hal/v2.0/hdi_impl/src/codec_omx_core.cpp +++ b/codec/hal/v2.0/hdi_impl/src/codec_omx_core.cpp @@ -77,6 +77,12 @@ int32_t CodecOMXCore::GetHandle(OMX_HANDLETYPE &handle, std::string &compName, O CODEC_LOGE("getHandle is null."); return HDF_ERR_INVALID_PARAM; } + + + if (compName.empty()) { + CODEC_LOGE("failed, invalid compName!"); + return HDF_ERR_INVALID_PARAM; + } return (*getHandle_)(&handle, const_cast(compName.c_str()), appData, (OMX_CALLBACKTYPE *)&callbacks); } @@ -110,6 +116,10 @@ int32_t CodecOMXCore::GetRolesOfComponent(std::string &name, std::vector(name.c_str()), &roleCount, nullptr); if (err != HDF_SUCCESS) { CODEC_LOGE("getRoles_ nullptr return err [%{public}x].", err); -- Gitee From e0f027c1ebfa0a59be600a30c05e340ecfde87f4 Mon Sep 17 00:00:00 2001 From: lishigao Date: Wed, 13 Sep 2023 03:04:03 +0000 Subject: [PATCH 2/4] second modify Change-Id: Ide0dcdcee0811ea7faef0a1efe747f573d13f106 Signed-off-by: lishigao --- .../idl_service/include/codec_dfx_service.h | 8 ++-- .../src/codec_component_config.cpp | 8 ++-- .../src/codec_component_manager_service.cpp | 2 +- .../hal/idl_service/src/codec_dfx_service.cpp | 37 ++++++++++--------- codec/hal/idl_service/src/codec_omx_core.cpp | 2 +- .../hal/v2.0/hdi_impl/src/codec_omx_core.cpp | 4 +- 6 files changed, 30 insertions(+), 31 deletions(-) diff --git a/codec/hal/idl_service/include/codec_dfx_service.h b/codec/hal/idl_service/include/codec_dfx_service.h index 7f04c19dd2..9c5a723f74 100644 --- a/codec/hal/idl_service/include/codec_dfx_service.h +++ b/codec/hal/idl_service/include/codec_dfx_service.h @@ -29,23 +29,21 @@ namespace Codec { namespace V1_0 { class CodecDfxService : public RefBase { public: + ~CodecDfxService() = default; static CodecDfxService &GetInstance(); static HdfSBuf* GetReply(); void SetComponentManager(sptr manager); - static void GetBuffCount(); + static void GetBuffCount(const std::shared_ptr &dumpNode, + uint32_t &inputBuffCount, uint32_t &outputBuffCount); static int32_t DevCodecHostDump(struct HdfSBuf *data, struct HdfSBuf *reply); static int32_t GetCodecComponentListInfo(struct HdfSBuf *reply); static void GetCodecMemoryInfo(); protected: CodecDfxService() = default; - ~CodecDfxService() = default; private: - static uint32_t inputBuffCount_; - static uint32_t outputBuffCount_; sptr managerService_; - static std::shared_ptr dumpNode_; static CodecDfxService dfxInstance_; static HdfSBuf *reply_; }; diff --git a/codec/hal/idl_service/src/codec_component_config.cpp b/codec/hal/idl_service/src/codec_component_config.cpp index c64428de3f..a508376a9c 100644 --- a/codec/hal/idl_service/src/codec_component_config.cpp +++ b/codec/hal/idl_service/src/codec_component_config.cpp @@ -86,9 +86,9 @@ void CodecComponentConfig::Init(const DeviceResourceNode &node) { node_ = node; const std::string codecGroupsNodeName[] = {NODE_VIDEO_HARDWARE_ENCODERS, NODE_VIDEO_HARDWARE_DECODERS, - NODE_VIDEO_SOFTWARE_ENCODERS, NODE_VIDEO_SOFTWARE_DECODERS, - NODE_AUDIO_HARDWARE_ENCODERS, NODE_AUDIO_HARDWARE_DECODERS, - NODE_AUDIO_SOFTWARE_ENCODERS, NODE_AUDIO_SOFTWARE_DECODERS}; + NODE_VIDEO_SOFTWARE_ENCODERS, NODE_VIDEO_SOFTWARE_DECODERS, + NODE_AUDIO_HARDWARE_ENCODERS, NODE_AUDIO_HARDWARE_DECODERS, + NODE_AUDIO_SOFTWARE_ENCODERS, NODE_AUDIO_SOFTWARE_DECODERS}; int count = sizeof(codecGroupsNodeName) / sizeof(std::string); for (int index = 0; index < count; index++) { if (GetGroupCapabilities(codecGroupsNodeName[index]) != HDF_SUCCESS) { @@ -181,7 +181,7 @@ int32_t CodecComponentConfig::GetOneCapability(const struct DeviceResourceIface bool isVideoGroup) { - if(iface.GetUint32 == NULL || iface.GetBool == NULL){ + if(iface.GetUint32 == nullptr || iface.GetBool == nullptr){ CODEC_LOGE("iface GetUint32 or GetBool is NULL"); return HDF_FAILURE; } diff --git a/codec/hal/idl_service/src/codec_component_manager_service.cpp b/codec/hal/idl_service/src/codec_component_manager_service.cpp index 5c220af5f5..508ae39cde 100644 --- a/codec/hal/idl_service/src/codec_component_manager_service.cpp +++ b/codec/hal/idl_service/src/codec_component_manager_service.cpp @@ -29,7 +29,7 @@ namespace V1_0 { sptr g_codecManagerService = nullptr; std::once_flag m_serviceFlag; using OHOS::Codec::Omx::ComponentNode; -sptr CodecComponentManagerImplGetInstance(void) +extern "C" ICodecComponentManager *CodecComponentManagerImplGetInstance(void) { std::call_once(m_serviceFlag, [] { g_codecManagerService = new (std::nothrow) CodecComponentManagerService(); diff --git a/codec/hal/idl_service/src/codec_dfx_service.cpp b/codec/hal/idl_service/src/codec_dfx_service.cpp index 1bb021bf86..02c437dba5 100644 --- a/codec/hal/idl_service/src/codec_dfx_service.cpp +++ b/codec/hal/idl_service/src/codec_dfx_service.cpp @@ -24,18 +24,16 @@ namespace V1_0 { #define INPUT_PORT_INDEX 0 #define OUTPUT_PORT_INDEX 1 CodecDfxService CodecDfxService::dfxInstance_; -uint32_t CodecDfxService::inputBuffCount_; -uint32_t CodecDfxService::outputBuffCount_; -std::shared_ptr CodecDfxService::dumpNode_; HdfSBuf *CodecDfxService::reply_; -void CodecDfxService::GetBuffCount() +void CodecDfxService::GetBuffCount(const std::shared_ptr &dumpNode, + uint32_t &inputBuffCount, uint32_t &outputBuffCount) { - auto iter = dumpNode_->GetBufferMapCount().begin(); - while (iter != dumpNode_->GetBufferMapCount().end()) { + auto iter = dumpNode->GetBufferMapCount().begin(); + while (iter != dumpNode->GetBufferMapCount().end()) { if (iter->second == INPUT_PORT_INDEX) { - inputBuffCount_++; + inputBuffCount++; } else { - outputBuffCount_++; + outputBuffCount++; } iter++; } @@ -44,6 +42,9 @@ void CodecDfxService::GetBuffCount() int32_t CodecDfxService::GetCodecComponentListInfo(struct HdfSBuf *reply) { CodecStateType state; + uint32_t inputBuffCount = 0; + uint32_t outputBuffCount = 0; + std::shared_ptr dumpNode = nullptr; std::map> dumpMap = {}; GetInstance().managerService_->GetManagerMap(dumpMap); @@ -58,18 +59,18 @@ int32_t CodecDfxService::GetCodecComponentListInfo(struct HdfSBuf *reply) .append(", compId = ") .append(std::to_string(it.first)) .append(", state = "); - componentService->GetComponentNode(dumpNode_); - dumpNode_->GetState(state); + componentService->GetComponentNode(dumpNode); + dumpNode->GetState(state); dump.append(std::to_string(state)); - GetInstance().GetBuffCount(); + GetInstance().GetBuffCount(dumpNode, inputBuffCount, outputBuffCount); dump.append(", inputPortIndex = ") .append(std::to_string(INPUT_PORT_INDEX)) - .append(", inputBuffCount_ = ") - .append(std::to_string(inputBuffCount_)) + .append(", inputBuffCount = ") + .append(std::to_string(inputBuffCount)) .append(", outputPortIndex = ") .append(std::to_string(OUTPUT_PORT_INDEX)) - .append(", outputBuffCount_ = ") - .append(std::to_string(outputBuffCount_)) + .append(", outputBuffCount = ") + .append(std::to_string(outputBuffCount)) .append("\n"); if (!HdfSbufWriteString(reply, dump.c_str())) { CODEC_LOGE("dump write Fail!"); @@ -79,8 +80,8 @@ int32_t CodecDfxService::GetCodecComponentListInfo(struct HdfSBuf *reply) CODEC_LOGE("Split symbol write Fail!"); return HDF_ERR_INVALID_PARAM; } - inputBuffCount_ = 0; - outputBuffCount_ = 0; + inputBuffCount = 0; + outputBuffCount = 0; componentService = nullptr; } return HDF_SUCCESS; @@ -130,7 +131,7 @@ int32_t CodecDfxService::DevCodecHostDump(struct HdfSBuf *data, struct HdfSBuf * } const char *para = HdfSbufReadString(data); - if (para == NULL) { + if (para == nullptr) { CODEC_LOGE("read string data failed"); return HDF_ERR_INVALID_PARAM; } diff --git a/codec/hal/idl_service/src/codec_omx_core.cpp b/codec/hal/idl_service/src/codec_omx_core.cpp index c6fdeaa4f1..115d1b3453 100644 --- a/codec/hal/idl_service/src/codec_omx_core.cpp +++ b/codec/hal/idl_service/src/codec_omx_core.cpp @@ -113,11 +113,11 @@ int32_t CodecOMXCore::GetRolesOfComponent(std::string &name, std::vector(name.c_str()), &roleCount, nullptr); if (err != HDF_SUCCESS) { CODEC_LOGE("get roleCount return err [%{public}x].", err); diff --git a/codec/hal/v2.0/hdi_impl/src/codec_omx_core.cpp b/codec/hal/v2.0/hdi_impl/src/codec_omx_core.cpp index 8ee1e36713..27f7def974 100644 --- a/codec/hal/v2.0/hdi_impl/src/codec_omx_core.cpp +++ b/codec/hal/v2.0/hdi_impl/src/codec_omx_core.cpp @@ -113,11 +113,11 @@ int32_t CodecOMXCore::GetRolesOfComponent(std::string &name, std::vector(name.c_str()), &roleCount, nullptr); if (err != HDF_SUCCESS) { CODEC_LOGE("getRoles_ nullptr return err [%{public}x].", err); -- Gitee From 9127d5dc00768aa0cd69b8af1cb6722fcaf14a55 Mon Sep 17 00:00:00 2001 From: lishigao Date: Fri, 15 Sep 2023 01:11:05 +0000 Subject: [PATCH 3/4] third modify Change-Id: Id3a553de642980545fcaf13bbec5f6f599bf8b04 Signed-off-by: lishigao --- .../idl_service/include/codec_dfx_service.h | 4 ++-- .../src/codec_component_config.cpp | 22 ++++++------------- .../idl_service/src/codec_death_recipient.cpp | 1 + codec/hal/idl_service/src/component_node.cpp | 7 +++--- .../hdi_service/src/codec_image_driver.cpp | 2 +- 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/codec/hal/idl_service/include/codec_dfx_service.h b/codec/hal/idl_service/include/codec_dfx_service.h index 9c5a723f74..bba06008af 100644 --- a/codec/hal/idl_service/include/codec_dfx_service.h +++ b/codec/hal/idl_service/include/codec_dfx_service.h @@ -33,8 +33,6 @@ public: static CodecDfxService &GetInstance(); static HdfSBuf* GetReply(); void SetComponentManager(sptr manager); - static void GetBuffCount(const std::shared_ptr &dumpNode, - uint32_t &inputBuffCount, uint32_t &outputBuffCount); static int32_t DevCodecHostDump(struct HdfSBuf *data, struct HdfSBuf *reply); static int32_t GetCodecComponentListInfo(struct HdfSBuf *reply); static void GetCodecMemoryInfo(); @@ -43,6 +41,8 @@ protected: CodecDfxService() = default; private: + void GetBuffCount(const std::shared_ptr &dumpNode, + uint32_t &inputBuffCount, uint32_t &outputBuffCount); sptr managerService_; static CodecDfxService dfxInstance_; static HdfSBuf *reply_; diff --git a/codec/hal/idl_service/src/codec_component_config.cpp b/codec/hal/idl_service/src/codec_component_config.cpp index a508376a9c..a062473122 100644 --- a/codec/hal/idl_service/src/codec_component_config.cpp +++ b/codec/hal/idl_service/src/codec_component_config.cpp @@ -85,10 +85,10 @@ CodecComponentConfig::CodecComponentConfig() void CodecComponentConfig::Init(const DeviceResourceNode &node) { node_ = node; - const std::string codecGroupsNodeName[] = {NODE_VIDEO_HARDWARE_ENCODERS, NODE_VIDEO_HARDWARE_DECODERS, - NODE_VIDEO_SOFTWARE_ENCODERS, NODE_VIDEO_SOFTWARE_DECODERS, - NODE_AUDIO_HARDWARE_ENCODERS, NODE_AUDIO_HARDWARE_DECODERS, - NODE_AUDIO_SOFTWARE_ENCODERS, NODE_AUDIO_SOFTWARE_DECODERS}; + const std::string codecGroupsNodeName[] = { NODE_VIDEO_HARDWARE_ENCODERS, NODE_VIDEO_HARDWARE_DECODERS, + NODE_VIDEO_SOFTWARE_ENCODERS, NODE_VIDEO_SOFTWARE_DECODERS, + NODE_AUDIO_HARDWARE_ENCODERS, NODE_AUDIO_HARDWARE_DECODERS, + NODE_AUDIO_SOFTWARE_ENCODERS, NODE_AUDIO_SOFTWARE_DECODERS }; int count = sizeof(codecGroupsNodeName) / sizeof(std::string); for (int index = 0; index < count; index++) { if (GetGroupCapabilities(codecGroupsNodeName[index]) != HDF_SUCCESS) { @@ -149,8 +149,8 @@ int32_t CodecComponentConfig::GetGroupCapabilities(const std::string &nodeName) const struct DeviceResourceNode *codecGroupNode = NULL; struct DeviceResourceNode *childNode = NULL; struct DeviceResourceIface *iface = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE); - if (iface == NULL) { - CODEC_LOGE(" failed, iface NULL!"); + if ((iface == NULL) || (iface->GetUint32 == nullptr) || (iface->GetBool == nullptr) || (iface->GetString == nullptr)) { + CODEC_LOGE(" failed, iface or its GetUint32 or GetBool or GetString is NULL!"); return HDF_ERR_INVALID_PARAM; } @@ -177,21 +177,14 @@ int32_t CodecComponentConfig::GetGroupCapabilities(const std::string &nodeName) } int32_t CodecComponentConfig::GetOneCapability(const struct DeviceResourceIface &iface, - const struct DeviceResourceNode &childNode, CodecCompCapability &cap, - bool isVideoGroup) + const struct DeviceResourceNode &childNode, CodecCompCapability &cap, bool isVideoGroup) { - - if(iface.GetUint32 == nullptr || iface.GetBool == nullptr){ - CODEC_LOGE("iface GetUint32 or GetBool is NULL"); - return HDF_FAILURE; - } if (iface.GetUint32(&childNode, CODEC_CONFIG_KEY_ROLE, reinterpret_cast(&cap.role), MEDIA_ROLETYPE_INVALID) != HDF_SUCCESS) { cap.role = MEDIA_ROLETYPE_INVALID; CODEC_LOGE("failed to get mime for: %{public}s! Discarded", childNode.name); return HDF_FAILURE; } - if (iface.GetUint32(&childNode, CODEC_CONFIG_KEY_TYPE, reinterpret_cast(&cap.type), INVALID_TYPE) != HDF_SUCCESS) { cap.role = MEDIA_ROLETYPE_INVALID; @@ -221,7 +214,6 @@ int32_t CodecComponentConfig::GetOneCapability(const struct DeviceResourceIface CODEC_LOGE("get misc cap err!"); return HDF_FAILURE; } - if (isVideoGroup) { if (GetVideoPortCapability(iface, childNode, cap) != HDF_SUCCESS) { cap.role = MEDIA_ROLETYPE_INVALID; diff --git a/codec/hal/idl_service/src/codec_death_recipient.cpp b/codec/hal/idl_service/src/codec_death_recipient.cpp index f77e5f692d..90c636cea1 100644 --- a/codec/hal/idl_service/src/codec_death_recipient.cpp +++ b/codec/hal/idl_service/src/codec_death_recipient.cpp @@ -76,6 +76,7 @@ void RegisterDeathRecipientService(const sptr callbacks, uint32_ void RemoveMapperOfDestoryedComponent(uint32_t componentId) { + std::lock_guard lk(g_mutex); auto compRemote = g_compRemoteMap.find(componentId); if (compRemote == g_compRemoteMap.end()) { return; diff --git a/codec/hal/idl_service/src/component_node.cpp b/codec/hal/idl_service/src/component_node.cpp index c400c3c79b..5b6e07b6eb 100644 --- a/codec/hal/idl_service/src/component_node.cpp +++ b/codec/hal/idl_service/src/component_node.cpp @@ -567,13 +567,14 @@ void ComponentNode::WaitStateChange(CodecStateType objState, CodecStateType &sta { int32_t ret = GetState(status); uint32_t count = 0; - while (status != objState && count++ < maxStateWaitCount) { + while (status != objState && count < maxStateWaitCount) { usleep(maxStateWaitTime); ret = GetState(status); if (ret != HDF_SUCCESS) { HDF_LOGE("%{public}s: GetState error [%{public}x]", __func__, ret); return; } + count++; } } @@ -588,7 +589,7 @@ void ComponentNode::ReleaseOMXResource() return; } CodecStateType status = CODEC_STATE_INVALID; - int32_t ret = GetState(status); + int32_t ret = 0; if (ret != HDF_SUCCESS) { HDF_LOGE("ReleaseOMXResource GetState error [%{public}x]", ret); return; @@ -599,7 +600,7 @@ void ComponentNode::ReleaseOMXResource() } if (status == CODEC_STATE_IDLE) { SendCommand(CODEC_COMMAND_STATE_SET, CODEC_STATE_LOADED, NULL); - auto ret = ReleaseAllBuffer(); + ret = ReleaseAllBuffer(); if (ret != HDF_SUCCESS) { HDF_LOGE("ReleaseAllBuffer err [%{public}x]", ret); return; diff --git a/codec/image/hdi_service/src/codec_image_driver.cpp b/codec/image/hdi_service/src/codec_image_driver.cpp index 5a2a541320..53e4554610 100644 --- a/codec/image/hdi_service/src/codec_image_driver.cpp +++ b/codec/image/hdi_service/src/codec_image_driver.cpp @@ -101,7 +101,7 @@ static void HdfCodecImageDriverRelease(struct HdfDeviceObject *deviceObject) } } -struct HdfDriverEntry g_CodecImageDriverEntry = { +static struct HdfDriverEntry g_CodecImageDriverEntry = { .moduleVersion = 1, .moduleName = "libcodec_image_service", .Bind = HdfCodecImageDriverBind, -- Gitee From 558cecd0774ba227cacf810eb443d96739da166b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=AF=97=E9=AB=98?= Date: Thu, 21 Sep 2023 11:48:05 +0000 Subject: [PATCH 4/4] update codec/hal/idl_service/src/codec_component_config.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李诗高 --- .../idl_service/src/codec_component_config.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/codec/hal/idl_service/src/codec_component_config.cpp b/codec/hal/idl_service/src/codec_component_config.cpp index a062473122..001d39115d 100644 --- a/codec/hal/idl_service/src/codec_component_config.cpp +++ b/codec/hal/idl_service/src/codec_component_config.cpp @@ -146,16 +146,16 @@ int32_t CodecComponentConfig::GetComponentCapabilityList(std::vectorGetUint32 == nullptr) || (iface->GetBool == nullptr) || (iface->GetString == nullptr)) { - CODEC_LOGE(" failed, iface or its GetUint32 or GetBool or GetString is NULL!"); + if ((iface == nullptr) || (iface->GetUint32 == nullptr) || (iface->GetBool == nullptr) || (iface->GetString == nullptr)) { + CODEC_LOGE(" failed, iface or its GetUint32 or GetBool or GetString is nullptr!"); return HDF_ERR_INVALID_PARAM; } codecGroupNode = iface->GetChildNode(&node_, nodeName.c_str()); - if (codecGroupNode == NULL) { + if (codecGroupNode == nullptr) { CODEC_LOGE("failed to get child node: %{public}s!", nodeName.c_str()); return HDF_FAILURE; } @@ -193,15 +193,15 @@ int32_t CodecComponentConfig::GetOneCapability(const struct DeviceResourceIface return HDF_FAILURE; } - const char *compName = NULL; + const char *compName = nullptr; if (iface.GetString(&childNode, CODEC_CONFIG_KEY_NAME, &compName, "") != HDF_SUCCESS) { cap.role = MEDIA_ROLETYPE_INVALID; CODEC_LOGE("get attr %{public}s err!", CODEC_CONFIG_KEY_NAME); return HDF_FAILURE; } - if (compName == NULL || strlen(compName) == 0) { + if (compName == nullptr || strlen(compName) == 0) { cap.role = MEDIA_ROLETYPE_INVALID; - CODEC_LOGE("compName is null or empty!"); + CODEC_LOGE("compName is nullptr or empty!"); return HDF_FAILURE; } cap.compName = compName; -- Gitee