Improve FPS handling
This commit is contained in:
@ -47,10 +47,10 @@ void buffer_lock_capture(buffer_lock_t *buf_lock, buffer_t *buf)
|
||||
buffer_consumed(buf_lock->buf, buf_lock->name);
|
||||
buf_lock->buf = NULL;
|
||||
buf_lock->buf_time_us = now;
|
||||
} else if (now - buf_lock->buf_time_us < buf->buf_list->fmt_interval_us) {
|
||||
} else if (now - buf_lock->buf_time_us < buf_lock->frame_interval_ms * 1000) {
|
||||
buf_lock->dropped++;
|
||||
|
||||
E_LOG_DEBUG(buf_lock, "Dropped buffer %s (refs=%d), frame=%d/%d, frame_us=%.1f",
|
||||
E_LOG_DEBUG(buf_lock, "Dropped buffer %s (refs=%d), frame=%d/%d, frame_ms=%.1f",
|
||||
dev_name(buf), buf ? buf->mmap_reflinks : 0,
|
||||
buf_lock->counter, buf_lock->dropped,
|
||||
(now - captured_time_us) / 1000.0f);
|
||||
@ -59,7 +59,7 @@ void buffer_lock_capture(buffer_lock_t *buf_lock, buffer_t *buf)
|
||||
buffer_use(buf);
|
||||
buf_lock->buf = buf;
|
||||
buf_lock->counter++;
|
||||
E_LOG_DEBUG(buf_lock, "Captured buffer %s (refs=%d), frame=%d/%d, processing_us=%.1f, frame_us=%.1f",
|
||||
E_LOG_DEBUG(buf_lock, "Captured buffer %s (refs=%d), frame=%d/%d, processing_ms=%.1f, frame_ms=%.1f",
|
||||
dev_name(buf), buf ? buf->mmap_reflinks : 0,
|
||||
buf_lock->counter, buf_lock->dropped,
|
||||
(now - captured_time_us) / 1000.0f,
|
||||
|
@ -14,6 +14,8 @@ typedef struct buffer_lock_s {
|
||||
int refs;
|
||||
int dropped;
|
||||
uint64_t timeout_us;
|
||||
|
||||
int frame_interval_ms;
|
||||
} buffer_lock_t;
|
||||
|
||||
#define DEFAULT_BUFFER_LOCK_TIMEOUT 16 // ~60fps
|
||||
|
@ -67,10 +67,16 @@ int _build_fds(link_t *all_links, struct pollfd *fds, link_t **links, buffer_lis
|
||||
}
|
||||
|
||||
int count_enqueued = buffer_list_count_enqueued(source);
|
||||
bool can_dequeue = count_enqueued > 0;
|
||||
|
||||
if (now_us - source->last_dequeued_us < source->fmt_interval_us) {
|
||||
can_dequeue = false;
|
||||
*max_timeout_ms = MIN(*max_timeout_ms, (source->last_dequeued_us + source->fmt_interval_us - now_us) / 1000);
|
||||
}
|
||||
|
||||
fds[n].fd = source->device->fd;
|
||||
fds[n].events = POLLHUP;
|
||||
if (count_enqueued > 0)
|
||||
if (can_dequeue)
|
||||
fds[n].events |= POLLIN;
|
||||
fds[n].revents = 0;
|
||||
buf_lists[n] = source;
|
||||
|
Reference in New Issue
Block a user