[common] fix FrameBuffer to use atomics correctly

Might Fix #248
This commit is contained in:
Geoffrey McRae
2020-04-12 13:14:53 +10:00
parent b5f4c639fd
commit 1222fd40b7
4 changed files with 39 additions and 21 deletions

View File

@@ -23,24 +23,19 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include <stdbool.h>
#include <stdint.h>
typedef struct stFrameBuffer
{
uint64_t wp;
uint8_t data[0];
}
FrameBuffer;
typedef struct stFrameBuffer 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
*/
static inline void framebuffer_wait(const FrameBuffer * frame, size_t size)
{
while(frame->wp != size) {}
}
void framebuffer_wait(const FrameBuffer * frame, size_t size);
/**
* Read data from the KVMFRFrame into the dst buffer
@@ -60,4 +55,4 @@ void framebuffer_prepare(FrameBuffer * frame);
/**
* Write data from the src buffer into the KVMFRFrame
*/
bool framebuffer_write(FrameBuffer * frame, const void * src, size_t size);
bool framebuffer_write(FrameBuffer * frame, const void * src, size_t size);