From d455601cef7f2aa85047804aa2e6032e4797e29e Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Fri, 5 May 2006 21:46:45 +0000 Subject: [PATCH] Sync --- player.cc | 68 ++++++++++++++++++------------------------------------- player.h | 2 -- 2 files changed, 22 insertions(+), 48 deletions(-) diff --git a/player.cc b/player.cc index 29c4f22..ecdaf36 100644 --- 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 } } diff --git a/player.h b/player.h index 3216783..75ff782 100644 --- 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(); -- 2.39.2