mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-03 06:08:39 +00:00
feat: change qt atomic to std::atomic
This commit is contained in:
parent
6b1a556e32
commit
96529076af
2 changed files with 5 additions and 6 deletions
|
@ -16,7 +16,7 @@ typedef qint32 (*ReadPacketFunc)(void*, quint8*, qint32);
|
||||||
Stream::Stream(QObject *parent)
|
Stream::Stream(QObject *parent)
|
||||||
: QThread(parent)
|
: QThread(parent)
|
||||||
{
|
{
|
||||||
m_quit.store(0);
|
m_quit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream::~Stream()
|
Stream::~Stream()
|
||||||
|
@ -227,14 +227,14 @@ bool Stream::startDecode()
|
||||||
if (!m_videoSocket) {
|
if (!m_videoSocket) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_quit.store(0);
|
m_quit = false;
|
||||||
start();
|
start();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stream::stopDecode()
|
void Stream::stopDecode()
|
||||||
{
|
{
|
||||||
m_quit.store(1);
|
m_quit = true;
|
||||||
if (m_decoder) {
|
if (m_decoder) {
|
||||||
m_decoder->interrupt();
|
m_decoder->interrupt();
|
||||||
}
|
}
|
||||||
|
@ -316,7 +316,7 @@ void Stream::run()
|
||||||
packet.size = 0;
|
packet.size = 0;
|
||||||
|
|
||||||
while (!av_read_frame(formatCtx, &packet)) {
|
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
|
// if the stream is stopped, the socket had been shutdown, so the
|
||||||
// last packet is probably corrupted (but not detected as such by
|
// last packet is probably corrupted (but not detected as such by
|
||||||
// FFmpeg) and will not be decoded correctly
|
// FFmpeg) and will not be decoded correctly
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QAtomicInteger>
|
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
@ -53,7 +52,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<VideoSocket> m_videoSocket;
|
QPointer<VideoSocket> m_videoSocket;
|
||||||
QAtomicInteger<qint8> m_quit;
|
std::atomic_bool m_quit;
|
||||||
|
|
||||||
// for recorder
|
// for recorder
|
||||||
Recorder* m_recorder = Q_NULLPTR;
|
Recorder* m_recorder = Q_NULLPTR;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue