mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 01:55:48 -05:00
DATV demod: player refactoring: preliminary cleanup (3)
This commit is contained in:
parent
1c0aa9cd8e
commit
d22cd45b14
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user