From 95085153cf5889ce613e2acea153615affd4fbb8 Mon Sep 17 00:00:00 2001 From: qijinquan Date: Wed, 24 Aug 2022 14:16:41 +0800 Subject: [PATCH 1/2] fix: Delete the depends on libdrm and modity the log in idl service Signed-off-by: qijinquan --- codec/hal/BUILD.gn | 13 ------- codec/hal/idl_service/BUILD.gn | 18 ++------- codec/hal/idl_service/include/icodec_buffer.h | 2 +- .../src/codec_component_manager_driver.cpp | 20 +++++----- .../src/codec_component_manager_service.cpp | 4 +- .../hal/idl_service/src/codec_dyna_buffer.cpp | 19 +++++---- .../idl_service/src/codec_handle_buffer.cpp | 21 +++++----- codec/hal/idl_service/src/codec_omx_core.cpp | 18 ++++----- .../idl_service/src/codec_share_buffer.cpp | 24 ++++++------ codec/hal/idl_service/src/component_mgr.cpp | 10 +---- codec/hal/idl_service/src/component_node.cpp | 2 +- codec/hal/idl_service/src/icodec_buffer.cpp | 39 ++++++++++++++++--- .../hal/v2.0/hdi_impl/include/icodec_buffer.h | 2 +- .../v2.0/hdi_impl/src/codec_dyna_buffer.cpp | 8 ++-- .../v2.0/hdi_impl/src/codec_handle_buffer.cpp | 8 ++-- .../hal/v2.0/hdi_impl/src/codec_omx_core.cpp | 1 - codec/hal/v2.0/hdi_impl/src/component_mgr.cpp | 4 -- .../hal/v2.0/hdi_impl/src/component_node.cpp | 4 -- codec/hal/v2.0/hdi_impl/src/icodec_buffer.cpp | 30 ++++++++++++++ 19 files changed, 138 insertions(+), 109 deletions(-) diff --git a/codec/hal/BUILD.gn b/codec/hal/BUILD.gn index ff04150fa2..2fcf54bd3c 100644 --- a/codec/hal/BUILD.gn +++ b/codec/hal/BUILD.gn @@ -41,18 +41,7 @@ ohos_shared_library("libcodec_hdi_omx_server") { "v2.0/hdi_impl/src/component_node.cpp", "v2.0/hdi_impl/src/icodec_buffer.cpp", ] - - cflags_cc = [ - "-Wall", - "-Wextra", - "-Werror", - "-Wno-#warnings", - "-Wno-missing-braces", - "-Wno-missing-field-initializers", - ] - if (is_standard_system) { - deps = [ "//third_party/libdrm:libdrm" ] external_deps = [ "graphic_chipsetsdk:buffer_handle", "hdf_core:libhdf_host", @@ -87,8 +76,6 @@ ohos_shared_library("libcodec_hdi_omx_client") { ] if (is_standard_system) { - deps = [ "//third_party/libdrm:libdrm" ] - external_deps = [ "graphic_chipsetsdk:buffer_handle", "hdf_core:libhdf_host", diff --git a/codec/hal/idl_service/BUILD.gn b/codec/hal/idl_service/BUILD.gn index 4b6dc17f2b..d2663e0cf5 100644 --- a/codec/hal/idl_service/BUILD.gn +++ b/codec/hal/idl_service/BUILD.gn @@ -15,7 +15,7 @@ import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") ohos_shared_library("libcodec_component_manager_service_1.0") { include_dirs = [ - "//drivers/peripheral/codec/hal/buffersequence/", + "//drivers/hdf_core/adapter/uhdf2/model/display/base/buffer_parcelable", "//drivers/peripheral/codec/interfaces/include/", "//third_party/openmax/api/1.1.2", "include", @@ -33,19 +33,7 @@ ohos_shared_library("libcodec_component_manager_service_1.0") { "src/icodec_buffer.cpp", ] - cflags_cc = [ - "-Wall", - "-Wextra", - "-Werror", - "-Wno-#warnings", - "-Wno-missing-braces", - "-Wno-missing-field-initializers", - ] - - deps = [ - "//drivers/peripheral/codec/hal/buffersequence:libbufferhandle_parcelable", - "//third_party/libdrm:libdrm", - ] + deps = [ "//drivers/hdf_core/adapter/uhdf2/model/display/base/buffer_parcelable:libbufferhandle_parcelable" ] if (is_standard_system) { external_deps = [ "drivers_interface_codec:codec_idl_headers", @@ -71,7 +59,7 @@ ohos_shared_library("libcodec_component_manager_service_1.0") { ohos_shared_library("libcodec_driver") { include_dirs = [ "//drivers/peripheral/codec/interfaces/include/", - "//drivers/peripheral/codec/hal/buffersequence", + "//drivers/hdf_core/adapter/uhdf2/model/display/base/buffer_parcelable", "include", ] diff --git a/codec/hal/idl_service/include/icodec_buffer.h b/codec/hal/idl_service/include/icodec_buffer.h index 077a375ccb..4aa54849d7 100644 --- a/codec/hal/idl_service/include/icodec_buffer.h +++ b/codec/hal/idl_service/include/icodec_buffer.h @@ -65,7 +65,7 @@ protected: ICodecBuffer() {} virtual bool CheckInvalid(struct OmxCodecBuffer &codecBuffer); - + int32_t SyncWait(int fd, uint32_t timeout); protected: struct OmxCodecBuffer codecBuffer_; }; diff --git a/codec/hal/idl_service/src/codec_component_manager_driver.cpp b/codec/hal/idl_service/src/codec_component_manager_driver.cpp index cf3c9ad412..86c03a74ad 100644 --- a/codec/hal/idl_service/src/codec_component_manager_driver.cpp +++ b/codec/hal/idl_service/src/codec_component_manager_driver.cpp @@ -15,9 +15,9 @@ #include #include -#include #include #include "codec_component_config.h" +#include "codec_log_wrapper.h" #include "v1_0/codec_component_manager_stub.h" using namespace OHOS::HDI::Codec::V1_0; namespace { @@ -38,11 +38,11 @@ static int32_t CodecComponentManagerDriverDispatch(struct HdfDeviceIoClient *cli OHOS::MessageOption option; if (SbufToParcel(data, &dataParcel) != HDF_SUCCESS) { - HDF_LOGE("%{public}s:invalid data sbuf object to dispatch", __func__); + CODEC_LOGE("invalid data sbuf object to dispatch"); return HDF_ERR_INVALID_PARAM; } if (SbufToParcel(reply, &replyParcel) != HDF_SUCCESS) { - HDF_LOGE("%{public}s:invalid reply sbuf object to dispatch", __func__); + CODEC_LOGE("invalid reply sbuf object to dispatch"); return HDF_ERR_INVALID_PARAM; } @@ -51,18 +51,18 @@ static int32_t CodecComponentManagerDriverDispatch(struct HdfDeviceIoClient *cli static int HdfCodecComponentManagerDriverInit(struct HdfDeviceObject *deviceObject) { - HDF_LOGI("HdfCodecComponentManagerDriverInit enter"); + CODEC_LOGI("HdfCodecComponentManagerDriverInit enter"); OHOS::Codec::Omx::CodecComponentConfig::GetInstance()->Init(*deviceObject->property); return HDF_SUCCESS; } static int HdfCodecComponentManagerDriverBind(struct HdfDeviceObject *deviceObject) { - HDF_LOGI("HdfCodecComponentManagerDriverBind enter"); + CODEC_LOGI("HdfCodecComponentManagerDriverBind enter"); auto *hdfCodecComponentManagerHost = new (std::nothrow) HdfCodecComponentManagerHost; if (hdfCodecComponentManagerHost == nullptr) { - HDF_LOGE("%{public}s: failed to create create HdfCodecComponentManagerHost object", __func__); + CODEC_LOGE("failed to create create HdfCodecComponentManagerHost object"); return HDF_FAILURE; } @@ -72,7 +72,7 @@ static int HdfCodecComponentManagerDriverBind(struct HdfDeviceObject *deviceObje auto serviceImpl = ICodecComponentManager::Get(true); if (serviceImpl == nullptr) { - HDF_LOGE("%{public}s: failed to get of implement service", __func__); + CODEC_LOGE("failed to get of implement service"); delete hdfCodecComponentManagerHost; return HDF_FAILURE; } @@ -80,7 +80,7 @@ static int HdfCodecComponentManagerDriverBind(struct HdfDeviceObject *deviceObje hdfCodecComponentManagerHost->stub = OHOS::HDI::ObjectCollector::GetInstance().GetOrNewObject(serviceImpl, ICodecComponentManager::GetDescriptor()); if (hdfCodecComponentManagerHost->stub == nullptr) { - HDF_LOGE("%{public}s: failed to get stub object", __func__); + CODEC_LOGE("failed to get stub object"); delete hdfCodecComponentManagerHost; return HDF_FAILURE; } @@ -91,9 +91,9 @@ static int HdfCodecComponentManagerDriverBind(struct HdfDeviceObject *deviceObje static void HdfCodecComponentManagerDriverRelease(struct HdfDeviceObject *deviceObject) { - HDF_LOGI("HdfCodecComponentManagerDriverRelease enter"); + CODEC_LOGI("HdfCodecComponentManagerDriverRelease enter"); if (deviceObject->service == nullptr) { - HDF_LOGE("HdfCodecComponentManagerDriverRelease not initted"); + CODEC_LOGE("HdfCodecComponentManagerDriverRelease not initted"); return; } 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 c696346674..835f99f9c3 100644 --- a/codec/hal/idl_service/src/codec_component_manager_service.cpp +++ b/codec/hal/idl_service/src/codec_component_manager_service.cpp @@ -72,12 +72,12 @@ int32_t CodecComponentManagerService::DestoryComponent(uint32_t componentId) CODEC_LOGD("componentId[%{public}d]", componentId); auto iter = componentMap_.find(componentId); if (iter == componentMap_.end() || iter->second == nullptr) { - CODEC_LOGE(" can not find component service by componentId[%{public}d]", componentId); + CODEC_LOGE("can not find component service by componentId[%{public}d]", componentId); return HDF_ERR_INVALID_PARAM; } - std::unique_lock autoLock(mutex_); componentMap_.erase(iter); + iter->second = nullptr; return HDF_SUCCESS; } diff --git a/codec/hal/idl_service/src/codec_dyna_buffer.cpp b/codec/hal/idl_service/src/codec_dyna_buffer.cpp index bc959b38e4..9f634f019d 100644 --- a/codec/hal/idl_service/src/codec_dyna_buffer.cpp +++ b/codec/hal/idl_service/src/codec_dyna_buffer.cpp @@ -15,9 +15,9 @@ #include "codec_dyna_buffer.h" #include #include -#include -#include #include +#include +#include "codec_log_wrapper.h" #include "v1_0/codec_types.h" using namespace OHOS::HDI::Codec::V1_0; namespace OHOS { @@ -48,7 +48,7 @@ sptr CodecDynaBuffer::Create(struct OmxCodecBuffer &codecBuffer) int32_t CodecDynaBuffer::FillOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_BUFFERHEADERTYPE &omxBuffer) { - HDF_LOGE("%{public}s :dyna buffer handle is not supported in FillThisBuffer ", __func__); + CODEC_LOGE("dyna buffer handle is not supported in FillThisBuffer"); (void)codecBuffer; (void)omxBuffer; return HDF_ERR_INVALID_PARAM; @@ -57,14 +57,17 @@ int32_t CodecDynaBuffer::FillOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_B int32_t CodecDynaBuffer::EmptyOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_BUFFERHEADERTYPE &omxBuffer) { if (!CheckInvalid(codecBuffer)) { - HDF_LOGE("%{public}s : CheckInvalid return false", __func__); + CODEC_LOGE("CheckInvalid return false"); return HDF_ERR_INVALID_PARAM; } ResetBuffer(codecBuffer, omxBuffer); int fence = codecBuffer.fenceFd; if (fence >= 0) { - sync_wait(fence, TIME_WAIT_MS); + auto ret = SyncWait(fence, TIME_WAIT_MS); + if (ret < 0) { + CODEC_LOGW("SyncWait ret err"); + } close(codecBuffer.fenceFd); codecBuffer.fenceFd = -1; } @@ -75,7 +78,7 @@ int32_t CodecDynaBuffer::EmptyOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_ int32_t CodecDynaBuffer::FreeBuffer(struct OmxCodecBuffer &codecBuffer) { if (!CheckInvalid(codecBuffer)) { - HDF_LOGE("%{public}s :shMem_ is null or CheckInvalid return false", __func__); + CODEC_LOGE("shMem_ is null or CheckInvalid return false"); return HDF_ERR_INVALID_PARAM; } if (codecBuffer.bufferhandle != nullptr) { @@ -95,7 +98,7 @@ int32_t CodecDynaBuffer::EmptyOmxBufferDone(OMX_BUFFERHEADERTYPE &omxBuffer) int32_t CodecDynaBuffer::FillOmxBufferDone(OMX_BUFFERHEADERTYPE &omxBuffer) { - HDF_LOGE("%{public}s :dyna buffer handle is not supported in FillThisBuffer ", __func__); + CODEC_LOGE("dyna buffer handle is not supported in FillThisBuffer"); (void)omxBuffer; return HDF_ERR_INVALID_PARAM; } @@ -108,7 +111,7 @@ uint8_t *CodecDynaBuffer::GetBuffer() bool CodecDynaBuffer::CheckInvalid(struct OmxCodecBuffer &codecBuffer) { if (!ICodecBuffer::CheckInvalid(codecBuffer) || dynaBuffer_ == nullptr) { - HDF_LOGE("%{public}s :dynaBuffer_ is null or CheckInvalid return false", __func__); + CODEC_LOGE("dynaBuffer_ is null or CheckInvalid return false"); return false; } return true; diff --git a/codec/hal/idl_service/src/codec_handle_buffer.cpp b/codec/hal/idl_service/src/codec_handle_buffer.cpp index b66e1d2df4..368fd176d5 100644 --- a/codec/hal/idl_service/src/codec_handle_buffer.cpp +++ b/codec/hal/idl_service/src/codec_handle_buffer.cpp @@ -15,9 +15,9 @@ #include "codec_handle_buffer.h" #include -#include -#include #include +#include +#include "codec_log_wrapper.h" #include "v1_0/codec_types.h" using namespace OHOS::HDI::Codec::V1_0; namespace OHOS { @@ -37,7 +37,7 @@ CodecHandleBuffer::~CodecHandleBuffer() sptr CodecHandleBuffer::Create(struct OmxCodecBuffer &codecBuffer) { if (codecBuffer.bufferhandle == nullptr) { - HDF_LOGE("%{public}s error, bufferHandle is null", __func__); + CODEC_LOGE("bufferHandle is null"); return nullptr; } auto bufferHandle = codecBuffer.bufferhandle->Move(); @@ -50,14 +50,17 @@ sptr CodecHandleBuffer::Create(struct OmxCodecBuffer &codecBuffer) int32_t CodecHandleBuffer::FillOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_BUFFERHEADERTYPE &omxBuffer) { if (!CheckInvalid(codecBuffer)) { - HDF_LOGE("%{public}s :CheckInvalid return false or mem has no right to write ", __func__); + CODEC_LOGE("CheckInvalid return false or mem has no right to write "); return HDF_ERR_INVALID_PARAM; } ResetBuffer(codecBuffer, omxBuffer); int fenceFd = codecBuffer.fenceFd; if (fenceFd >= 0) { - sync_wait(fenceFd, TIME_WAIT_MS); + auto ret = SyncWait(fenceFd, TIME_WAIT_MS); + if (ret < 0) { + CODEC_LOGW("SyncWait ret err"); + } close(codecBuffer.fenceFd); codecBuffer.fenceFd = -1; } @@ -66,7 +69,7 @@ int32_t CodecHandleBuffer::FillOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX int32_t CodecHandleBuffer::EmptyOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_BUFFERHEADERTYPE &omxBuffer) { - HDF_LOGE("%{public}s : bufferHandle is not support in EmptyThisBuffer", __func__); + CODEC_LOGE("bufferHandle is not support in EmptyThisBuffer"); (void)codecBuffer; (void)omxBuffer; return HDF_ERR_INVALID_PARAM; @@ -75,7 +78,7 @@ int32_t CodecHandleBuffer::EmptyOmxBuffer(struct OmxCodecBuffer &codecBuffer, OM int32_t CodecHandleBuffer::FreeBuffer(struct OmxCodecBuffer &codecBuffer) { if (!CheckInvalid(codecBuffer)) { - HDF_LOGE("%{public}s :shMem_ is null or CheckInvalid return false", __func__); + CODEC_LOGE("shMem_ is null or CheckInvalid return false"); return HDF_ERR_INVALID_PARAM; } codecBuffer.bufferhandle = nullptr; @@ -89,7 +92,7 @@ int32_t CodecHandleBuffer::FreeBuffer(struct OmxCodecBuffer &codecBuffer) int32_t CodecHandleBuffer::EmptyOmxBufferDone(OMX_BUFFERHEADERTYPE &omxBuffer) { - HDF_LOGE("%{public}s : bufferHandle is not support in EmptyThisBuffer", __func__); + CODEC_LOGE("bufferHandle is not support in EmptyThisBuffer"); (void)omxBuffer; return HDF_ERR_INVALID_PARAM; } @@ -107,7 +110,7 @@ uint8_t *CodecHandleBuffer::GetBuffer() bool CodecHandleBuffer::CheckInvalid(struct OmxCodecBuffer &codecBuffer) { if (!ICodecBuffer::CheckInvalid(codecBuffer) || bufferHandle_ == nullptr) { - HDF_LOGE("%{public}s :bufferHandle_ is null or CheckInvalid return false", __func__); + CODEC_LOGE("bufferHandle_ is null or CheckInvalid return false"); return false; } return true; diff --git a/codec/hal/idl_service/src/codec_omx_core.cpp b/codec/hal/idl_service/src/codec_omx_core.cpp index e92c3338df..3c862357e8 100644 --- a/codec/hal/idl_service/src/codec_omx_core.cpp +++ b/codec/hal/idl_service/src/codec_omx_core.cpp @@ -17,9 +17,9 @@ #include #include #include -#include #include #include +#include "codec_log_wrapper.h" namespace OHOS { namespace Codec { namespace Omx { @@ -33,7 +33,7 @@ int32_t CodecOMXCore::Init(const std::string &libName) { libHandle_ = dlopen(libName.c_str(), RTLD_LAZY); if (libHandle_ == NULL) { - HDF_LOGE("%{public}s:failed to dlopen %{public}s.", __func__, libName.c_str()); + CODEC_LOGE("Failed to dlopen %{public}s.", libName.c_str()); return HDF_ERR_INVALID_PARAM; } @@ -61,7 +61,7 @@ int32_t CodecOMXCore::GetHandle(OMX_HANDLETYPE &handle, std::string &compName, O const OMX_CALLBACKTYPE &callbacks) { if (getHandle_ == nullptr) { - HDF_LOGE("%{public}s: getHandle is null.", __func__); + CODEC_LOGE("getHandle_ is nullptr."); return HDF_ERR_INVALID_PARAM; } return (*getHandle_)(&handle, const_cast(compName.c_str()), appData, (OMX_CALLBACKTYPE *)&callbacks); @@ -70,7 +70,7 @@ int32_t CodecOMXCore::GetHandle(OMX_HANDLETYPE &handle, std::string &compName, O int32_t CodecOMXCore::FreeHandle(OMX_HANDLETYPE handle) { if (freeHandle_ == nullptr) { - HDF_LOGE("%{public}s: freeHandle_ is null.", __func__); + CODEC_LOGE("freeHandle_ is nullptr."); return HDF_ERR_INVALID_PARAM; } return (*freeHandle_)(handle); @@ -79,7 +79,7 @@ int32_t CodecOMXCore::FreeHandle(OMX_HANDLETYPE handle) int32_t CodecOMXCore::ComponentNameEnum(std::string &name, uint32_t index) { if (componentNameEnum_ == nullptr) { - HDF_LOGE("%{public}s: componentNameEnum is null.", __func__); + CODEC_LOGE("componentNameEnum_ is nullptr."); return HDF_ERR_INVALID_PARAM; } char tmpComponentName[OMX_MAX_STRINGNAME_SIZE] = {0}; @@ -92,13 +92,13 @@ int32_t CodecOMXCore::ComponentNameEnum(std::string &name, uint32_t index) int32_t CodecOMXCore::GetRolesOfComponent(std::string &name, std::vector &roles) { if (getRoles_ == nullptr) { - HDF_LOGE("%{public}s: getRoles is null.", __func__); + CODEC_LOGE("getRoles_ is null."); return HDF_ERR_INVALID_PARAM; } uint32_t roleCount = 0; uint32_t err = (*getRoles_)(const_cast(name.c_str()), &roleCount, nullptr); if (err != HDF_SUCCESS) { - HDF_LOGE("%{public}s: getRoles_ return err [%{public}x].", __func__, err); + CODEC_LOGE("getRoles_ return err [%{public}x].", err); return err; } if (roleCount <= 0) { @@ -109,14 +109,14 @@ int32_t CodecOMXCore::GetRolesOfComponent(std::string &name, std::vector(name.c_str()), &roleCount, reinterpret_cast(role)); if (err != HDF_SUCCESS) { - HDF_LOGE("%{public}s: getRoles_ return err [%{public}x].", __func__, err); + CODEC_LOGE("getRoles_ return err [%{public}x].", err); return err; } for (uint32_t i = 0; i < roleLen; i++) { diff --git a/codec/hal/idl_service/src/codec_share_buffer.cpp b/codec/hal/idl_service/src/codec_share_buffer.cpp index 980c80d84c..650c8410f7 100644 --- a/codec/hal/idl_service/src/codec_share_buffer.cpp +++ b/codec/hal/idl_service/src/codec_share_buffer.cpp @@ -15,9 +15,9 @@ #include "codec_share_buffer.h" #include -#include #include #include +#include "codec_log_wrapper.h" using namespace OHOS::HDI::Codec::V1_0; namespace OHOS { namespace Codec { @@ -42,7 +42,7 @@ void CodecShareBuffer::SetAshMem(std::shared_ptr shMem) OHOS::sptr CodecShareBuffer::Create(struct OmxCodecBuffer &codecBuffer) { if (codecBuffer.fd < 0) { - HDF_LOGE("%{public}s error, codecBuffer.fd < 0", __func__); + CODEC_LOGE("codecBuffer.fd is invalid"); return nullptr; } int size = OHOS::AshmemGetSize(codecBuffer.fd); @@ -54,7 +54,7 @@ OHOS::sptr CodecShareBuffer::Create(struct OmxCodecBuffer &codecBu mapd = sharedMem->MapReadOnlyAshmem(); } if (!mapd) { - HDF_LOGE("%{public}s error, MapReadAndWriteAshmem or MapReadOnlyAshmem return false", __func__); + CODEC_LOGE("MapReadAndWriteAshmem or MapReadOnlyAshmem return false"); return nullptr; } codecBuffer.fd = -1; @@ -78,7 +78,7 @@ OHOS::sptr CodecShareBuffer::Allocate(struct OmxCodecBuffer &codec mapd = sharedMemory->MapReadOnlyAshmem(); } if (!mapd) { - HDF_LOGE("%{public}s error, MapReadAndWriteAshmem or MapReadOnlyAshmem return false", __func__); + CODEC_LOGE("MapReadAndWriteAshmem or MapReadOnlyAshmem return false"); return nullptr; } codecBuffer.offset = 0; @@ -92,7 +92,7 @@ OHOS::sptr CodecShareBuffer::Allocate(struct OmxCodecBuffer &codec int32_t CodecShareBuffer::FillOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_BUFFERHEADERTYPE &omxBuffer) { if (!CheckInvalid(codecBuffer) || codecBuffer_.type != READ_WRITE_TYPE) { - HDF_LOGE("%{public}s :CheckInvalid return false or mem has no right to write ", __func__); + CODEC_LOGE("CheckInvalid return false or mem has no right to write "); return HDF_ERR_INVALID_PARAM; } ReleaseFd(codecBuffer); @@ -102,7 +102,7 @@ int32_t CodecShareBuffer::FillOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_ int32_t CodecShareBuffer::EmptyOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_BUFFERHEADERTYPE &omxBuffer) { if (!CheckInvalid(codecBuffer)) { - HDF_LOGE("%{public}s :shMem_ is null or CheckInvalid return false", __func__); + CODEC_LOGE("shMem_ is null or CheckInvalid return false"); return HDF_ERR_INVALID_PARAM; } @@ -110,14 +110,14 @@ int32_t CodecShareBuffer::EmptyOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX void *sharedPtr = const_cast(shMem_->ReadFromAshmem(codecBuffer.filledLen, codecBuffer.offset)); if (!sharedPtr) { - HDF_LOGE("%{public}s error, omxBuffer.length [%{public}d omxBuffer.offset[%{public}d]", __func__, - codecBuffer.filledLen, codecBuffer.offset); + CODEC_LOGE("omxBuffer.length [%{public}d omxBuffer.offset[%{public}d]", codecBuffer.filledLen, + codecBuffer.offset); return HDF_ERR_INVALID_PARAM; } auto ret = memcpy_s(omxBuffer.pBuffer + codecBuffer.offset, codecBuffer.allocLen - codecBuffer.offset, sharedPtr, codecBuffer.filledLen); if (ret != EOK) { - HDF_LOGE("%{public}s error, memcpy_s ret [%{public}d", __func__, ret); + CODEC_LOGE("memcpy_s ret [%{public}d]", ret); return HDF_ERR_INVALID_PARAM; } return ICodecBuffer::EmptyOmxBuffer(codecBuffer, omxBuffer); @@ -126,7 +126,7 @@ int32_t CodecShareBuffer::EmptyOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX int32_t CodecShareBuffer::FreeBuffer(struct OmxCodecBuffer &codecBuffer) { if (!CheckInvalid(codecBuffer)) { - HDF_LOGE("%{public}s :shMem_ is null or CheckInvalid return false", __func__); + CODEC_LOGE("shMem_ is null or CheckInvalid return false"); return HDF_ERR_INVALID_PARAM; } @@ -151,7 +151,7 @@ int32_t CodecShareBuffer::EmptyOmxBufferDone(OMX_BUFFERHEADERTYPE &omxBuffer) int32_t CodecShareBuffer::FillOmxBufferDone(OMX_BUFFERHEADERTYPE &omxBuffer) { if (shMem_ == nullptr || !shMem_->WriteToAshmem(omxBuffer.pBuffer, omxBuffer.nFilledLen, omxBuffer.nOffset)) { - HDF_LOGE("%{public}s write to ashmem[%{public}p] fail", __func__, shMem_.get()); + CODEC_LOGE("write to ashmem[%{public}p] fail", shMem_.get()); return HDF_ERR_INVALID_PARAM; } @@ -161,7 +161,7 @@ int32_t CodecShareBuffer::FillOmxBufferDone(OMX_BUFFERHEADERTYPE &omxBuffer) bool CodecShareBuffer::CheckInvalid(struct OmxCodecBuffer &codecBuffer) { if (!ICodecBuffer::CheckInvalid(codecBuffer) || shMem_ == nullptr) { - HDF_LOGE("%{public}s :shMem_ is null or CheckInvalid return false", __func__); + CODEC_LOGE("shMem_ is null or CheckInvalid return false"); return false; } return true; diff --git a/codec/hal/idl_service/src/component_mgr.cpp b/codec/hal/idl_service/src/component_mgr.cpp index 5db39ad1f0..9cca7b19dd 100644 --- a/codec/hal/idl_service/src/component_mgr.cpp +++ b/codec/hal/idl_service/src/component_mgr.cpp @@ -14,14 +14,8 @@ */ #include "component_mgr.h" -#include -#include #include -#include -#include -#include -#define HDF_LOG_TAG codec_hdi_server - +#include "codec_log_wrapper.h" namespace OHOS { namespace Codec { namespace Omx { @@ -44,7 +38,7 @@ int32_t ComponentMgr::CreateComponentInstance(const char *componentName, const O auto iter = compoentsCore_.find(componentName); if (iter == compoentsCore_.end() || iter->second == nullptr) { - HDF_LOGE("%{public}s: can not find component[%{public}s] in core", __func__, componentName); + CODEC_LOGE("can not find component[%{public}s] in core", componentName); return err; } auto core = iter->second; diff --git a/codec/hal/idl_service/src/component_node.cpp b/codec/hal/idl_service/src/component_node.cpp index ad9149a87f..2c52e1e2cb 100644 --- a/codec/hal/idl_service/src/component_node.cpp +++ b/codec/hal/idl_service/src/component_node.cpp @@ -15,8 +15,8 @@ #include "component_node.h" #include -#include #include +#include #include "codec_log_wrapper.h" #include "component_mgr.h" #include "icodec_buffer.h" diff --git a/codec/hal/idl_service/src/icodec_buffer.cpp b/codec/hal/idl_service/src/icodec_buffer.cpp index a906c1de41..82fcea461c 100644 --- a/codec/hal/idl_service/src/icodec_buffer.cpp +++ b/codec/hal/idl_service/src/icodec_buffer.cpp @@ -14,9 +14,10 @@ */ #include "icodec_buffer.h" #include -#include +#include #include "codec_dyna_buffer.h" #include "codec_handle_buffer.h" +#include "codec_log_wrapper.h" #include "codec_share_buffer.h" #include "v1_0/codec_types.h" using namespace OHOS::HDI::Codec::V1_0; @@ -44,7 +45,7 @@ sptr ICodecBuffer::CreateCodeBuffer(struct OmxCodecBuffer &codecBu buffer = CodecDynaBuffer::Create(codecBuffer); break; default: - HDF_LOGE("%s: bufferType[%{public}d] is unexpected", __func__, codecBuffer.bufferType); + CODEC_LOGE("bufferType[%{public}d] is unexpected", codecBuffer.bufferType); break; } return buffer; @@ -58,7 +59,7 @@ sptr ICodecBuffer::AllocateCodecBuffer(struct OmxCodecBuffer &code buffer = CodecShareBuffer::Allocate(codecBuffer); break; default: - HDF_LOGE("%s: bufferType[%{public}d] is unexpected", __func__, codecBuffer.bufferType); + CODEC_LOGE("bufferType[%{public}d] is unexpected", codecBuffer.bufferType); break; } return buffer; @@ -77,8 +78,8 @@ void ICodecBuffer::SetBufferId(int32_t bufferId) bool ICodecBuffer::CheckInvalid(struct OmxCodecBuffer &codecBuffer) { if (codecBuffer_.type != codecBuffer.type) { - HDF_LOGE("%{public}s :input buffer type [%{public}d], but expect type [%{public}d]", __func__, - codecBuffer.bufferType, codecBuffer_.bufferType); + CODEC_LOGE("input buffer type [%{public}d], but expect type [%{public}d]", codecBuffer.bufferType, + codecBuffer_.bufferType); return false; } return true; @@ -115,6 +116,34 @@ int32_t ICodecBuffer::FillOmxBufferDone(OMX_BUFFERHEADERTYPE &omxBuffer) codecBuffer_.pts = omxBuffer.nTimeStamp; return HDF_SUCCESS; } +int32_t ICodecBuffer::SyncWait(int fd, uint32_t timeout) +{ + int retCode = -1; + if (fd < 0) { + CODEC_LOGE("The fence id is invalid."); + return retCode; + } + + struct pollfd pollfds = {0}; + pollfds.fd = fd; + pollfds.events = POLLIN; + + do { + retCode = poll(&pollfds, 1, timeout); + } while (retCode == -1 && (errno == EINTR || errno == EAGAIN)); + + if (retCode == 0) { + retCode = -1; + errno = ETIME; + } else if (retCode > 0) { + if (pollfds.revents & (POLLERR | POLLNVAL)) { + retCode = -1; + errno = EINVAL; + } + retCode = 0; + } + return retCode < 0 ? -errno : 0; +} } // namespace Omx } // namespace Codec } // namespace OHOS \ No newline at end of file diff --git a/codec/hal/v2.0/hdi_impl/include/icodec_buffer.h b/codec/hal/v2.0/hdi_impl/include/icodec_buffer.h index bdfcc4bb2d..ab27e5f378 100644 --- a/codec/hal/v2.0/hdi_impl/include/icodec_buffer.h +++ b/codec/hal/v2.0/hdi_impl/include/icodec_buffer.h @@ -64,7 +64,7 @@ protected: ICodecBuffer() {} virtual bool CheckInvalid(struct OmxCodecBuffer &codecBuffer); - + int32_t SyncWait(int fd, uint32_t timeout); protected: struct OmxCodecBuffer codecBuffer_; }; diff --git a/codec/hal/v2.0/hdi_impl/src/codec_dyna_buffer.cpp b/codec/hal/v2.0/hdi_impl/src/codec_dyna_buffer.cpp index 7be49fd515..840c7ce2d8 100644 --- a/codec/hal/v2.0/hdi_impl/src/codec_dyna_buffer.cpp +++ b/codec/hal/v2.0/hdi_impl/src/codec_dyna_buffer.cpp @@ -16,9 +16,8 @@ #include #include #include -#include #include - +#include namespace OHOS { namespace Codec { namespace Omx { @@ -63,7 +62,10 @@ int32_t CodecDynaBuffer::EmptyOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_ int fence = codecBuffer.fenceFd; if (fence >= 0) { - sync_wait(fence, TIME_WAIT_MS); + auto ret = SyncWait(fence, TIME_WAIT_MS); + if (ret < 0) { + HDF_LOGW("%{public}s : SyncWait ret err", __func__); + } close(codecBuffer.fenceFd); codecBuffer.fenceFd = -1; } diff --git a/codec/hal/v2.0/hdi_impl/src/codec_handle_buffer.cpp b/codec/hal/v2.0/hdi_impl/src/codec_handle_buffer.cpp index a27a6d2eee..2a15a07ca3 100644 --- a/codec/hal/v2.0/hdi_impl/src/codec_handle_buffer.cpp +++ b/codec/hal/v2.0/hdi_impl/src/codec_handle_buffer.cpp @@ -16,9 +16,8 @@ #include "codec_handle_buffer.h" #include #include -#include #include - +#include namespace OHOS { namespace Codec { namespace Omx { @@ -58,7 +57,10 @@ int32_t CodecHandleBuffer::FillOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX int fenceFd = codecBuffer.fenceFd; if (fenceFd >= 0) { - sync_wait(fenceFd, TIME_WAIT_MS); + auto ret = SyncWait(fenceFd, TIME_WAIT_MS); + if (ret < 0) { + HDF_LOGW("%{public}s : SyncWait ret err", __func__); + } close(codecBuffer.fenceFd); codecBuffer.fenceFd = -1; } 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 b8deb3969d..b61b0782aa 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 @@ -18,7 +18,6 @@ #include #include #include -#include #include namespace OHOS { namespace Codec { diff --git a/codec/hal/v2.0/hdi_impl/src/component_mgr.cpp b/codec/hal/v2.0/hdi_impl/src/component_mgr.cpp index 5db39ad1f0..bda963d70c 100644 --- a/codec/hal/v2.0/hdi_impl/src/component_mgr.cpp +++ b/codec/hal/v2.0/hdi_impl/src/component_mgr.cpp @@ -14,12 +14,8 @@ */ #include "component_mgr.h" -#include -#include #include #include -#include -#include #define HDF_LOG_TAG codec_hdi_server namespace OHOS { diff --git a/codec/hal/v2.0/hdi_impl/src/component_node.cpp b/codec/hal/v2.0/hdi_impl/src/component_node.cpp index 9f42c181da..ee9efbb7db 100644 --- a/codec/hal/v2.0/hdi_impl/src/component_node.cpp +++ b/codec/hal/v2.0/hdi_impl/src/component_node.cpp @@ -15,12 +15,8 @@ #include "component_node.h" #include -#include #include -#include -#include #include -#include #include #include "icodec_buffer.h" diff --git a/codec/hal/v2.0/hdi_impl/src/icodec_buffer.cpp b/codec/hal/v2.0/hdi_impl/src/icodec_buffer.cpp index 1959a02a2e..3a5a4683be 100644 --- a/codec/hal/v2.0/hdi_impl/src/icodec_buffer.cpp +++ b/codec/hal/v2.0/hdi_impl/src/icodec_buffer.cpp @@ -15,6 +15,7 @@ #include "icodec_buffer.h" #include #include +#include #include "codec_dyna_buffer.h" #include "codec_handle_buffer.h" #include "codec_share_buffer.h" @@ -83,6 +84,35 @@ bool ICodecBuffer::CheckInvalid(struct OmxCodecBuffer &codecBuffer) return true; } +int32_t ICodecBuffer::SyncWait(int fd, uint32_t timeout) +{ + int retCode = -1; + if (fd < 0) { + HDF_LOGE("%{public}s The fence id is invalid.", __func__); + return retCode; + } + + struct pollfd pollfds = {0}; + pollfds.fd = fd; + pollfds.events = POLLIN; + + do { + retCode = poll(&pollfds, 1, timeout); + } while (retCode == -1 && (errno == EINTR || errno == EAGAIN)); + + if (retCode == 0) { + retCode = -1; + errno = ETIME; + } else if (retCode > 0) { + if (pollfds.revents & (POLLERR | POLLNVAL)) { + retCode = -1; + errno = EINVAL; + } + retCode = 0; + } + return retCode < 0 ? -errno : 0; +} + int32_t ICodecBuffer::FillOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_BUFFERHEADERTYPE &omxBuffer) { omxBuffer.nOffset = codecBuffer.offset; -- Gitee From 982489c662b8aff00dc275df39b0221096c08c04 Mon Sep 17 00:00:00 2001 From: qijinquan Date: Wed, 24 Aug 2022 17:57:53 +0800 Subject: [PATCH 2/2] fix: Modify the gn, and header include Signed-off-by: qijinquan --- codec/hal/BUILD.gn | 13 +++++++ codec/hal/idl_service/BUILD.gn | 18 +++++++-- codec/hal/idl_service/include/icodec_buffer.h | 2 +- .../src/codec_component_manager_driver.cpp | 20 +++++----- .../src/codec_component_manager_service.cpp | 4 +- .../hal/idl_service/src/codec_dyna_buffer.cpp | 19 ++++----- .../idl_service/src/codec_handle_buffer.cpp | 21 +++++----- codec/hal/idl_service/src/codec_omx_core.cpp | 18 ++++----- .../idl_service/src/codec_share_buffer.cpp | 24 ++++++------ codec/hal/idl_service/src/component_mgr.cpp | 10 ++++- codec/hal/idl_service/src/component_node.cpp | 2 +- codec/hal/idl_service/src/icodec_buffer.cpp | 39 +++---------------- .../hal/v2.0/hdi_impl/include/icodec_buffer.h | 2 +- .../v2.0/hdi_impl/src/codec_dyna_buffer.cpp | 8 ++-- .../v2.0/hdi_impl/src/codec_handle_buffer.cpp | 8 ++-- .../hal/v2.0/hdi_impl/src/codec_omx_core.cpp | 1 + codec/hal/v2.0/hdi_impl/src/component_mgr.cpp | 4 ++ .../hal/v2.0/hdi_impl/src/component_node.cpp | 4 ++ codec/hal/v2.0/hdi_impl/src/icodec_buffer.cpp | 30 -------------- .../test/demo/v2.0/include/codec_hdi_decode.h | 5 --- .../test/demo/v2.0/include/codec_hdi_encode.h | 5 --- codec/test/demo/v2.0/include/command_parse.h | 4 +- codec/test/demo/v2.0/src/codec_hdi_decode.cpp | 5 --- codec/test/demo/v2.0/src/codec_hdi_encode.cpp | 4 -- codec/test/demo/v2.0/src/command_parse.cpp | 2 +- codec/test/unittest/hdi_omx/BUILD.gn | 20 ++++------ .../unittest/hdi_omx/codec_hdi_omx_test.cpp | 1 - 27 files changed, 120 insertions(+), 173 deletions(-) diff --git a/codec/hal/BUILD.gn b/codec/hal/BUILD.gn index 2fcf54bd3c..ff04150fa2 100644 --- a/codec/hal/BUILD.gn +++ b/codec/hal/BUILD.gn @@ -41,7 +41,18 @@ ohos_shared_library("libcodec_hdi_omx_server") { "v2.0/hdi_impl/src/component_node.cpp", "v2.0/hdi_impl/src/icodec_buffer.cpp", ] + + cflags_cc = [ + "-Wall", + "-Wextra", + "-Werror", + "-Wno-#warnings", + "-Wno-missing-braces", + "-Wno-missing-field-initializers", + ] + if (is_standard_system) { + deps = [ "//third_party/libdrm:libdrm" ] external_deps = [ "graphic_chipsetsdk:buffer_handle", "hdf_core:libhdf_host", @@ -76,6 +87,8 @@ ohos_shared_library("libcodec_hdi_omx_client") { ] if (is_standard_system) { + deps = [ "//third_party/libdrm:libdrm" ] + external_deps = [ "graphic_chipsetsdk:buffer_handle", "hdf_core:libhdf_host", diff --git a/codec/hal/idl_service/BUILD.gn b/codec/hal/idl_service/BUILD.gn index d2663e0cf5..4b6dc17f2b 100644 --- a/codec/hal/idl_service/BUILD.gn +++ b/codec/hal/idl_service/BUILD.gn @@ -15,7 +15,7 @@ import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") ohos_shared_library("libcodec_component_manager_service_1.0") { include_dirs = [ - "//drivers/hdf_core/adapter/uhdf2/model/display/base/buffer_parcelable", + "//drivers/peripheral/codec/hal/buffersequence/", "//drivers/peripheral/codec/interfaces/include/", "//third_party/openmax/api/1.1.2", "include", @@ -33,7 +33,19 @@ ohos_shared_library("libcodec_component_manager_service_1.0") { "src/icodec_buffer.cpp", ] - deps = [ "//drivers/hdf_core/adapter/uhdf2/model/display/base/buffer_parcelable:libbufferhandle_parcelable" ] + cflags_cc = [ + "-Wall", + "-Wextra", + "-Werror", + "-Wno-#warnings", + "-Wno-missing-braces", + "-Wno-missing-field-initializers", + ] + + deps = [ + "//drivers/peripheral/codec/hal/buffersequence:libbufferhandle_parcelable", + "//third_party/libdrm:libdrm", + ] if (is_standard_system) { external_deps = [ "drivers_interface_codec:codec_idl_headers", @@ -59,7 +71,7 @@ ohos_shared_library("libcodec_component_manager_service_1.0") { ohos_shared_library("libcodec_driver") { include_dirs = [ "//drivers/peripheral/codec/interfaces/include/", - "//drivers/hdf_core/adapter/uhdf2/model/display/base/buffer_parcelable", + "//drivers/peripheral/codec/hal/buffersequence", "include", ] diff --git a/codec/hal/idl_service/include/icodec_buffer.h b/codec/hal/idl_service/include/icodec_buffer.h index 4aa54849d7..077a375ccb 100644 --- a/codec/hal/idl_service/include/icodec_buffer.h +++ b/codec/hal/idl_service/include/icodec_buffer.h @@ -65,7 +65,7 @@ protected: ICodecBuffer() {} virtual bool CheckInvalid(struct OmxCodecBuffer &codecBuffer); - int32_t SyncWait(int fd, uint32_t timeout); + protected: struct OmxCodecBuffer codecBuffer_; }; diff --git a/codec/hal/idl_service/src/codec_component_manager_driver.cpp b/codec/hal/idl_service/src/codec_component_manager_driver.cpp index 86c03a74ad..cf3c9ad412 100644 --- a/codec/hal/idl_service/src/codec_component_manager_driver.cpp +++ b/codec/hal/idl_service/src/codec_component_manager_driver.cpp @@ -15,9 +15,9 @@ #include #include +#include #include #include "codec_component_config.h" -#include "codec_log_wrapper.h" #include "v1_0/codec_component_manager_stub.h" using namespace OHOS::HDI::Codec::V1_0; namespace { @@ -38,11 +38,11 @@ static int32_t CodecComponentManagerDriverDispatch(struct HdfDeviceIoClient *cli OHOS::MessageOption option; if (SbufToParcel(data, &dataParcel) != HDF_SUCCESS) { - CODEC_LOGE("invalid data sbuf object to dispatch"); + HDF_LOGE("%{public}s:invalid data sbuf object to dispatch", __func__); return HDF_ERR_INVALID_PARAM; } if (SbufToParcel(reply, &replyParcel) != HDF_SUCCESS) { - CODEC_LOGE("invalid reply sbuf object to dispatch"); + HDF_LOGE("%{public}s:invalid reply sbuf object to dispatch", __func__); return HDF_ERR_INVALID_PARAM; } @@ -51,18 +51,18 @@ static int32_t CodecComponentManagerDriverDispatch(struct HdfDeviceIoClient *cli static int HdfCodecComponentManagerDriverInit(struct HdfDeviceObject *deviceObject) { - CODEC_LOGI("HdfCodecComponentManagerDriverInit enter"); + HDF_LOGI("HdfCodecComponentManagerDriverInit enter"); OHOS::Codec::Omx::CodecComponentConfig::GetInstance()->Init(*deviceObject->property); return HDF_SUCCESS; } static int HdfCodecComponentManagerDriverBind(struct HdfDeviceObject *deviceObject) { - CODEC_LOGI("HdfCodecComponentManagerDriverBind enter"); + HDF_LOGI("HdfCodecComponentManagerDriverBind enter"); auto *hdfCodecComponentManagerHost = new (std::nothrow) HdfCodecComponentManagerHost; if (hdfCodecComponentManagerHost == nullptr) { - CODEC_LOGE("failed to create create HdfCodecComponentManagerHost object"); + HDF_LOGE("%{public}s: failed to create create HdfCodecComponentManagerHost object", __func__); return HDF_FAILURE; } @@ -72,7 +72,7 @@ static int HdfCodecComponentManagerDriverBind(struct HdfDeviceObject *deviceObje auto serviceImpl = ICodecComponentManager::Get(true); if (serviceImpl == nullptr) { - CODEC_LOGE("failed to get of implement service"); + HDF_LOGE("%{public}s: failed to get of implement service", __func__); delete hdfCodecComponentManagerHost; return HDF_FAILURE; } @@ -80,7 +80,7 @@ static int HdfCodecComponentManagerDriverBind(struct HdfDeviceObject *deviceObje hdfCodecComponentManagerHost->stub = OHOS::HDI::ObjectCollector::GetInstance().GetOrNewObject(serviceImpl, ICodecComponentManager::GetDescriptor()); if (hdfCodecComponentManagerHost->stub == nullptr) { - CODEC_LOGE("failed to get stub object"); + HDF_LOGE("%{public}s: failed to get stub object", __func__); delete hdfCodecComponentManagerHost; return HDF_FAILURE; } @@ -91,9 +91,9 @@ static int HdfCodecComponentManagerDriverBind(struct HdfDeviceObject *deviceObje static void HdfCodecComponentManagerDriverRelease(struct HdfDeviceObject *deviceObject) { - CODEC_LOGI("HdfCodecComponentManagerDriverRelease enter"); + HDF_LOGI("HdfCodecComponentManagerDriverRelease enter"); if (deviceObject->service == nullptr) { - CODEC_LOGE("HdfCodecComponentManagerDriverRelease not initted"); + HDF_LOGE("HdfCodecComponentManagerDriverRelease not initted"); return; } 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 835f99f9c3..c696346674 100644 --- a/codec/hal/idl_service/src/codec_component_manager_service.cpp +++ b/codec/hal/idl_service/src/codec_component_manager_service.cpp @@ -72,12 +72,12 @@ int32_t CodecComponentManagerService::DestoryComponent(uint32_t componentId) CODEC_LOGD("componentId[%{public}d]", componentId); auto iter = componentMap_.find(componentId); if (iter == componentMap_.end() || iter->second == nullptr) { - CODEC_LOGE("can not find component service by componentId[%{public}d]", componentId); + CODEC_LOGE(" can not find component service by componentId[%{public}d]", componentId); return HDF_ERR_INVALID_PARAM; } + std::unique_lock autoLock(mutex_); componentMap_.erase(iter); - iter->second = nullptr; return HDF_SUCCESS; } diff --git a/codec/hal/idl_service/src/codec_dyna_buffer.cpp b/codec/hal/idl_service/src/codec_dyna_buffer.cpp index 9f634f019d..bc959b38e4 100644 --- a/codec/hal/idl_service/src/codec_dyna_buffer.cpp +++ b/codec/hal/idl_service/src/codec_dyna_buffer.cpp @@ -15,9 +15,9 @@ #include "codec_dyna_buffer.h" #include #include +#include +#include #include -#include -#include "codec_log_wrapper.h" #include "v1_0/codec_types.h" using namespace OHOS::HDI::Codec::V1_0; namespace OHOS { @@ -48,7 +48,7 @@ sptr CodecDynaBuffer::Create(struct OmxCodecBuffer &codecBuffer) int32_t CodecDynaBuffer::FillOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_BUFFERHEADERTYPE &omxBuffer) { - CODEC_LOGE("dyna buffer handle is not supported in FillThisBuffer"); + HDF_LOGE("%{public}s :dyna buffer handle is not supported in FillThisBuffer ", __func__); (void)codecBuffer; (void)omxBuffer; return HDF_ERR_INVALID_PARAM; @@ -57,17 +57,14 @@ int32_t CodecDynaBuffer::FillOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_B int32_t CodecDynaBuffer::EmptyOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_BUFFERHEADERTYPE &omxBuffer) { if (!CheckInvalid(codecBuffer)) { - CODEC_LOGE("CheckInvalid return false"); + HDF_LOGE("%{public}s : CheckInvalid return false", __func__); return HDF_ERR_INVALID_PARAM; } ResetBuffer(codecBuffer, omxBuffer); int fence = codecBuffer.fenceFd; if (fence >= 0) { - auto ret = SyncWait(fence, TIME_WAIT_MS); - if (ret < 0) { - CODEC_LOGW("SyncWait ret err"); - } + sync_wait(fence, TIME_WAIT_MS); close(codecBuffer.fenceFd); codecBuffer.fenceFd = -1; } @@ -78,7 +75,7 @@ int32_t CodecDynaBuffer::EmptyOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_ int32_t CodecDynaBuffer::FreeBuffer(struct OmxCodecBuffer &codecBuffer) { if (!CheckInvalid(codecBuffer)) { - CODEC_LOGE("shMem_ is null or CheckInvalid return false"); + HDF_LOGE("%{public}s :shMem_ is null or CheckInvalid return false", __func__); return HDF_ERR_INVALID_PARAM; } if (codecBuffer.bufferhandle != nullptr) { @@ -98,7 +95,7 @@ int32_t CodecDynaBuffer::EmptyOmxBufferDone(OMX_BUFFERHEADERTYPE &omxBuffer) int32_t CodecDynaBuffer::FillOmxBufferDone(OMX_BUFFERHEADERTYPE &omxBuffer) { - CODEC_LOGE("dyna buffer handle is not supported in FillThisBuffer"); + HDF_LOGE("%{public}s :dyna buffer handle is not supported in FillThisBuffer ", __func__); (void)omxBuffer; return HDF_ERR_INVALID_PARAM; } @@ -111,7 +108,7 @@ uint8_t *CodecDynaBuffer::GetBuffer() bool CodecDynaBuffer::CheckInvalid(struct OmxCodecBuffer &codecBuffer) { if (!ICodecBuffer::CheckInvalid(codecBuffer) || dynaBuffer_ == nullptr) { - CODEC_LOGE("dynaBuffer_ is null or CheckInvalid return false"); + HDF_LOGE("%{public}s :dynaBuffer_ is null or CheckInvalid return false", __func__); return false; } return true; diff --git a/codec/hal/idl_service/src/codec_handle_buffer.cpp b/codec/hal/idl_service/src/codec_handle_buffer.cpp index 368fd176d5..b66e1d2df4 100644 --- a/codec/hal/idl_service/src/codec_handle_buffer.cpp +++ b/codec/hal/idl_service/src/codec_handle_buffer.cpp @@ -15,9 +15,9 @@ #include "codec_handle_buffer.h" #include +#include +#include #include -#include -#include "codec_log_wrapper.h" #include "v1_0/codec_types.h" using namespace OHOS::HDI::Codec::V1_0; namespace OHOS { @@ -37,7 +37,7 @@ CodecHandleBuffer::~CodecHandleBuffer() sptr CodecHandleBuffer::Create(struct OmxCodecBuffer &codecBuffer) { if (codecBuffer.bufferhandle == nullptr) { - CODEC_LOGE("bufferHandle is null"); + HDF_LOGE("%{public}s error, bufferHandle is null", __func__); return nullptr; } auto bufferHandle = codecBuffer.bufferhandle->Move(); @@ -50,17 +50,14 @@ sptr CodecHandleBuffer::Create(struct OmxCodecBuffer &codecBuffer) int32_t CodecHandleBuffer::FillOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_BUFFERHEADERTYPE &omxBuffer) { if (!CheckInvalid(codecBuffer)) { - CODEC_LOGE("CheckInvalid return false or mem has no right to write "); + HDF_LOGE("%{public}s :CheckInvalid return false or mem has no right to write ", __func__); return HDF_ERR_INVALID_PARAM; } ResetBuffer(codecBuffer, omxBuffer); int fenceFd = codecBuffer.fenceFd; if (fenceFd >= 0) { - auto ret = SyncWait(fenceFd, TIME_WAIT_MS); - if (ret < 0) { - CODEC_LOGW("SyncWait ret err"); - } + sync_wait(fenceFd, TIME_WAIT_MS); close(codecBuffer.fenceFd); codecBuffer.fenceFd = -1; } @@ -69,7 +66,7 @@ int32_t CodecHandleBuffer::FillOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX int32_t CodecHandleBuffer::EmptyOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_BUFFERHEADERTYPE &omxBuffer) { - CODEC_LOGE("bufferHandle is not support in EmptyThisBuffer"); + HDF_LOGE("%{public}s : bufferHandle is not support in EmptyThisBuffer", __func__); (void)codecBuffer; (void)omxBuffer; return HDF_ERR_INVALID_PARAM; @@ -78,7 +75,7 @@ int32_t CodecHandleBuffer::EmptyOmxBuffer(struct OmxCodecBuffer &codecBuffer, OM int32_t CodecHandleBuffer::FreeBuffer(struct OmxCodecBuffer &codecBuffer) { if (!CheckInvalid(codecBuffer)) { - CODEC_LOGE("shMem_ is null or CheckInvalid return false"); + HDF_LOGE("%{public}s :shMem_ is null or CheckInvalid return false", __func__); return HDF_ERR_INVALID_PARAM; } codecBuffer.bufferhandle = nullptr; @@ -92,7 +89,7 @@ int32_t CodecHandleBuffer::FreeBuffer(struct OmxCodecBuffer &codecBuffer) int32_t CodecHandleBuffer::EmptyOmxBufferDone(OMX_BUFFERHEADERTYPE &omxBuffer) { - CODEC_LOGE("bufferHandle is not support in EmptyThisBuffer"); + HDF_LOGE("%{public}s : bufferHandle is not support in EmptyThisBuffer", __func__); (void)omxBuffer; return HDF_ERR_INVALID_PARAM; } @@ -110,7 +107,7 @@ uint8_t *CodecHandleBuffer::GetBuffer() bool CodecHandleBuffer::CheckInvalid(struct OmxCodecBuffer &codecBuffer) { if (!ICodecBuffer::CheckInvalid(codecBuffer) || bufferHandle_ == nullptr) { - CODEC_LOGE("bufferHandle_ is null or CheckInvalid return false"); + HDF_LOGE("%{public}s :bufferHandle_ is null or CheckInvalid return false", __func__); return false; } return true; diff --git a/codec/hal/idl_service/src/codec_omx_core.cpp b/codec/hal/idl_service/src/codec_omx_core.cpp index 3c862357e8..e92c3338df 100644 --- a/codec/hal/idl_service/src/codec_omx_core.cpp +++ b/codec/hal/idl_service/src/codec_omx_core.cpp @@ -17,9 +17,9 @@ #include #include #include +#include #include #include -#include "codec_log_wrapper.h" namespace OHOS { namespace Codec { namespace Omx { @@ -33,7 +33,7 @@ int32_t CodecOMXCore::Init(const std::string &libName) { libHandle_ = dlopen(libName.c_str(), RTLD_LAZY); if (libHandle_ == NULL) { - CODEC_LOGE("Failed to dlopen %{public}s.", libName.c_str()); + HDF_LOGE("%{public}s:failed to dlopen %{public}s.", __func__, libName.c_str()); return HDF_ERR_INVALID_PARAM; } @@ -61,7 +61,7 @@ int32_t CodecOMXCore::GetHandle(OMX_HANDLETYPE &handle, std::string &compName, O const OMX_CALLBACKTYPE &callbacks) { if (getHandle_ == nullptr) { - CODEC_LOGE("getHandle_ is nullptr."); + HDF_LOGE("%{public}s: getHandle is null.", __func__); return HDF_ERR_INVALID_PARAM; } return (*getHandle_)(&handle, const_cast(compName.c_str()), appData, (OMX_CALLBACKTYPE *)&callbacks); @@ -70,7 +70,7 @@ int32_t CodecOMXCore::GetHandle(OMX_HANDLETYPE &handle, std::string &compName, O int32_t CodecOMXCore::FreeHandle(OMX_HANDLETYPE handle) { if (freeHandle_ == nullptr) { - CODEC_LOGE("freeHandle_ is nullptr."); + HDF_LOGE("%{public}s: freeHandle_ is null.", __func__); return HDF_ERR_INVALID_PARAM; } return (*freeHandle_)(handle); @@ -79,7 +79,7 @@ int32_t CodecOMXCore::FreeHandle(OMX_HANDLETYPE handle) int32_t CodecOMXCore::ComponentNameEnum(std::string &name, uint32_t index) { if (componentNameEnum_ == nullptr) { - CODEC_LOGE("componentNameEnum_ is nullptr."); + HDF_LOGE("%{public}s: componentNameEnum is null.", __func__); return HDF_ERR_INVALID_PARAM; } char tmpComponentName[OMX_MAX_STRINGNAME_SIZE] = {0}; @@ -92,13 +92,13 @@ int32_t CodecOMXCore::ComponentNameEnum(std::string &name, uint32_t index) int32_t CodecOMXCore::GetRolesOfComponent(std::string &name, std::vector &roles) { if (getRoles_ == nullptr) { - CODEC_LOGE("getRoles_ is null."); + HDF_LOGE("%{public}s: getRoles is null.", __func__); return HDF_ERR_INVALID_PARAM; } uint32_t roleCount = 0; uint32_t err = (*getRoles_)(const_cast(name.c_str()), &roleCount, nullptr); if (err != HDF_SUCCESS) { - CODEC_LOGE("getRoles_ return err [%{public}x].", err); + HDF_LOGE("%{public}s: getRoles_ return err [%{public}x].", __func__, err); return err; } if (roleCount <= 0) { @@ -109,14 +109,14 @@ int32_t CodecOMXCore::GetRolesOfComponent(std::string &name, std::vector(name.c_str()), &roleCount, reinterpret_cast(role)); if (err != HDF_SUCCESS) { - CODEC_LOGE("getRoles_ return err [%{public}x].", err); + HDF_LOGE("%{public}s: getRoles_ return err [%{public}x].", __func__, err); return err; } for (uint32_t i = 0; i < roleLen; i++) { diff --git a/codec/hal/idl_service/src/codec_share_buffer.cpp b/codec/hal/idl_service/src/codec_share_buffer.cpp index 650c8410f7..980c80d84c 100644 --- a/codec/hal/idl_service/src/codec_share_buffer.cpp +++ b/codec/hal/idl_service/src/codec_share_buffer.cpp @@ -15,9 +15,9 @@ #include "codec_share_buffer.h" #include +#include #include #include -#include "codec_log_wrapper.h" using namespace OHOS::HDI::Codec::V1_0; namespace OHOS { namespace Codec { @@ -42,7 +42,7 @@ void CodecShareBuffer::SetAshMem(std::shared_ptr shMem) OHOS::sptr CodecShareBuffer::Create(struct OmxCodecBuffer &codecBuffer) { if (codecBuffer.fd < 0) { - CODEC_LOGE("codecBuffer.fd is invalid"); + HDF_LOGE("%{public}s error, codecBuffer.fd < 0", __func__); return nullptr; } int size = OHOS::AshmemGetSize(codecBuffer.fd); @@ -54,7 +54,7 @@ OHOS::sptr CodecShareBuffer::Create(struct OmxCodecBuffer &codecBu mapd = sharedMem->MapReadOnlyAshmem(); } if (!mapd) { - CODEC_LOGE("MapReadAndWriteAshmem or MapReadOnlyAshmem return false"); + HDF_LOGE("%{public}s error, MapReadAndWriteAshmem or MapReadOnlyAshmem return false", __func__); return nullptr; } codecBuffer.fd = -1; @@ -78,7 +78,7 @@ OHOS::sptr CodecShareBuffer::Allocate(struct OmxCodecBuffer &codec mapd = sharedMemory->MapReadOnlyAshmem(); } if (!mapd) { - CODEC_LOGE("MapReadAndWriteAshmem or MapReadOnlyAshmem return false"); + HDF_LOGE("%{public}s error, MapReadAndWriteAshmem or MapReadOnlyAshmem return false", __func__); return nullptr; } codecBuffer.offset = 0; @@ -92,7 +92,7 @@ OHOS::sptr CodecShareBuffer::Allocate(struct OmxCodecBuffer &codec int32_t CodecShareBuffer::FillOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_BUFFERHEADERTYPE &omxBuffer) { if (!CheckInvalid(codecBuffer) || codecBuffer_.type != READ_WRITE_TYPE) { - CODEC_LOGE("CheckInvalid return false or mem has no right to write "); + HDF_LOGE("%{public}s :CheckInvalid return false or mem has no right to write ", __func__); return HDF_ERR_INVALID_PARAM; } ReleaseFd(codecBuffer); @@ -102,7 +102,7 @@ int32_t CodecShareBuffer::FillOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_ int32_t CodecShareBuffer::EmptyOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_BUFFERHEADERTYPE &omxBuffer) { if (!CheckInvalid(codecBuffer)) { - CODEC_LOGE("shMem_ is null or CheckInvalid return false"); + HDF_LOGE("%{public}s :shMem_ is null or CheckInvalid return false", __func__); return HDF_ERR_INVALID_PARAM; } @@ -110,14 +110,14 @@ int32_t CodecShareBuffer::EmptyOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX void *sharedPtr = const_cast(shMem_->ReadFromAshmem(codecBuffer.filledLen, codecBuffer.offset)); if (!sharedPtr) { - CODEC_LOGE("omxBuffer.length [%{public}d omxBuffer.offset[%{public}d]", codecBuffer.filledLen, - codecBuffer.offset); + HDF_LOGE("%{public}s error, omxBuffer.length [%{public}d omxBuffer.offset[%{public}d]", __func__, + codecBuffer.filledLen, codecBuffer.offset); return HDF_ERR_INVALID_PARAM; } auto ret = memcpy_s(omxBuffer.pBuffer + codecBuffer.offset, codecBuffer.allocLen - codecBuffer.offset, sharedPtr, codecBuffer.filledLen); if (ret != EOK) { - CODEC_LOGE("memcpy_s ret [%{public}d]", ret); + HDF_LOGE("%{public}s error, memcpy_s ret [%{public}d", __func__, ret); return HDF_ERR_INVALID_PARAM; } return ICodecBuffer::EmptyOmxBuffer(codecBuffer, omxBuffer); @@ -126,7 +126,7 @@ int32_t CodecShareBuffer::EmptyOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX int32_t CodecShareBuffer::FreeBuffer(struct OmxCodecBuffer &codecBuffer) { if (!CheckInvalid(codecBuffer)) { - CODEC_LOGE("shMem_ is null or CheckInvalid return false"); + HDF_LOGE("%{public}s :shMem_ is null or CheckInvalid return false", __func__); return HDF_ERR_INVALID_PARAM; } @@ -151,7 +151,7 @@ int32_t CodecShareBuffer::EmptyOmxBufferDone(OMX_BUFFERHEADERTYPE &omxBuffer) int32_t CodecShareBuffer::FillOmxBufferDone(OMX_BUFFERHEADERTYPE &omxBuffer) { if (shMem_ == nullptr || !shMem_->WriteToAshmem(omxBuffer.pBuffer, omxBuffer.nFilledLen, omxBuffer.nOffset)) { - CODEC_LOGE("write to ashmem[%{public}p] fail", shMem_.get()); + HDF_LOGE("%{public}s write to ashmem[%{public}p] fail", __func__, shMem_.get()); return HDF_ERR_INVALID_PARAM; } @@ -161,7 +161,7 @@ int32_t CodecShareBuffer::FillOmxBufferDone(OMX_BUFFERHEADERTYPE &omxBuffer) bool CodecShareBuffer::CheckInvalid(struct OmxCodecBuffer &codecBuffer) { if (!ICodecBuffer::CheckInvalid(codecBuffer) || shMem_ == nullptr) { - CODEC_LOGE("shMem_ is null or CheckInvalid return false"); + HDF_LOGE("%{public}s :shMem_ is null or CheckInvalid return false", __func__); return false; } return true; diff --git a/codec/hal/idl_service/src/component_mgr.cpp b/codec/hal/idl_service/src/component_mgr.cpp index 9cca7b19dd..5db39ad1f0 100644 --- a/codec/hal/idl_service/src/component_mgr.cpp +++ b/codec/hal/idl_service/src/component_mgr.cpp @@ -14,8 +14,14 @@ */ #include "component_mgr.h" +#include +#include #include -#include "codec_log_wrapper.h" +#include +#include +#include +#define HDF_LOG_TAG codec_hdi_server + namespace OHOS { namespace Codec { namespace Omx { @@ -38,7 +44,7 @@ int32_t ComponentMgr::CreateComponentInstance(const char *componentName, const O auto iter = compoentsCore_.find(componentName); if (iter == compoentsCore_.end() || iter->second == nullptr) { - CODEC_LOGE("can not find component[%{public}s] in core", componentName); + HDF_LOGE("%{public}s: can not find component[%{public}s] in core", __func__, componentName); return err; } auto core = iter->second; diff --git a/codec/hal/idl_service/src/component_node.cpp b/codec/hal/idl_service/src/component_node.cpp index 2c52e1e2cb..ad9149a87f 100644 --- a/codec/hal/idl_service/src/component_node.cpp +++ b/codec/hal/idl_service/src/component_node.cpp @@ -15,8 +15,8 @@ #include "component_node.h" #include +#include #include -#include #include "codec_log_wrapper.h" #include "component_mgr.h" #include "icodec_buffer.h" diff --git a/codec/hal/idl_service/src/icodec_buffer.cpp b/codec/hal/idl_service/src/icodec_buffer.cpp index 82fcea461c..a906c1de41 100644 --- a/codec/hal/idl_service/src/icodec_buffer.cpp +++ b/codec/hal/idl_service/src/icodec_buffer.cpp @@ -14,10 +14,9 @@ */ #include "icodec_buffer.h" #include -#include +#include #include "codec_dyna_buffer.h" #include "codec_handle_buffer.h" -#include "codec_log_wrapper.h" #include "codec_share_buffer.h" #include "v1_0/codec_types.h" using namespace OHOS::HDI::Codec::V1_0; @@ -45,7 +44,7 @@ sptr ICodecBuffer::CreateCodeBuffer(struct OmxCodecBuffer &codecBu buffer = CodecDynaBuffer::Create(codecBuffer); break; default: - CODEC_LOGE("bufferType[%{public}d] is unexpected", codecBuffer.bufferType); + HDF_LOGE("%s: bufferType[%{public}d] is unexpected", __func__, codecBuffer.bufferType); break; } return buffer; @@ -59,7 +58,7 @@ sptr ICodecBuffer::AllocateCodecBuffer(struct OmxCodecBuffer &code buffer = CodecShareBuffer::Allocate(codecBuffer); break; default: - CODEC_LOGE("bufferType[%{public}d] is unexpected", codecBuffer.bufferType); + HDF_LOGE("%s: bufferType[%{public}d] is unexpected", __func__, codecBuffer.bufferType); break; } return buffer; @@ -78,8 +77,8 @@ void ICodecBuffer::SetBufferId(int32_t bufferId) bool ICodecBuffer::CheckInvalid(struct OmxCodecBuffer &codecBuffer) { if (codecBuffer_.type != codecBuffer.type) { - CODEC_LOGE("input buffer type [%{public}d], but expect type [%{public}d]", codecBuffer.bufferType, - codecBuffer_.bufferType); + HDF_LOGE("%{public}s :input buffer type [%{public}d], but expect type [%{public}d]", __func__, + codecBuffer.bufferType, codecBuffer_.bufferType); return false; } return true; @@ -116,34 +115,6 @@ int32_t ICodecBuffer::FillOmxBufferDone(OMX_BUFFERHEADERTYPE &omxBuffer) codecBuffer_.pts = omxBuffer.nTimeStamp; return HDF_SUCCESS; } -int32_t ICodecBuffer::SyncWait(int fd, uint32_t timeout) -{ - int retCode = -1; - if (fd < 0) { - CODEC_LOGE("The fence id is invalid."); - return retCode; - } - - struct pollfd pollfds = {0}; - pollfds.fd = fd; - pollfds.events = POLLIN; - - do { - retCode = poll(&pollfds, 1, timeout); - } while (retCode == -1 && (errno == EINTR || errno == EAGAIN)); - - if (retCode == 0) { - retCode = -1; - errno = ETIME; - } else if (retCode > 0) { - if (pollfds.revents & (POLLERR | POLLNVAL)) { - retCode = -1; - errno = EINVAL; - } - retCode = 0; - } - return retCode < 0 ? -errno : 0; -} } // namespace Omx } // namespace Codec } // namespace OHOS \ No newline at end of file diff --git a/codec/hal/v2.0/hdi_impl/include/icodec_buffer.h b/codec/hal/v2.0/hdi_impl/include/icodec_buffer.h index ab27e5f378..bdfcc4bb2d 100644 --- a/codec/hal/v2.0/hdi_impl/include/icodec_buffer.h +++ b/codec/hal/v2.0/hdi_impl/include/icodec_buffer.h @@ -64,7 +64,7 @@ protected: ICodecBuffer() {} virtual bool CheckInvalid(struct OmxCodecBuffer &codecBuffer); - int32_t SyncWait(int fd, uint32_t timeout); + protected: struct OmxCodecBuffer codecBuffer_; }; diff --git a/codec/hal/v2.0/hdi_impl/src/codec_dyna_buffer.cpp b/codec/hal/v2.0/hdi_impl/src/codec_dyna_buffer.cpp index 840c7ce2d8..7be49fd515 100644 --- a/codec/hal/v2.0/hdi_impl/src/codec_dyna_buffer.cpp +++ b/codec/hal/v2.0/hdi_impl/src/codec_dyna_buffer.cpp @@ -16,8 +16,9 @@ #include #include #include +#include #include -#include + namespace OHOS { namespace Codec { namespace Omx { @@ -62,10 +63,7 @@ int32_t CodecDynaBuffer::EmptyOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_ int fence = codecBuffer.fenceFd; if (fence >= 0) { - auto ret = SyncWait(fence, TIME_WAIT_MS); - if (ret < 0) { - HDF_LOGW("%{public}s : SyncWait ret err", __func__); - } + sync_wait(fence, TIME_WAIT_MS); close(codecBuffer.fenceFd); codecBuffer.fenceFd = -1; } diff --git a/codec/hal/v2.0/hdi_impl/src/codec_handle_buffer.cpp b/codec/hal/v2.0/hdi_impl/src/codec_handle_buffer.cpp index 2a15a07ca3..a27a6d2eee 100644 --- a/codec/hal/v2.0/hdi_impl/src/codec_handle_buffer.cpp +++ b/codec/hal/v2.0/hdi_impl/src/codec_handle_buffer.cpp @@ -16,8 +16,9 @@ #include "codec_handle_buffer.h" #include #include +#include #include -#include + namespace OHOS { namespace Codec { namespace Omx { @@ -57,10 +58,7 @@ int32_t CodecHandleBuffer::FillOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX int fenceFd = codecBuffer.fenceFd; if (fenceFd >= 0) { - auto ret = SyncWait(fenceFd, TIME_WAIT_MS); - if (ret < 0) { - HDF_LOGW("%{public}s : SyncWait ret err", __func__); - } + sync_wait(fenceFd, TIME_WAIT_MS); close(codecBuffer.fenceFd); codecBuffer.fenceFd = -1; } 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 b61b0782aa..b8deb3969d 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 @@ -18,6 +18,7 @@ #include #include #include +#include #include namespace OHOS { namespace Codec { diff --git a/codec/hal/v2.0/hdi_impl/src/component_mgr.cpp b/codec/hal/v2.0/hdi_impl/src/component_mgr.cpp index bda963d70c..5db39ad1f0 100644 --- a/codec/hal/v2.0/hdi_impl/src/component_mgr.cpp +++ b/codec/hal/v2.0/hdi_impl/src/component_mgr.cpp @@ -14,8 +14,12 @@ */ #include "component_mgr.h" +#include +#include #include #include +#include +#include #define HDF_LOG_TAG codec_hdi_server namespace OHOS { diff --git a/codec/hal/v2.0/hdi_impl/src/component_node.cpp b/codec/hal/v2.0/hdi_impl/src/component_node.cpp index ee9efbb7db..9f42c181da 100644 --- a/codec/hal/v2.0/hdi_impl/src/component_node.cpp +++ b/codec/hal/v2.0/hdi_impl/src/component_node.cpp @@ -15,8 +15,12 @@ #include "component_node.h" #include +#include #include +#include +#include #include +#include #include #include "icodec_buffer.h" diff --git a/codec/hal/v2.0/hdi_impl/src/icodec_buffer.cpp b/codec/hal/v2.0/hdi_impl/src/icodec_buffer.cpp index 3a5a4683be..1959a02a2e 100644 --- a/codec/hal/v2.0/hdi_impl/src/icodec_buffer.cpp +++ b/codec/hal/v2.0/hdi_impl/src/icodec_buffer.cpp @@ -15,7 +15,6 @@ #include "icodec_buffer.h" #include #include -#include #include "codec_dyna_buffer.h" #include "codec_handle_buffer.h" #include "codec_share_buffer.h" @@ -84,35 +83,6 @@ bool ICodecBuffer::CheckInvalid(struct OmxCodecBuffer &codecBuffer) return true; } -int32_t ICodecBuffer::SyncWait(int fd, uint32_t timeout) -{ - int retCode = -1; - if (fd < 0) { - HDF_LOGE("%{public}s The fence id is invalid.", __func__); - return retCode; - } - - struct pollfd pollfds = {0}; - pollfds.fd = fd; - pollfds.events = POLLIN; - - do { - retCode = poll(&pollfds, 1, timeout); - } while (retCode == -1 && (errno == EINTR || errno == EAGAIN)); - - if (retCode == 0) { - retCode = -1; - errno = ETIME; - } else if (retCode > 0) { - if (pollfds.revents & (POLLERR | POLLNVAL)) { - retCode = -1; - errno = EINVAL; - } - retCode = 0; - } - return retCode < 0 ? -errno : 0; -} - int32_t ICodecBuffer::FillOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_BUFFERHEADERTYPE &omxBuffer) { omxBuffer.nOffset = codecBuffer.offset; diff --git a/codec/test/demo/v2.0/include/codec_hdi_decode.h b/codec/test/demo/v2.0/include/codec_hdi_decode.h index 3fe365ddbf..44f014334b 100644 --- a/codec/test/demo/v2.0/include/codec_hdi_decode.h +++ b/codec/test/demo/v2.0/include/codec_hdi_decode.h @@ -20,17 +20,12 @@ #include #include #include -#include #include -#include #include #include #include #include #include -#include -#include -#include #include "codec_callback_type_service.h" #include "codec_callback_type_stub.h" #include "codec_component_manager.h" diff --git a/codec/test/demo/v2.0/include/codec_hdi_encode.h b/codec/test/demo/v2.0/include/codec_hdi_encode.h index c0fb7a8cf1..accb2ccbfd 100644 --- a/codec/test/demo/v2.0/include/codec_hdi_encode.h +++ b/codec/test/demo/v2.0/include/codec_hdi_encode.h @@ -21,17 +21,12 @@ #include #include #include -#include #include -#include #include #include #include #include #include -#include -#include -#include #include "codec_callback_type_service.h" #include "codec_callback_type_stub.h" #include "codec_component_manager.h" diff --git a/codec/test/demo/v2.0/include/command_parse.h b/codec/test/demo/v2.0/include/command_parse.h index 52351f401d..48363d35dc 100644 --- a/codec/test/demo/v2.0/include/command_parse.h +++ b/codec/test/demo/v2.0/include/command_parse.h @@ -14,8 +14,8 @@ */ #ifndef PARSE_COMMAND_H #define PARSE_COMMAND_H -#include - +#include +#include enum class codecMime { AVC, HEVC }; using CommandOpt = struct CommandOpt { diff --git a/codec/test/demo/v2.0/src/codec_hdi_decode.cpp b/codec/test/demo/v2.0/src/codec_hdi_decode.cpp index ad892effc7..f0e77261f6 100644 --- a/codec/test/demo/v2.0/src/codec_hdi_decode.cpp +++ b/codec/test/demo/v2.0/src/codec_hdi_decode.cpp @@ -14,13 +14,8 @@ */ #include "codec_hdi_decode.h" -#include -#include #include -#include #include -#include -#include #include "codec_omx_ext.h" OHOS::HDI::Display::V1_0::IDisplayGralloc *CodecHdiDecode::gralloc_ = nullptr; diff --git a/codec/test/demo/v2.0/src/codec_hdi_encode.cpp b/codec/test/demo/v2.0/src/codec_hdi_encode.cpp index 27d424e691..54030b0d84 100644 --- a/codec/test/demo/v2.0/src/codec_hdi_encode.cpp +++ b/codec/test/demo/v2.0/src/codec_hdi_encode.cpp @@ -14,12 +14,8 @@ */ #include "codec_hdi_encode.h" -#include -#include #include -#include #include -#include #include #include "codec_omx_ext.h" diff --git a/codec/test/demo/v2.0/src/command_parse.cpp b/codec/test/demo/v2.0/src/command_parse.cpp index e7c67ac895..76232baf42 100644 --- a/codec/test/demo/v2.0/src/command_parse.cpp +++ b/codec/test/demo/v2.0/src/command_parse.cpp @@ -14,7 +14,7 @@ */ #include "command_parse.h" #include - +#include namespace { enum class MyOptIndex { OPT_INDEX_UNKONWN = 0, diff --git a/codec/test/unittest/hdi_omx/BUILD.gn b/codec/test/unittest/hdi_omx/BUILD.gn index 96fa44c236..7937711586 100644 --- a/codec/test/unittest/hdi_omx/BUILD.gn +++ b/codec/test/unittest/hdi_omx/BUILD.gn @@ -25,16 +25,6 @@ ohos_unittest("codec_hdi_omx_test") { "//drivers/peripheral/display/hdi_service/gralloc/include", ] sources = [ "codec_hdi_omx_test.cpp" ] - - cflags = [ - "-Wall", - "-Wextra", - "-Werror", - "-fsigned-char", - "-fno-common", - "-fno-strict-aliasing", - ] - deps = [ "//drivers/peripheral/codec/hal:codec_hdi_omx", "//third_party/googletest:gtest_main", @@ -55,7 +45,13 @@ ohos_unittest("codec_hdi_omx_test") { external_deps = [ "hilog:libhilog" ] } - if (device_name == "rk3568") { - cflags += [ "-DSUPPORT_OMX" ] + OMX_IL_PATH = rebase_path( + "//device/soc/${device_company}/${product_name}/hardware/omx_il") + cmd = "if [ -f ${OMX_IL_PATH}/BUILD.gn ]; then echo true; else echo false; fi" + HAVE_OMX_IL_PATH = + exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value") + + if (HAVE_OMX_IL_PATH) { + cflags = [ "-DSUPPORT_OMX" ] } } diff --git a/codec/test/unittest/hdi_omx/codec_hdi_omx_test.cpp b/codec/test/unittest/hdi_omx/codec_hdi_omx_test.cpp index 2afca96107..e2cd6d8c86 100644 --- a/codec/test/unittest/hdi_omx/codec_hdi_omx_test.cpp +++ b/codec/test/unittest/hdi_omx/codec_hdi_omx_test.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include -- Gitee