From: Chris Tallon Date: Sat, 29 Apr 2006 14:52:31 +0000 (+0000) Subject: Prebuffering X-Git-Tag: r0-2-2b~25 X-Git-Url: https://git.vomp.tv/gitweb/?a=commitdiff_plain;h=3f81879f59d54d0abad46fdaa9834f1b6ca90a66;p=vompclient.git Prebuffering --- diff --git a/player.cc b/player.cc index 5c022cf..ed5d166 100644 --- 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) diff --git a/player.h b/player.h index d48bc12..3216783 100644 --- 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;