diff --git a/plugins/channelrx/demoddatv/datvdemodsink.cpp b/plugins/channelrx/demoddatv/datvdemodsink.cpp index 76a869dda..7a580ec57 100644 --- a/plugins/channelrx/demoddatv/datvdemodsink.cpp +++ b/plugins/channelrx/demoddatv/datvdemodsink.cpp @@ -62,7 +62,7 @@ DATVDemodSink::~DATVDemodSink() m_blnInitialized = false; //Immediately exit from DATVideoStream if waiting for data before killing thread - m_objVideoStream->ThreadTimeOut = 0; + m_objVideoStream->setThreadTimeout(0); m_objVideoStream->deleteLater(); stopVideo(); @@ -173,8 +173,8 @@ bool DATVDemodSink::playVideo() if (m_objVideoStream->bytesAvailable() > 0) { - m_objVideoStream->MultiThreaded = true; - m_objVideoStream->ThreadTimeOut = DATVideoRenderThread::videoThreadTimeoutMs; + m_objVideoStream->setMultiThreaded(true); + m_objVideoStream->setThreadTimeout(DATVideoRenderThread::videoThreadTimeoutMs); m_objRenderThread->start(); } diff --git a/plugins/channelrx/demoddatv/datvideorender.h b/plugins/channelrx/demoddatv/datvideorender.h index b66110fe6..2446c4057 100644 --- a/plugins/channelrx/demoddatv/datvideorender.h +++ b/plugins/channelrx/demoddatv/datvideorender.h @@ -235,7 +235,7 @@ class DATVideoRenderThread : public QThread m_renderingVideo = false; } - static const int videoThreadTimeoutMs = 500; + static const int videoThreadTimeoutMs = 1000; private: DATVideoRender *m_renderer; diff --git a/plugins/channelrx/demoddatv/datvideostream.cpp b/plugins/channelrx/demoddatv/datvideostream.cpp index aa3727d99..4eba45b4a 100644 --- a/plugins/channelrx/demoddatv/datvideostream.cpp +++ b/plugins/channelrx/demoddatv/datvideostream.cpp @@ -26,8 +26,8 @@ DATVideostream::DATVideostream(): m_intTotalReceived = 0; m_intPacketReceived = 0; m_intMemoryLimit = m_defaultMemoryLimit; - MultiThreaded = false; - ThreadTimeOut = -1; + m_multiThreaded = false; + m_threadTimeout = -1; m_objeventLoop.connect(this,SIGNAL(onDataAvailable()), &m_objeventLoop, SLOT(quit()),Qt::QueuedConnection); } @@ -59,6 +59,18 @@ void DATVideostream::resetTotalReceived() emit onDataPackets(&m_intBytesWaiting, &m_intPercentBuffer, &m_intTotalReceived); } +void DATVideostream::setMultiThreaded(bool multiThreaded) +{ + if (multiThreaded) + { + if (m_objeventLoop.isRunning()) { + m_objeventLoop.exit(); + } + } + + m_multiThreaded = multiThreaded; +} + int DATVideostream::pushData(const char * chrData, int intSize) { if (intSize <= 0) { @@ -146,7 +158,7 @@ qint64 DATVideostream::readData(char *data, qint64 len) { m_objMutex.unlock(); - if (MultiThreaded == true) + if (m_multiThreaded == true) { intThreadLoop=0; @@ -155,9 +167,9 @@ qint64 DATVideostream::readData(char *data, qint64 len) QThread::msleep(5); intThreadLoop++; - if (ThreadTimeOut >= 0) + if (m_threadTimeout >= 0) { - if (intThreadLoop*5 > ThreadTimeOut) { + if (intThreadLoop*5 > m_threadTimeout) { return -1; } } @@ -172,7 +184,7 @@ qint64 DATVideostream::readData(char *data, qint64 len) } //Read DATA - intEffectiveLen=m_objFIFO.head().size(); + intEffectiveLen = m_objFIFO.head().size(); if (intExpectedLen < intEffectiveLen) { diff --git a/plugins/channelrx/demoddatv/datvideostream.h b/plugins/channelrx/demoddatv/datvideostream.h index e6665c13d..3436ec2b4 100644 --- a/plugins/channelrx/demoddatv/datvideostream.h +++ b/plugins/channelrx/demoddatv/datvideostream.h @@ -34,14 +34,14 @@ public: DATVideostream(); ~DATVideostream(); - bool MultiThreaded; - int ThreadTimeOut; - static const int m_defaultMemoryLimit = 2048000; + static const int m_defaultMemoryLimit = 2820000; static const int m_minStackSize = 4; int pushData(const char * chrData, int intSize); void resetTotalReceived(); void cleanUp(); + void setMultiThreaded(bool multiThreaded); + void setThreadTimeout(int timeOut) { m_threadTimeout = timeOut; } virtual bool isSequential() const; virtual qint64 bytesAvailable() const; @@ -62,6 +62,8 @@ protected: virtual qint64 readLineData(char *data, qint64 maxSize); private: + bool m_multiThreaded; + int m_threadTimeout; QEventLoop m_objeventLoop; QMutex m_objMutex;