mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-07-31 12:58:39 +00:00
确保DeviceSocket subThreadRecvData不在主线程调用
This commit is contained in:
parent
3e906c51d3
commit
05d5626a84
3 changed files with 8 additions and 7 deletions
|
@ -57,7 +57,7 @@ qint32 Decoder::recvData(quint8* buf, qint32 bufSize)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (m_deviceSocket) {
|
if (m_deviceSocket) {
|
||||||
qint32 len = m_deviceSocket->recvData(buf, bufSize);
|
qint32 len = m_deviceSocket->subThreadRecvData(buf, bufSize);
|
||||||
if (len == -1) {
|
if (len == -1) {
|
||||||
return AVERROR(errno);
|
return AVERROR(errno);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QThread>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "qscrcpyevent.h"
|
#include "qscrcpyevent.h"
|
||||||
|
@ -16,8 +17,10 @@ DeviceSocket::~DeviceSocket()
|
||||||
quitNotify();
|
quitNotify();
|
||||||
}
|
}
|
||||||
|
|
||||||
qint32 DeviceSocket::recvData(quint8 *buf, qint32 bufSize)
|
qint32 DeviceSocket::subThreadRecvData(quint8 *buf, qint32 bufSize)
|
||||||
{
|
{
|
||||||
|
// this function cant call in main thread
|
||||||
|
Q_ASSERT(QCoreApplication::instance()->thread() != QThread::currentThread());
|
||||||
if (m_quit) {
|
if (m_quit) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,16 +13,14 @@ public:
|
||||||
explicit DeviceSocket(QObject *parent = nullptr);
|
explicit DeviceSocket(QObject *parent = nullptr);
|
||||||
virtual ~DeviceSocket();
|
virtual ~DeviceSocket();
|
||||||
|
|
||||||
qint32 recvData(quint8* buf, qint32 bufSize);
|
qint32 subThreadRecvData(quint8* buf, qint32 bufSize);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent *event);
|
bool event(QEvent *event);
|
||||||
|
|
||||||
public slots:
|
|
||||||
void quitNotify();
|
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void onReadyRead();
|
void onReadyRead();
|
||||||
|
void quitNotify();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMutex m_mutex;
|
QMutex m_mutex;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue