diff --git a/src/main_window.cpp b/src/main_window.cpp index f1f4488..fae701e 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -456,12 +456,12 @@ bool AC_MainWindow::startVideo(const QString &filename, const QString &outdir, b void AC_MainWindow::controls_Stop() { playback->Stop(); + progress_bar->hide(); controls_showvideo->setEnabled(false); controls_stop->setEnabled(false); controls_pause->setEnabled(false); controls_step->setEnabled(false); controls_snapshot->setEnabled(false); - if(capture_video.isOpened()) { capture_video.release(); if(recording == true) writer.release(); @@ -492,7 +492,6 @@ void AC_MainWindow::controls_Stop() { disp->hide(); playback->Release(); } - } void AC_MainWindow::controls_ShowVideo() { diff --git a/src/playback_thread.cpp b/src/playback_thread.cpp index 4a8368f..0bbcfad 100644 --- a/src/playback_thread.cpp +++ b/src/playback_thread.cpp @@ -12,6 +12,7 @@ void Playback::Play() { stop = false; } } + //start(LowPriority); start(HighPriority); } @@ -58,13 +59,11 @@ void Playback::run() { emit stopRecording(); return; } - + mutex.unlock(); static std::vector> cur; mutex_shown.lock(); cur = current; mutex_shown.unlock(); - - ac::orig_frame = frame.clone(); if(cur.size()>0) { ac::in_custom = true; @@ -82,6 +81,7 @@ void Playback::run() { } } } + mutex.lock(); if(recording && writer.isOpened()) { writer.write(frame); } @@ -122,9 +122,7 @@ Playback::~Playback() { } void Playback::Stop() { - mutex.lock(); stop = true; - mutex.unlock(); } void Playback::Release() { diff --git a/src/playback_thread.h b/src/playback_thread.h index 94bac60..8cc2a63 100644 --- a/src/playback_thread.h +++ b/src/playback_thread.h @@ -3,11 +3,13 @@ #include "qtheaders.h" +#include + class Playback : public QThread { Q_OBJECT private: - bool stop; - QMutex mutex,mutex_shown,mutex_add; + std::atomic stop; + QMutex mutex,mutex_shown,mutex_add, mutex_start; QWaitCondition condition; cv::Mat frame; int frame_rate;