Add buffer lock deadline for no frame

This commit is contained in:
Kamil Trzcinski 2022-04-10 14:00:53 +02:00
parent 7275b56e6d
commit 885ec79f5b

View File

@ -105,6 +105,7 @@ int buffer_lock_write_loop(buffer_lock_t *buf_lock, int nframes, buffer_write_fn
{ {
int counter = 0; int counter = 0;
int frames = 0; int frames = 0;
uint64_t deadline_ms = get_monotonic_time_us(NULL, NULL) + DEFAULT_BUFFER_LOCK_GET_TIMEOUT * 1000LL;
buffer_lock_use(buf_lock, 1); buffer_lock_use(buf_lock, 1);
@ -121,6 +122,9 @@ int buffer_lock_write_loop(buffer_lock_t *buf_lock, int nframes, buffer_write_fn
frames++; frames++;
} else if (ret < 0) { } else if (ret < 0) {
goto error; goto error;
} else if(!frames && deadline_ms < get_monotonic_time_us(NULL, NULL)) {
E_LOG_DEBUG(buf_lock, "Deadline getting frame elapsed.");
goto error;
} }
} }