summaryrefslogtreecommitdiffstats
path: root/xbmc/utils/BufferObject.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
commitc04dcc2e7d834218ef2d4194331e383402495ae1 (patch)
tree7333e38d10d75386e60f336b80c2443c1166031d /xbmc/utils/BufferObject.cpp
parentInitial commit. (diff)
downloadkodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz
kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/utils/BufferObject.cpp')
-rw-r--r--xbmc/utils/BufferObject.cpp61
1 files changed, 61 insertions, 0 deletions
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 <linux/dma-buf.h>
+#include <sys/ioctl.h>
+#endif
+
+std::unique_ptr<CBufferObject> 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
+}