From 1f819ed0f0f9b31219c665df4d6de8099e72b814 Mon Sep 17 00:00:00 2001 From: Nikolaos Ftylitakis Date: Tue, 7 Dec 2021 11:34:34 +0200 Subject: [PATCH] fix of VideoSink use for Android: map/unmap every frame. @kiibimees #199 --- src/QZXingFilterVideoSink.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/QZXingFilterVideoSink.cpp b/src/QZXingFilterVideoSink.cpp index e0536c6..49f1f6e 100644 --- a/src/QZXingFilterVideoSink.cpp +++ b/src/QZXingFilterVideoSink.cpp @@ -44,10 +44,6 @@ void QZXingFilter::setVideoSink(QObject *videoSink){ } void QZXingFilter::processFrame(const QVideoFrame &frame) { - if(isDecoding() || !processThread.isFinished()) return; - - decoding = true; - #ifdef Q_OS_ANDROID m_videoSink->setRhi(nullptr); // https://bugreports.qt.io/browse/QTBUG-97789 QVideoFrame f(frame); @@ -56,15 +52,17 @@ void QZXingFilter::processFrame(const QVideoFrame &frame) { const QVideoFrame &f = frame; #endif // Q_OS_ANDROID + if(isDecoding() || !processThread.isFinished()) return; + + decoding = true; + QImage image = f.toImage(); #ifdef Q_OS_ANDROID f.unmap(); #endif -#ifndef Q_OS_ANDROID processThread = QtConcurrent::run([=](){ -#endif if(image.isNull()) { qDebug() << "QZXingFilter error: Cant create image file to process."; @@ -86,8 +84,5 @@ void QZXingFilter::processFrame(const QVideoFrame &frame) { // qDebug() << "saving image" << i << "at:" << path << frameToProcess.save(path); decoder.decodeImage(frameToProcess, frameToProcess.width(), frameToProcess.height()); -#ifndef Q_OS_ANDROID }); -#endif - }