From 62d0661f98f653af39b2bc657fc0213b4d330366 Mon Sep 17 00:00:00 2001 From: Exeldro Date: Mon, 17 May 2021 21:35:18 +0200 Subject: [PATCH] obs-ffmpeg: Don't purge packets when there are none --- plugins/obs-ffmpeg/obs-ffmpeg-mux.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-mux.c b/plugins/obs-ffmpeg/obs-ffmpeg-mux.c index cba35e651..ee5c8f15a 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-mux.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-mux.c @@ -724,6 +724,9 @@ static bool purge_front(struct ffmpeg_muxer *stream) struct encoder_packet pkt; bool keyframe; + if (!stream->packets.size) + return false; + circlebuf_pop_front(&stream->packets, &pkt, sizeof(pkt)); keyframe = pkt.type == OBS_ENCODER_VIDEO && pkt.keyframe; @@ -751,6 +754,8 @@ static inline void purge(struct ffmpeg_muxer *stream) struct encoder_packet pkt; for (;;) { + if (!stream->packets.size) + return; circlebuf_peek_front(&stream->packets, &pkt, sizeof(pkt)); if (pkt.type == OBS_ENCODER_VIDEO && pkt.keyframe)