feat: change qt atomic to std::atomic

This commit is contained in:
rankun 2019-08-21 11:35:25 +08:00
parent 6b1a556e32
commit 96529076af
2 changed files with 5 additions and 6 deletions

View file

@ -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

View file

@ -4,7 +4,6 @@
#include <QThread>
#include <QPointer>
#include <QMutex>
#include <QAtomicInteger>
extern "C"
{
@ -53,7 +52,7 @@ protected:
private:
QPointer<VideoSocket> m_videoSocket;
QAtomicInteger<qint8> m_quit;
std::atomic_bool m_quit;
// for recorder
Recorder* m_recorder = Q_NULLPTR;