summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorRick Kern <kernrj@gmail.com>2016-10-10 09:13:39 -0400
committerRick Kern <kernrj@gmail.com>2016-10-17 08:58:17 -0400
commitaa413b810a7f94d8317635160a1de1b573b138ee (patch)
treebbe6c09133f3acfc6cbd16adee3a56d285c08879 /libavcodec
parent9ea91e4114e802738b6075ed0801a48e9e5fcd80 (diff)
lavc/videotoolboxenc: flush/free frames on close
Prevents encode callback from running after codec is closed. Fixes a crash when an error is returned. Signed-off-by: Rick Kern <kernrj@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/videotoolboxenc.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index d9100494d7..73e673f082 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -145,6 +145,11 @@ static void set_async_error(VTEncContext *vtctx, int err)
pthread_mutex_unlock(&vtctx->lock);
}
+static void clear_frame_queue(VTEncContext *vtctx)
+{
+ set_async_error(vtctx, 0);
+}
+
static int vtenc_q_pop(VTEncContext *vtctx, bool wait, CMSampleBufferRef *buf, ExtraSEI **sei)
{
BufNode *info;
@@ -1966,6 +1971,9 @@ static av_cold int vtenc_close(AVCodecContext *avctx)
if(!vtctx->session) return 0;
+ VTCompressionSessionCompleteFrames(vtctx->session,
+ kCMTimeIndefinite);
+ clear_frame_queue(vtctx);
pthread_cond_destroy(&vtctx->cv_sample_sent);
pthread_mutex_destroy(&vtctx->lock);
CFRelease(vtctx->session);