Commit c919513d2649882f3fc90bae9a1d68d06eee01f8
1 parent
eb9a51b0
Use a mutex when opening videos in stream, this appears to not be thread safe on windows.
Showing
1 changed file
with
7 additions
and
1 deletions
openbr/plugins/stream.cpp
| ... | ... | @@ -364,6 +364,7 @@ protected: |
| 364 | 364 | QMutex last_frame_update; |
| 365 | 365 | }; |
| 366 | 366 | |
| 367 | +static QMutex openLock; | |
| 367 | 368 | // Read a video frame by frame using cv::VideoCapture |
| 368 | 369 | class VideoDataSource : public DataSource |
| 369 | 370 | { |
| ... | ... | @@ -396,6 +397,8 @@ public: |
| 396 | 397 | // Yes, we should specify absolute path: |
| 397 | 398 | // http://stackoverflow.com/questions/9396459/loading-a-video-in-opencv-in-python |
| 398 | 399 | QString fileName = (Globals->path.isEmpty() ? "" : Globals->path + "/") + input.file.name; |
| 400 | + // On windows, this appears to not be thread-safe | |
| 401 | + QMutexLocker lock(&openLock); | |
| 399 | 402 | video.open(QFileInfo(fileName).absoluteFilePath().toStdString()); |
| 400 | 403 | } |
| 401 | 404 | |
| ... | ... | @@ -1057,7 +1060,10 @@ public: |
| 1057 | 1060 | dst = src; |
| 1058 | 1061 | |
| 1059 | 1062 | bool res = readStage->dataSource.open(dst); |
| 1060 | - if (!res) return; | |
| 1063 | + if (!res) { | |
| 1064 | + qDebug("stream failed to open %s", qPrintable(dst[0].file.name)); | |
| 1065 | + return; | |
| 1066 | + } | |
| 1061 | 1067 | |
| 1062 | 1068 | // Start the first thread in the stream. |
| 1063 | 1069 | QWriteLocker lock(&readStage->statusLock); | ... | ... |