From 757d0fef9a48c02c377b13d064ee459b03f6e3a5 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Tue, 3 Mar 2020 22:24:05 +0000 Subject: [PATCH] Remove Thread::PostStopCleanup from PlayerRadioRec --- playerradiorec.cc | 26 +++++++++----------------- playerradiorec.h | 2 -- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/playerradiorec.cc b/playerradiorec.cc index 0fdf0ad..5ecd8cd 100644 --- a/playerradiorec.cc +++ b/playerradiorec.cc @@ -1,5 +1,5 @@ /* - Copyright 2004-2006 Chris Tallon + Copyright 2004-2020 Chris Tallon This file is part of VOMP. @@ -26,6 +26,7 @@ #include "vdr.h" #include "message.h" #include "messagequeue.h" +#include "buffer.h" #include "playerradiorec.h" @@ -440,6 +441,8 @@ void PlayerRadioRec::threadFeedPlay() logger->log("PlayerRadioRec", Log::DEBUG, "startFeedPlay: wantedFrame %i goto %llu", currentFrameNumber, feedPosition); + Buffer threadBuffer; + while(1) { thisRead = 0; @@ -480,7 +483,7 @@ void PlayerRadioRec::threadFeedPlay() askFor = blockSize; } - threadBuffer = vdr->getBlock(feedPosition, askFor, &thisRead); + threadBuffer.set(vdr->getBlock(feedPosition, askFor, &thisRead)); feedPosition += thisRead; if (!vdr->isConnected()) @@ -489,11 +492,11 @@ void PlayerRadioRec::threadFeedPlay() 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; @@ -503,7 +506,7 @@ void PlayerRadioRec::threadFeedPlay() while(writeLength < thisRead) { - thisWrite = demuxer->put(threadBuffer + writeLength, thisRead - writeLength); + thisWrite = demuxer->put(threadBuffer.ucharp() + writeLength, thisRead - writeLength); writeLength += thisWrite; if (!thisWrite) @@ -517,9 +520,7 @@ void PlayerRadioRec::threadFeedPlay() threadCheckExit(); } - free(threadBuffer); - threadBuffer = NULL; - + threadBuffer.release(); } // end of recording @@ -537,12 +538,3 @@ void PlayerRadioRec::threadFeedPlay() messageQueue->postMessage(m); } -void PlayerRadioRec::threadPostStopCleanup() -{ - if (threadBuffer) - { - free(threadBuffer); - threadBuffer = NULL; - } -} - diff --git a/playerradiorec.h b/playerradiorec.h index 56a9fc9..0c498a9 100644 --- a/playerradiorec.h +++ b/playerradiorec.h @@ -88,7 +88,6 @@ class PlayerRadioRec : public Thread_TYPE, public Callback protected: void threadMethod(); - void threadPostStopCleanup(); private: void switchState(UCHAR newState, ULONG jumpToFrame=0); @@ -121,7 +120,6 @@ class PlayerRadioRec : public Thread_TYPE, public Callback ULONG currentFrameNumber{}; static const UINT blockSize{10000}; static const UINT startupBlockSize{20000}; - UCHAR* threadBuffer{}; UCHAR state{S_STOP}; }; -- 2.39.5