From c919513d2649882f3fc90bae9a1d68d06eee01f8 Mon Sep 17 00:00:00 2001 From: Charles Otto Date: Mon, 12 Aug 2013 19:48:17 -0700 Subject: [PATCH] Use a mutex when opening videos in stream, this appears to not be thread safe on windows. --- openbr/plugins/stream.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/openbr/plugins/stream.cpp b/openbr/plugins/stream.cpp index 15944be..4550baa 100644 --- a/openbr/plugins/stream.cpp +++ b/openbr/plugins/stream.cpp @@ -364,6 +364,7 @@ protected: QMutex last_frame_update; }; +static QMutex openLock; // Read a video frame by frame using cv::VideoCapture class VideoDataSource : public DataSource { @@ -396,6 +397,8 @@ public: // Yes, we should specify absolute path: // http://stackoverflow.com/questions/9396459/loading-a-video-in-opencv-in-python QString fileName = (Globals->path.isEmpty() ? "" : Globals->path + "/") + input.file.name; + // On windows, this appears to not be thread-safe + QMutexLocker lock(&openLock); video.open(QFileInfo(fileName).absoluteFilePath().toStdString()); } @@ -1057,7 +1060,10 @@ public: dst = src; bool res = readStage->dataSource.open(dst); - if (!res) return; + if (!res) { + qDebug("stream failed to open %s", qPrintable(dst[0].file.name)); + return; + } // Start the first thread in the stream. QWriteLocker lock(&readStage->statusLock); -- libgit2 0.21.4