diff --git a/QtScrcpy/device/stream/stream.cpp b/QtScrcpy/device/stream/stream.cpp index dbe7eb1..648aef2 100644 --- a/QtScrcpy/device/stream/stream.cpp +++ b/QtScrcpy/device/stream/stream.cpp @@ -16,7 +16,7 @@ typedef qint32 (*ReadPacketFunc)(void*, quint8*, qint32); Stream::Stream(QObject *parent) : QThread(parent) { - m_quit.store(0); + m_quit = false; } Stream::~Stream() @@ -227,14 +227,14 @@ bool Stream::startDecode() if (!m_videoSocket) { return false; } - m_quit.store(0); + m_quit = false; start(); return true; } void Stream::stopDecode() { - m_quit.store(1); + m_quit = true; if (m_decoder) { m_decoder->interrupt(); } @@ -316,7 +316,7 @@ void Stream::run() packet.size = 0; while (!av_read_frame(formatCtx, &packet)) { - if (m_quit.load()) { + if (m_quit) { // if the stream is stopped, the socket had been shutdown, so the // last packet is probably corrupted (but not detected as such by // FFmpeg) and will not be decoded correctly diff --git a/QtScrcpy/device/stream/stream.h b/QtScrcpy/device/stream/stream.h index 4f075ba..0c4605e 100644 --- a/QtScrcpy/device/stream/stream.h +++ b/QtScrcpy/device/stream/stream.h @@ -4,7 +4,6 @@ #include #include #include -#include extern "C" { @@ -53,7 +52,7 @@ protected: private: QPointer m_videoSocket; - QAtomicInteger m_quit; + std::atomic_bool m_quit; // for recorder Recorder* m_recorder = Q_NULLPTR;