/*
- Copyright 2004-2006 Chris Tallon
+ Copyright 2004-2020 Chris Tallon
This file is part of VOMP.
#include "vdr.h"
#include "message.h"
#include "messagequeue.h"
+#include "buffer.h"
#include "playerradiorec.h"
logger->log("PlayerRadioRec", Log::DEBUG, "startFeedPlay: wantedFrame %i goto %llu", currentFrameNumber, feedPosition);
+ Buffer threadBuffer;
+
while(1)
{
thisRead = 0;
askFor = blockSize;
}
- threadBuffer = vdr->getBlock(feedPosition, askFor, &thisRead);
+ threadBuffer.set(vdr->getBlock(feedPosition, askFor, &thisRead));
feedPosition += thisRead;
if (!vdr->isConnected())
return;
}
- if (!threadBuffer) break;
+ if (threadBuffer.isNull()) break;
if (startup)
{
- int a_stream = demuxer->scan(threadBuffer, thisRead);
+ int a_stream = demuxer->scan(threadBuffer.ucharp(), thisRead);
demuxer->setAudioStream(a_stream);
logger->log("PlayerRadioRec", Log::DEBUG, "Startup Audio stream chosen %x", a_stream);
startup = false;
while(writeLength < thisRead)
{
- thisWrite = demuxer->put(threadBuffer + writeLength, thisRead - writeLength);
+ thisWrite = demuxer->put(threadBuffer.ucharp() + writeLength, thisRead - writeLength);
writeLength += thisWrite;
if (!thisWrite)
threadCheckExit();
}
- free(threadBuffer);
- threadBuffer = NULL;
-
+ threadBuffer.release();
}
// end of recording
messageQueue->postMessage(m);
}
-void PlayerRadioRec::threadPostStopCleanup()
-{
- if (threadBuffer)
- {
- free(threadBuffer);
- threadBuffer = NULL;
- }
-}
-
protected:
void threadMethod();
- void threadPostStopCleanup();
private:
void switchState(UCHAR newState, ULONG jumpToFrame=0);
ULONG currentFrameNumber{};
static const UINT blockSize{10000};
static const UINT startupBlockSize{20000};
- UCHAR* threadBuffer{};
UCHAR state{S_STOP};
};