]> git.vomp.tv Git - vompclient.git/commitdiff
Sync
authorChris Tallon <chris@vomp.tv>
Fri, 5 May 2006 21:46:45 +0000 (21:46 +0000)
committerChris Tallon <chris@vomp.tv>
Fri, 5 May 2006 21:46:45 +0000 (21:46 +0000)
player.cc
player.h

index 29c4f224443b6d6a6c86b97f7a51a8bf9756207d..ecdaf36a3b81eb7d71c36b6d1ebe3500da276246 100644 (file)
--- a/player.cc
+++ b/player.cc
@@ -96,9 +96,7 @@ int Player::shutdown()
   if (!initted) return 0;
   initted = 0;
 
-  logger->log("Player", Log::DEBUG, "Player shutdown...");
-
-  // copy of stop
+ // copy of stop
   if (playing)
   {
     playing = false;
@@ -107,34 +105,16 @@ int Player::shutdown()
     video->blank();
     audio->stop();
     vfeed.stop();
+
     afeed.stop();
     video->reset();
     demuxer.reset();
     feedPosition = 0;
   }
-  logger->log("Player", Log::DEBUG, "Player shutdown done");
 
   return 1;
 }
 
-void Player::resyncAudio()
-{
-  // Temp hopefully
-  if (!initted) return;
-  audio->pause();
-  MILLISLEEP(500);
-  audio->unPause();
-}
-
-void Player::resyncVideo()
-{
-  // Temp hopefully
-  if (!initted) return;
-  video->pause();
-  MILLISLEEP(500);
-  video->unPause();
-}
-
 int Player::play()
 {
   if (!initted) return 0;
@@ -146,6 +126,9 @@ int Player::play()
     return 1;
   }
 
+  // If we are still seeking in from the last jump, ignore
+  if (videoStartup) return 1;
+
   // If we are fast forwarding, set to normal
   if (ffwd)
   {
@@ -160,14 +143,6 @@ int Player::play()
     return 1;
   }
 
-  // If we are already playing, bail // FIXME - resync?
-  if (playing)
-  {
-    logger->log("Player", Log::DEBUG, "DOING RESYNC");
-    resyncVideo();
-    return 1;
-  }
-
   // Standard play start
   logger->log("Player", Log::DEBUG, "Standard play start");
 
@@ -178,19 +153,6 @@ int Player::play()
   demuxer.reset();
   if (!isRadio) demuxer.seek();
 
-// ------------------------ This one works, but doesn't allow any pre-buffering.
-/*
-  videoStartup = true;
-  threadStart();
-  afeed.start();
-  video->sync();
-  audio->sync();
-  audio->play();
-  video->pause();
-*/
-
-// ------------------------ This one doesn't work, but it should, and would allow for prebuffering.
-
   videoStartup = true;
   threadStart();
 
@@ -198,6 +160,7 @@ int Player::play()
   {
     logger->log("Player", Log::DEBUG, "Immediate play");
     afeed.start();
+    vfeed.start();
     video->sync();
     audio->sync();
     audio->play();
@@ -220,7 +183,8 @@ void Player::stop()
   if (!initted) return;
   if (!playing) return;
 
-  logger->log("Player", Log::DEBUG, "Stop called", streamLength);
+  // If we are still seeking in from the last jump, ignore
+  if (videoStartup) return;
 
   if (ffwd || fbwd)
   {
@@ -284,6 +248,9 @@ void Player::setLength(ULLONG length)
 
 void Player::restartAt(ULLONG timecode)
 {
+  // If we are still seeking in from the last jump, ignore
+  if (videoStartup) return;
+
   if (paused) togglePause();
   if (ffwd) toggleFastForward();
 
@@ -303,6 +270,7 @@ void Player::restartAt(ULLONG timecode)
   feedPosition = newPosition;
   videoStartup = true;
   afeed.start();
+  vfeed.start();
   threadStart();
   audio->play();
   video->sync();
@@ -338,6 +306,9 @@ void Player::toggleFastForward()
   if (!initted) return;
   if (!playing) return;
 
+  // If we are still seeking in from the last jump, ignore
+  if (videoStartup) return;
+
   if (paused) togglePause();
   if (fbwd) toggleFastBackward();
 
@@ -357,6 +328,7 @@ void Player::toggleFastForward()
     videoStartup = true;
     afeed.enable();
     afeed.start();
+    vfeed.start();
     threadStart();
     audio->play();
     video->sync();
@@ -379,6 +351,9 @@ void Player::toggleFastBackward()
   if (!initted) return;
   if (!playing) return;
 
+  // If we are still seeking in from the last jump, ignore
+  if (videoStartup) return;
+
   if (paused) togglePause();
   if (ffwd) toggleFastForward();
 
@@ -458,11 +433,10 @@ void Player::call(void* caller)
     if (videoStartup)
     {
       videoStartup = false;
-      logger->log("Player", Log::DEBUG, "Starting VFeed");
       video->reset();
       video->play();
       video->sync();
-      vfeed.start();
+      vfeed.release();
     }
 
     threadSignalNoLock();
@@ -570,6 +544,8 @@ void Player::threadMethod()
         video->sync();
         video->pause();
         afeed.start();
+        vfeed.start();
+        // FIXME - see if this can segfault because it is starting threads out of the master mutex
       }
     }
 
index 3216783ce7d16f0f4ca270a6d72b50310dba0e75..75ff7822bad4ee6b78b23990124303da50f36859 100644 (file)
--- a/player.h
+++ b/player.h
@@ -60,7 +60,6 @@ class Player : public Thread_TYPE, public Callback
     void call(void*); // for callback interface
     void setPosition(ULLONG position);
     void setLength(ULLONG length);
-    void resyncAudio();
     ULLONG getPositionTS();
     ULLONG getEndTS();
 
@@ -77,7 +76,6 @@ class Player : public Thread_TYPE, public Callback
     void threadPostStopCleanup();
 
   private:
-    void resyncVideo();
     void setStartTS(UINT dataInBuffer);
     void setEndTS();
     void doConnectionLost();