mirror of
https://github.com/lostjared/Acid.Cam.v2.Qt.git
synced 2025-12-17 12:20:00 +01:00
updated to use std::atomic
This commit is contained in:
@@ -456,12 +456,12 @@ bool AC_MainWindow::startVideo(const QString &filename, const QString &outdir, b
|
|||||||
|
|
||||||
void AC_MainWindow::controls_Stop() {
|
void AC_MainWindow::controls_Stop() {
|
||||||
playback->Stop();
|
playback->Stop();
|
||||||
|
progress_bar->hide();
|
||||||
controls_showvideo->setEnabled(false);
|
controls_showvideo->setEnabled(false);
|
||||||
controls_stop->setEnabled(false);
|
controls_stop->setEnabled(false);
|
||||||
controls_pause->setEnabled(false);
|
controls_pause->setEnabled(false);
|
||||||
controls_step->setEnabled(false);
|
controls_step->setEnabled(false);
|
||||||
controls_snapshot->setEnabled(false);
|
controls_snapshot->setEnabled(false);
|
||||||
|
|
||||||
if(capture_video.isOpened()) {
|
if(capture_video.isOpened()) {
|
||||||
capture_video.release();
|
capture_video.release();
|
||||||
if(recording == true) writer.release();
|
if(recording == true) writer.release();
|
||||||
@@ -492,7 +492,6 @@ void AC_MainWindow::controls_Stop() {
|
|||||||
disp->hide();
|
disp->hide();
|
||||||
playback->Release();
|
playback->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AC_MainWindow::controls_ShowVideo() {
|
void AC_MainWindow::controls_ShowVideo() {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ void Playback::Play() {
|
|||||||
stop = false;
|
stop = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//start(LowPriority);
|
||||||
start(HighPriority);
|
start(HighPriority);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,13 +59,11 @@ void Playback::run() {
|
|||||||
emit stopRecording();
|
emit stopRecording();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
mutex.unlock();
|
||||||
static std::vector<std::pair<int, int>> cur;
|
static std::vector<std::pair<int, int>> cur;
|
||||||
mutex_shown.lock();
|
mutex_shown.lock();
|
||||||
cur = current;
|
cur = current;
|
||||||
mutex_shown.unlock();
|
mutex_shown.unlock();
|
||||||
|
|
||||||
|
|
||||||
ac::orig_frame = frame.clone();
|
ac::orig_frame = frame.clone();
|
||||||
if(cur.size()>0) {
|
if(cur.size()>0) {
|
||||||
ac::in_custom = true;
|
ac::in_custom = true;
|
||||||
@@ -82,6 +81,7 @@ void Playback::run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mutex.lock();
|
||||||
if(recording && writer.isOpened()) {
|
if(recording && writer.isOpened()) {
|
||||||
writer.write(frame);
|
writer.write(frame);
|
||||||
}
|
}
|
||||||
@@ -122,9 +122,7 @@ Playback::~Playback() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Playback::Stop() {
|
void Playback::Stop() {
|
||||||
mutex.lock();
|
|
||||||
stop = true;
|
stop = true;
|
||||||
mutex.unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playback::Release() {
|
void Playback::Release() {
|
||||||
|
|||||||
@@ -3,11 +3,13 @@
|
|||||||
|
|
||||||
#include "qtheaders.h"
|
#include "qtheaders.h"
|
||||||
|
|
||||||
|
#include<atomic>
|
||||||
|
|
||||||
class Playback : public QThread {
|
class Playback : public QThread {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
bool stop;
|
std::atomic<bool> stop;
|
||||||
QMutex mutex,mutex_shown,mutex_add;
|
QMutex mutex,mutex_shown,mutex_add, mutex_start;
|
||||||
QWaitCondition condition;
|
QWaitCondition condition;
|
||||||
cv::Mat frame;
|
cv::Mat frame;
|
||||||
int frame_rate;
|
int frame_rate;
|
||||||
|
|||||||
Reference in New Issue
Block a user