diff options
Diffstat (limited to 'xbmc/utils/BufferObject.cpp')
| -rw-r--r-- | xbmc/utils/BufferObject.cpp | 61 |
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 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2020 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #include "BufferObject.h" | ||
| 10 | |||
| 11 | #include "BufferObjectFactory.h" | ||
| 12 | #include "utils/log.h" | ||
| 13 | |||
| 14 | #if defined(HAVE_LINUX_DMA_BUF) | ||
| 15 | #include <linux/dma-buf.h> | ||
| 16 | #include <sys/ioctl.h> | ||
| 17 | #endif | ||
| 18 | |||
| 19 | std::unique_ptr<CBufferObject> CBufferObject::GetBufferObject(bool needsCreateBySize) | ||
| 20 | { | ||
| 21 | return CBufferObjectFactory::CreateBufferObject(needsCreateBySize); | ||
| 22 | } | ||
| 23 | |||
| 24 | int CBufferObject::GetFd() | ||
| 25 | { | ||
| 26 | return m_fd; | ||
| 27 | } | ||
| 28 | |||
| 29 | uint32_t CBufferObject::GetStride() | ||
| 30 | { | ||
| 31 | return m_stride; | ||
| 32 | } | ||
| 33 | |||
| 34 | uint64_t CBufferObject::GetModifier() | ||
| 35 | { | ||
| 36 | return 0; // linear | ||
| 37 | } | ||
| 38 | |||
| 39 | void CBufferObject::SyncStart() | ||
| 40 | { | ||
| 41 | #if defined(HAVE_LINUX_DMA_BUF) | ||
| 42 | struct dma_buf_sync sync; | ||
| 43 | sync.flags = DMA_BUF_SYNC_START | DMA_BUF_SYNC_RW; | ||
| 44 | |||
| 45 | int ret = ioctl(m_fd, DMA_BUF_IOCTL_SYNC, &sync); | ||
| 46 | if (ret < 0) | ||
| 47 | CLog::LogF(LOGERROR, "ioctl DMA_BUF_IOCTL_SYNC failed, ret={} errno={}", ret, strerror(errno)); | ||
| 48 | #endif | ||
| 49 | } | ||
| 50 | |||
| 51 | void CBufferObject::SyncEnd() | ||
| 52 | { | ||
| 53 | #if defined(HAVE_LINUX_DMA_BUF) | ||
| 54 | struct dma_buf_sync sync; | ||
| 55 | sync.flags = DMA_BUF_SYNC_END | DMA_BUF_SYNC_RW; | ||
| 56 | |||
| 57 | int ret = ioctl(m_fd, DMA_BUF_IOCTL_SYNC, &sync); | ||
| 58 | if (ret < 0) | ||
| 59 | CLog::LogF(LOGERROR, "ioctl DMA_BUF_IOCTL_SYNC failed, ret={} errno={}", ret, strerror(errno)); | ||
| 60 | #endif | ||
| 61 | } | ||
