From bfd3131e63c265fdb70daa61d49eae77c3dbd61c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 19 May 2021 10:04:54 -0400 Subject: [PATCH] try additional unrefs of hw_device_ctx and unref'ing after freeing codec --- src/zm_videostore.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index e97e0b3e9..92c482764 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -272,7 +272,7 @@ bool VideoStore::open() { frames_ctx->initial_pool_size = 20; if ((ret = av_hwframe_ctx_init(hw_frames_ref)) < 0) { Error("Failed to initialize hwaccel frame context." - "Error code: %s",av_err2str(ret)); + "Error code: %s", av_err2str(ret)); av_buffer_unref(&hw_frames_ref); } else { video_out_ctx->hw_frames_ctx = av_buffer_ref(hw_frames_ref); @@ -281,6 +281,7 @@ bool VideoStore::open() { } } av_buffer_unref(&hw_frames_ref); + av_buffer_unref(&hw_device_ctx); } // end if hwdevice_type != NONE #endif @@ -666,9 +667,12 @@ VideoStore::~VideoStore() { video_in_ctx = nullptr; avcodec_close(video_out_ctx); - if (hw_device_ctx) av_buffer_unref(&hw_device_ctx); - Debug(4, "Freeing video_out_ctx"); + Debug(3, "Freeing video_out_ctx"); avcodec_free_context(&video_out_ctx); + if (hw_device_ctx) { + Debug(3, "Freeing hw_device_ctx"); + av_buffer_unref(&hw_device_ctx); + } } // end if video_out_stream if (audio_out_stream) {