Fix buffer re-use on short streaming

This commit is contained in:
Kamil Trzcinski
2022-04-04 22:52:31 +02:00
parent a20883e8f1
commit 6c628cfe72
4 changed files with 44 additions and 10 deletions

View File

@@ -32,10 +32,12 @@ void http_video(http_worker_t *worker, FILE *stream)
int counter = 0;
fprintf(stream, VIDEO_HEADER);
buffer_lock_use(&http_h264, 1);
while (!feof(stream)) {
buffer_t *buf = buffer_lock_get(&http_h264, 3, &counter);
if (!buf) {
return;
goto error;
}
if (buf->v4l2_buffer.flags & V4L2_BUF_FLAG_KEYFRAME) {
@@ -51,4 +53,7 @@ void http_video(http_worker_t *worker, FILE *stream)
}
buffer_consumed(buf);
}
error:
buffer_lock_use(&http_h264, -1);
}