private:
void threadMethod();
+ void threadPostStopCleanup() {};
int audioEnabled;
int fd;
Callback& cb;
private:
void threadMethod();
+ void threadPostStopCleanup() {};
+
int fd;
Callback& cb;
Stream& stream;
virtual void call()=0; // for callback interface
virtual void threadMethod()=0; // for thread interface
+ virtual void threadPostStopCleanup()=0;
protected:
int initted;
void setLength(ULLONG length);
void threadMethod();
+ void threadPostStopCleanup() {};
void skipForward(int) {};
void skipBackward(int) {};
feedMode = MODE_NORMAL;
isRecording = tIsRecording;
lastRescan = 0;
+ threadBuffer = NULL;
}
PlayerVideo::~PlayerVideo()
void PlayerVideo::threadMethod()
{
- UCHAR* buf;
UINT thisRead;
UINT writeLength;
UINT thisWrite;
askFor = blockSize; // normal
}
- buf = vdr->getBlock(feedPosition, askFor, &thisRead);
- if (!buf) break;
+ threadBuffer = vdr->getBlock(feedPosition, askFor, &thisRead);
+ if (!threadBuffer) break;
if (startup)
{
- int a_stream = demuxer.scan(buf, thisRead);
+ int a_stream = demuxer.scan(threadBuffer, thisRead);
demuxer.setAudioStream(a_stream);
Log::getInstance()->log("Player", Log::DEBUG, "Startup Audio stream chosen %x", a_stream);
startup = 0;
while(writeLength < thisRead)
{
- thisWrite = demuxer.put(buf + writeLength, thisRead - writeLength);
+ thisWrite = demuxer.put(threadBuffer + writeLength, thisRead - writeLength);
writeLength += thisWrite;
if (!thisWrite)
threadCheckExit();
}
- free(buf);
+ free(threadBuffer);
+ threadBuffer = NULL;
}
}
+
+void PlayerVideo::threadPostStopCleanup()
+{
+ Log::getInstance()->log("Player", Log::DEBUG, "Post stop cleanup 1");
+ if (threadBuffer)
+ {
+ Log::getInstance()->log("Player", Log::DEBUG, "Post stop cleanup 2");
+ free(threadBuffer);
+ threadBuffer = NULL;
+ }
+}
void setLength(ULLONG length);
void threadMethod();
+ void threadPostStopCleanup();
private:
MessageQueue* commandMessageQueue;
const static UCHAR MODE_BACKWARDS = 2;
const static UINT blockSize = 100000;
const static UINT startupBlockSize = 250000;
+ UCHAR* threadBuffer;
UCHAR playing; // As in not stopped, (playing && paused) can == TRUE
UCHAR paused; // Must be in playing state as well
// Signal thread here in case it's waiting
threadSignal();
pthread_join(pthread, NULL);
+ this->threadPostStopCleanup();
}
void Thread::threadCancel()
threadActive = 0;
pthread_cancel(pthread);
pthread_join(pthread, NULL);
+ this->threadPostStopCleanup();
}
void Thread::threadCheckExit()
#include <pthread.h>
#include <signal.h>
+#include <stdio.h> // temp
+
class Thread
{
protected:
// Override this method in derived classes
virtual void threadMethod()=0;
+ virtual void threadPostStopCleanup()=0;
// Methods to use from outside the thread
int threadStart(); // start the thread. threadMethod() will be called in derived class
private:
void threadMethod();
+ void threadPostStopCleanup() {};
void clearServerIPs();
UCHAR irun;
private:
void threadMethod();
+ void threadPostStopCleanup() {};
int fd;
Callback& cb;
struct timespec delayTime;