From c04dcc2e7d834218ef2d4194331e383402495ae1 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 Apr 2024 20:07:22 +0200 Subject: Adding upstream version 2:20.4+dfsg. Signed-off-by: Daniel Baumann --- xbmc/utils/BufferObject.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 xbmc/utils/BufferObject.cpp (limited to 'xbmc/utils/BufferObject.cpp') diff --git a/xbmc/utils/BufferObject.cpp b/xbmc/utils/BufferObject.cpp new file mode 100644 index 0000000..1bf338e --- /dev/null +++ b/xbmc/utils/BufferObject.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2005-2020 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "BufferObject.h" + +#include "BufferObjectFactory.h" +#include "utils/log.h" + +#if defined(HAVE_LINUX_DMA_BUF) +#include +#include +#endif + +std::unique_ptr CBufferObject::GetBufferObject(bool needsCreateBySize) +{ + return CBufferObjectFactory::CreateBufferObject(needsCreateBySize); +} + +int CBufferObject::GetFd() +{ + return m_fd; +} + +uint32_t CBufferObject::GetStride() +{ + return m_stride; +} + +uint64_t CBufferObject::GetModifier() +{ + return 0; // linear +} + +void CBufferObject::SyncStart() +{ +#if defined(HAVE_LINUX_DMA_BUF) + struct dma_buf_sync sync; + sync.flags = DMA_BUF_SYNC_START | DMA_BUF_SYNC_RW; + + int ret = ioctl(m_fd, DMA_BUF_IOCTL_SYNC, &sync); + if (ret < 0) + CLog::LogF(LOGERROR, "ioctl DMA_BUF_IOCTL_SYNC failed, ret={} errno={}", ret, strerror(errno)); +#endif +} + +void CBufferObject::SyncEnd() +{ +#if defined(HAVE_LINUX_DMA_BUF) + struct dma_buf_sync sync; + sync.flags = DMA_BUF_SYNC_END | DMA_BUF_SYNC_RW; + + int ret = ioctl(m_fd, DMA_BUF_IOCTL_SYNC, &sync); + if (ret < 0) + CLog::LogF(LOGERROR, "ioctl DMA_BUF_IOCTL_SYNC failed, ret={} errno={}", ret, strerror(errno)); +#endif +} -- cgit v1.2.3