Add declare buffer lock

This commit is contained in:
Kamil Trzcinski 2022-04-06 18:11:19 +02:00
parent 4a7a42bab2
commit 14c0290e22

View File

@ -18,13 +18,15 @@ typedef struct buffer_lock_s {
#define DEFAULT_BUFFER_LOCK_TIMEOUT 16 // ~60fps
#define DEFAULT_BUFFER_LOCK_GET_TIMEOUT 2000 // 2s
#define DEFINE_BUFFER_LOCK(_name, _timeout_ms) static buffer_lock_t _name = { \
#define DEFINE_BUFFER_LOCK(_name, _timeout_ms) buffer_lock_t _name = { \
.name = #_name, \
.lock = PTHREAD_MUTEX_INITIALIZER, \
.cond_wait = PTHREAD_COND_INITIALIZER, \
.timeout_us = (_timeout_ms > DEFAULT_BUFFER_LOCK_TIMEOUT ? _timeout_ms : DEFAULT_BUFFER_LOCK_TIMEOUT) * 1000LL, \
};
#define DECLARE_BUFFER_LOCK(_name) extern buffer_lock_t _name;
typedef int (*buffer_write_fn)(buffer_lock_t *buf_lock, buffer_t *buf, int frame, void *data);
void buffer_lock_capture(buffer_lock_t *buf_lock, buffer_t *buf);