Commit b9efda59 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Merge branch 'release/20.08' into master

parents f83d5102 8afd5c8d
...@@ -33,6 +33,12 @@ add_library(krfb_framebuffer_pw ...@@ -33,6 +33,12 @@ add_library(krfb_framebuffer_pw
${krfb_framebuffer_pw_SRCS} ${krfb_framebuffer_pw_SRCS}
) )
check_include_file("linux/dma-buf.h" HAVE_LINUX_DMABUF_H)
if (HAVE_LINUX_DMABUF_H)
target_compile_definitions(krfb_framebuffer_pw PRIVATE -DHAVE_LINUX_DMABUF_H)
endif ()
target_link_libraries (krfb_framebuffer_pw target_link_libraries (krfb_framebuffer_pw
Qt5::Core Qt5::Core
Qt5::Gui Qt5::Gui
......
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
#if PW_CHECK_VERSION(0, 2, 90) #if PW_CHECK_VERSION(0, 2, 90)
#include <spa/utils/result.h> #include <spa/utils/result.h>
#ifdef HAVE_LINUX_DMABUF_H
#include <linux/dma-buf.h> #include <linux/dma-buf.h>
#endif
#include <sys/ioctl.h> #include <sys/ioctl.h>
#endif #endif
...@@ -691,6 +693,7 @@ void PWFrameBuffer::Private::onStreamProcess(void *data) ...@@ -691,6 +693,7 @@ void PWFrameBuffer::Private::onStreamProcess(void *data)
pw_stream_queue_buffer(d->pwStream, buf); pw_stream_queue_buffer(d->pwStream, buf);
} }
#if PW_CHECK_VERSION(0, 2, 90) && defined(HAVE_LINUX_DMABUF_H)
static void syncDmaBuf(int fd, uint64_t start_or_end) static void syncDmaBuf(int fd, uint64_t start_or_end)
{ {
struct dma_buf_sync sync = { 0 }; struct dma_buf_sync sync = { 0 };
...@@ -709,6 +712,7 @@ static void syncDmaBuf(int fd, uint64_t start_or_end) ...@@ -709,6 +712,7 @@ static void syncDmaBuf(int fd, uint64_t start_or_end)
} }
} }
} }
#endif
void PWFrameBuffer::Private::handleFrame(pw_buffer *pwBuffer) void PWFrameBuffer::Private::handleFrame(pw_buffer *pwBuffer)
{ {
...@@ -719,10 +723,18 @@ void PWFrameBuffer::Private::handleFrame(pw_buffer *pwBuffer) ...@@ -719,10 +723,18 @@ void PWFrameBuffer::Private::handleFrame(pw_buffer *pwBuffer)
return; return;
} }
#if PW_CHECK_VERSION(0, 2, 90)
if (spaBuffer->datas->type != SPA_DATA_DmaBuf) {
qDebug() << "discarding null buffer";
return;
}
#endif
const quint32 maxSize = spaBuffer->datas[0].maxsize; const quint32 maxSize = spaBuffer->datas[0].maxsize;
std::function<void()> cleanup; std::function<void()> cleanup;
#if PW_CHECK_VERSION(0, 2, 90) #if PW_CHECK_VERSION(0, 2, 90)
#ifdef HAVE_LINUX_DMABUF_H
if (spaBuffer->datas->type == SPA_DATA_DmaBuf) { if (spaBuffer->datas->type == SPA_DATA_DmaBuf) {
const int fd = spaBuffer->datas[0].fd; const int fd = spaBuffer->datas[0].fd;
auto map = mmap( auto map = mmap(
...@@ -740,7 +752,9 @@ void PWFrameBuffer::Private::handleFrame(pw_buffer *pwBuffer) ...@@ -740,7 +752,9 @@ void PWFrameBuffer::Private::handleFrame(pw_buffer *pwBuffer)
syncDmaBuf(fd, DMA_BUF_SYNC_END); syncDmaBuf(fd, DMA_BUF_SYNC_END);
munmap(map, spaBuffer->datas[0].maxsize + spaBuffer->datas[0].mapoffset); munmap(map, spaBuffer->datas[0].maxsize + spaBuffer->datas[0].mapoffset);
}; };
} else if (spaBuffer->datas->type == SPA_DATA_MemFd) { } else
#endif
if (spaBuffer->datas->type == SPA_DATA_MemFd) {
uint8_t *map = static_cast<uint8_t*>(mmap( uint8_t *map = static_cast<uint8_t*>(mmap(
nullptr, spaBuffer->datas->maxsize + spaBuffer->datas->mapoffset, nullptr, spaBuffer->datas->maxsize + spaBuffer->datas->mapoffset,
PROT_READ, MAP_PRIVATE, spaBuffer->datas->fd, 0)); PROT_READ, MAP_PRIVATE, spaBuffer->datas->fd, 0));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment