From 35ec0c9bcfe57c29d3d1596f9871c52c57495bd1 Mon Sep 17 00:00:00 2001 From: Bruno Herbelin Date: Sat, 22 Jan 2022 00:20:40 +0100 Subject: [PATCH] BugFix: prevent repeated initialization --- FrameGrabber.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/FrameGrabber.cpp b/FrameGrabber.cpp index 4ba12e7..69cad79 100644 --- a/FrameGrabber.cpp +++ b/FrameGrabber.cpp @@ -379,11 +379,6 @@ void FrameGrabber::addFrame (GstBuffer *buffer, GstCaps *caps) if (buffer == nullptr) return; - // first time initialization - if (pipeline_ == nullptr) { - initializer_ = std::async( FrameGrabber::initialize, this, caps); - } - // initializer ongoing in separate thread if (initializer_.valid()) { // try to get info from initializer @@ -412,6 +407,10 @@ void FrameGrabber::addFrame (GstBuffer *buffer, GstCaps *caps) } } } + // first time initialization + else if (pipeline_ == nullptr) { + initializer_ = std::async( FrameGrabber::initialize, this, caps); + } // stop if an incompatilble frame buffer given after initialization if (initialized_ && !gst_caps_is_subset( caps_, caps ))