diff --git a/src/playback_thread.cpp b/src/playback_thread.cpp index 0bbcfad..fdeb504 100644 --- a/src/playback_thread.cpp +++ b/src/playback_thread.cpp @@ -45,9 +45,7 @@ void Playback::setOptions(bool n, int c) { } void Playback::setDisplayed(bool shown) { - mutex_shown.lock(); video_shown = shown; - mutex_shown.unlock(); } void Playback::run() { @@ -86,12 +84,7 @@ void Playback::run() { writer.write(frame); } mutex.unlock(); - bool shown_var; - mutex_shown.lock(); - shown_var = video_shown; - mutex_shown.unlock(); - - if(shown_var == true) { + if(video_shown == true) { if(frame.channels()==3) { cv::cvtColor(frame, rgb_frame, CV_BGR2RGB); img = QImage((const unsigned char*)(rgb_frame.data), rgb_frame.cols, rgb_frame.rows, QImage::Format_RGB888); diff --git a/src/playback_thread.h b/src/playback_thread.h index 8cc2a63..14c0251 100644 --- a/src/playback_thread.h +++ b/src/playback_thread.h @@ -9,7 +9,8 @@ class Playback : public QThread { Q_OBJECT private: std::atomic stop; - QMutex mutex,mutex_shown,mutex_add, mutex_start; + std::atomic video_shown; + QMutex mutex, mutex_shown, mutex_add; QWaitCondition condition; cv::Mat frame; int frame_rate; @@ -20,7 +21,6 @@ private: QImage img; std::vector> current; bool isPaused, isStep; - bool video_shown; public: Playback(QObject *parent = 0); ~Playback();