diff --git a/client/src/main.c b/client/src/main.c index 1db1d7b1..e4cf5f41 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -742,7 +742,7 @@ int main_frameThread(void * unused) if (dma->fd == -1) { const uintptr_t pos = (uintptr_t)msg.mem - (uintptr_t)g_state.shm.mem; - const uintptr_t offset = (uintptr_t)frame->offset + FrameBufferStructSize; + const uintptr_t offset = (uintptr_t)frame->offset + sizeof(FrameBuffer); dma->dataSize = dataSize; dma->fd = ivshmemGetDMABuf(&g_state.shm, pos + offset, dataSize); diff --git a/common/include/common/framebuffer.h b/common/include/common/framebuffer.h index 3ac9032e..0bd76425 100644 --- a/common/include/common/framebuffer.h +++ b/common/include/common/framebuffer.h @@ -24,16 +24,21 @@ #include #include #include +#include -typedef struct stFrameBuffer FrameBuffer; +#define FB_CHUNK_SIZE 1048576 // 1MB +#define FB_SPIN_LIMIT 10000 // 10ms +#define FB_WP_TYPE atomic_uint_least32_t +#define FB_WP_SIZE sizeof(FB_WP_TYPE) + +typedef struct stFrameBuffer +{ + FB_WP_TYPE wp; + uint8_t data[0]; +} FrameBuffer; typedef bool (*FrameBufferReadFn)(void * opaque, const void * src, size_t size); -/** - * The size of the FrameBuffer struct - */ -extern const size_t FrameBufferStructSize; - /** * Wait for the framebuffer to fill to the specified size */ diff --git a/common/src/framebuffer.c b/common/src/framebuffer.c index 6656c66b..f5641ee7 100644 --- a/common/src/framebuffer.c +++ b/common/src/framebuffer.c @@ -27,22 +27,10 @@ #endif #include -#include #include #include #include -#define FB_CHUNK_SIZE 1048576 // 1MB -#define FB_SPIN_LIMIT 10000 // 10ms - -struct stFrameBuffer -{ - atomic_uint_least32_t wp; - uint8_t data[0]; -}; - -const size_t FrameBufferStructSize = sizeof(FrameBuffer); - bool framebuffer_wait(const FrameBuffer * frame, size_t size) { while(atomic_load_explicit(&frame->wp, memory_order_acquire) < size) diff --git a/host/src/app.c b/host/src/app.c index cf9e32d6..cf437525 100644 --- a/host/src/app.c +++ b/host/src/app.c @@ -275,7 +275,7 @@ static bool sendFrame(void) fi->frameHeight = frame.frameHeight; fi->stride = frame.stride; fi->pitch = frame.pitch; - fi->offset = app.pageSize - FrameBufferStructSize; + fi->offset = app.pageSize - sizeof(FrameBuffer); fi->flags = (os_blockScreensaver() ? FRAME_FLAG_BLOCK_SCREENSAVER : 0) | diff --git a/obs/lg.c b/obs/lg.c index 5307348d..0131280a 100644 --- a/obs/lg.c +++ b/obs/lg.c @@ -458,7 +458,7 @@ static int dmabufGetFd(LGPlugin * this, LGMPMessage * msg, KVMFRFrame * frame, s if (dma->fd == -1) { const uintptr_t pos = (uintptr_t) msg->mem - (uintptr_t) this->shmDev.mem; - const uintptr_t offset = (uintptr_t) frame->offset + FrameBufferStructSize; + const uintptr_t offset = (uintptr_t) frame->offset + sizeof(FrameBuffer); dma->dataSize = dataSize; dma->fd = ivshmemGetDMABuf(&this->shmDev, pos + offset, dataSize);