]> git.vomp.tv Git - vompclient.git/commitdiff
Remove Thread::PostStopCleanup from PlayerRadioRec
authorChris Tallon <chris@vomp.tv>
Tue, 3 Mar 2020 22:24:05 +0000 (22:24 +0000)
committerChris Tallon <chris@vomp.tv>
Tue, 3 Mar 2020 22:24:05 +0000 (22:24 +0000)
playerradiorec.cc
playerradiorec.h

index 0fdf0ad8de9171b322307b572d4c2ffe66b80eed..5ecd8cda3791f2efe800da41d54d88218b7eaa6e 100644 (file)
@@ -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;
-  }
-}
-
index 56a9fc902d3d41f65b58ffc347e8e63a5a1c9fc9..0c498a9fe3da47b6442c3e552772732017db41e5 100644 (file)
@@ -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};
 };