From 885ec79f5b5071b432d8ca76040989c51d5c594f Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sun, 10 Apr 2022 14:00:53 +0200 Subject: [PATCH] Add buffer lock deadline for no frame --- device/buffer_lock.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/device/buffer_lock.c b/device/buffer_lock.c index e19aee6..62affc1 100644 --- a/device/buffer_lock.c +++ b/device/buffer_lock.c @@ -105,6 +105,7 @@ int buffer_lock_write_loop(buffer_lock_t *buf_lock, int nframes, buffer_write_fn { int counter = 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); @@ -121,6 +122,9 @@ int buffer_lock_write_loop(buffer_lock_t *buf_lock, int nframes, buffer_write_fn frames++; } else if (ret < 0) { goto error; + } else if(!frames && deadline_ms < get_monotonic_time_us(NULL, NULL)) { + E_LOG_DEBUG(buf_lock, "Deadline getting frame elapsed."); + goto error; } }