]> git.vomp.tv Git - vompclient.git/commitdiff
Prebuffering
authorChris Tallon <chris@vomp.tv>
Sat, 29 Apr 2006 14:52:31 +0000 (14:52 +0000)
committerChris Tallon <chris@vomp.tv>
Sat, 29 Apr 2006 14:52:31 +0000 (14:52 +0000)
player.cc
player.h

index 5c022cfd926a1d13c5f1a67fd5b9d3ef6543e891..ed5d1664f52ce5d8f382df5986aa9989fcc774a8 100644 (file)
--- a/player.cc
+++ b/player.cc
@@ -39,8 +39,8 @@ Player::Player(MessageQueue* messageQueue, bool tIsRecording, bool tIsRadio)
   startTS = 0;
   endTS = 0;
 
-  startup = true;
   videoStartup = false;
+  preBuffering = false;
   isRecording = tIsRecording;
   isRadio = tIsRadio;
 
@@ -171,11 +171,15 @@ int Player::play()
   // Standard play start
   logger->log("Player", Log::DEBUG, "Standard play start");
 
+  startup = true;
+
   audio->reset();
   video->reset();
   demuxer.reset();
+  if (!isRadio) demuxer.seek();
 
 // ------------------------ This one works, but doesn't allow any pre-buffering.
+/*
   videoStartup = true;
   threadStart();
   afeed.start();
@@ -183,10 +187,27 @@ int Player::play()
   audio->sync();
   audio->play();
   video->pause();
-
+*/
 
 // ------------------------ This one doesn't work, but it should, and would allow for prebuffering.
 
+  videoStartup = true;
+  threadStart();
+
+  if (isRecording)
+  {
+    logger->log("Player", Log::DEBUG, "Immediate play");
+    afeed.start();
+    video->sync();
+    audio->sync();
+    audio->play();
+    video->pause();
+  }
+  else // do prebuffering
+  {
+    logger->log("Player", Log::DEBUG, "Prebuffering...");
+    preBuffering = true;
+  }
 
 // ------------------------------------------------------------------------------------------------
 
@@ -462,6 +483,7 @@ void Player::threadMethod()
   UINT thisRead;
   UINT writeLength;
   UINT thisWrite;
+  UINT preBufferTotal;
 
   VDR* vdr = VDR::getInstance();
 
@@ -533,6 +555,24 @@ void Player::threadMethod()
       startup = false;
     }
 
+    if (preBuffering)
+    {
+      preBufferTotal += thisRead;
+      if (preBufferTotal > 500000)
+      {
+        logger->log("Player", Log::DEBUG, "Got >500K, prebuffering complete");
+
+        preBuffering = false;
+        preBufferTotal = 0;
+
+        afeed.start();
+        video->sync();
+        audio->sync();
+        audio->play();
+        video->pause();
+      }
+    }
+
     if (feedMode == MODE_NORMAL)
     {
       feedPosition += thisRead;
@@ -591,14 +631,11 @@ void Player::threadMethod()
 
 void Player::threadPostStopCleanup()
 {
-  logger->log("Player", Log::DEBUG, "Post stop cleanup 1");
   if (threadBuffer)
   {
-    logger->log("Player", Log::DEBUG, "Post stop cleanup 2");
     free(threadBuffer);
     threadBuffer = NULL;
   }
-  logger->log("Player", Log::DEBUG, "Post stop cleanup 3");
 }
 
 void Player::setStartTS(UINT dataInBuffer)
index d48bc121cb2b110c89bd5e7709a2774539ed0b91..3216783ce7d16f0f4ca270a6d72b50310dba0e75 100644 (file)
--- a/player.h
+++ b/player.h
@@ -96,6 +96,7 @@ class Player : public Thread_TYPE, public Callback
     bool videoStartup;
     bool isRecording;
     bool isRadio;
+    bool preBuffering;
 
     ULLONG startTS;
     ULLONG endTS;