From 4aed4f1d02ceb13f5c0ce84acecb164c2bbbe679 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 2 Dec 2007 21:46:24 +0000 Subject: [PATCH] Live TV updates --- playerlivetv.cc | 140 ++++++++++++++++++++++++------------------------ playerlivetv.h | 6 ++- 2 files changed, 73 insertions(+), 73 deletions(-) diff --git a/playerlivetv.cc b/playerlivetv.cc index 22a10fb..806a5bd 100644 --- a/playerlivetv.cc +++ b/playerlivetv.cc @@ -202,27 +202,6 @@ void PlayerLiveTV::call(void* caller) threadSignalNoLock(); } } - /* - else if (caller == &vfeed) - { - if (videoStartup2) - { - logger->log("PlayerLiveTV", Log::DEBUG, "Video startup %i", videoStartup2count); - - if (++videoStartup2count == 2) - { - videoStartup2 = false; - - video->unPause(); - audio->unPause(); - - audio->systemMuteOff(); - } - } - - threadSignalNoLock(); - } -*/ } // ----------------------------------- @@ -280,76 +259,82 @@ void PlayerLiveTV::switchState(UCHAR newState) { switch(newState) { - case S_PREBUFFERING: + case S_VIDEOSTARTUP: { video->blank(); + video->reset(); + video->sync(); + video->play(); + video->pause(); + audio->stop(); audio->unPause(); audio->reset(); - audio->setStreamType(Audio::MPEG2_PES); - audio->systemMuteOff(); - video->reset(); + audio->sync(); + audio->play(); + audio->pause(); + demuxer->reset(); demuxer->seek(); + + afeed.start(); + vfeed.start(); + state = newState; return; } + default: + { + logger->log("PlayerLiveTV", Log::EMERG, "Thread called state %u to state %u which is not supported", state, newState); + abort(); + break; + } } } - - case S_PREBUFFERING: // FROM S_PREBUFFERING + + case S_VIDEOSTARTUP: // FROM S_VIDEOSTARTUP { switch(newState) { - case S_STOP: - { - vdr->stopStreaming(); - clearStreamChunks(); - state = newState; - return; - } case S_PREBUFFERING: { - vdr->stopStreaming(); - clearStreamChunks(); + logger->log("PlayerLiveTV", Log::DEBUG, "doing ss to ss2"); + vfeed.release(); state = newState; return; } - case S_VIDEOSTARTUP: + default: { - logger->log("PlayerLiveTV", Log::DEBUG, "doing ss to videostartup"); - - audio->sync(); - audio->play(); - //audio->systemMuteOn(); - video->sync(); - video->pause(); - afeed.start(); - vfeed.start(); - state = newState; - return; - } + logger->log("PlayerLiveTV", Log::EMERG, "Thread called state %u to state %u which is not supported", state, newState); + abort(); + break; + } } } - case S_VIDEOSTARTUP: // FROM S_VIDEOSTARTUP + case S_PREBUFFERING: // FROM S_PREBUFFERING { switch(newState) { case S_PLAY: { - logger->log("PlayerLiveTV", Log::DEBUG, "doing ss to play"); - video->reset(); - video->play(); - video->sync(); - vfeed.release(); + logger->log("PlayerLiveTV", Log::DEBUG, "doing ss2 to ss3"); + audio->unPause(); + video->unPause(); state = newState; return; } + default: + { + logger->log("PlayerLiveTV", Log::EMERG, "Thread called state %u to state %u which is not supported", state, newState); + abort(); + break; + } } } + case S_PLAY: // FROM S_PLAY { switch(newState) @@ -369,7 +354,7 @@ void PlayerLiveTV::switchState(UCHAR newState) state = newState; return; } - case S_PREBUFFERING: + case S_VIDEOSTARTUP: { vdr->stopStreaming(); clearStreamChunks(); @@ -381,20 +366,34 @@ void PlayerLiveTV::switchState(UCHAR newState) audio->unPause(); audio->reset(); - audio->setStreamType(Audio::MPEG2_PES); - // audio->systemMuteOn(); video->reset(); + video->sync(); + video->play(); + video->pause(); + + audio->setStreamType(Audio::MPEG2_PES); + audio->sync(); + audio->play(); + audio->pause(); + demuxer->reset(); demuxer->seek(); + + afeed.start(); + vfeed.start(); + state = newState; return; } + default: + { + logger->log("PlayerLiveTV", Log::EMERG, "Thread called state %u to state %u which is not supported", state, newState); + abort(); + break; + } } } } - - logger->log("PlayerLiveTV", Log::EMERG, "Thread called state %u to state %u which is not supported", state, newState); - abort(); } void PlayerLiveTV::threadMethod() @@ -405,8 +404,9 @@ void PlayerLiveTV::threadMethod() { if (videoStartup) // we are in S_VIDEOSTARTUP, afeed has signalled that it has written some data { - switchState(S_PLAY); + switchState(S_PREBUFFERING); videoStartup = false; + videoStartup2Counter = 0; } while(!instructions.empty()) @@ -421,7 +421,7 @@ void PlayerLiveTV::threadMethod() { logger->log("PlayerLiveTV", Log::DEBUG, "start new stream"); - switchState(S_PREBUFFERING); + switchState(S_VIDEOSTARTUP); Channel* chan = (*chanList)[i.channelIndex]; chan->loadPids(); @@ -443,20 +443,18 @@ void PlayerLiveTV::threadMethod() if (stopNow) break; - if (streamChunks.size()) + while(streamChunks.size()) { + chunkToDemuxer(); + if (state == S_PREBUFFERING) { - if (streamChunks.size() > 9) + logger->log("PlayerLiveTV", Log::DEBUG, "video startup2 buffering..."); + if (++videoStartup2Counter == 3) { - while(streamChunks.size()) chunkToDemuxer(); - switchState(S_VIDEOSTARTUP); + switchState(S_PLAY); } } - else if (state == S_PLAY || state == S_VIDEOSTARTUP) - { - while(streamChunks.size()) chunkToDemuxer(); - } } threadLock(); diff --git a/playerlivetv.h b/playerlivetv.h index ef28aa5..3ee74d8 100644 --- a/playerlivetv.h +++ b/playerlivetv.h @@ -116,14 +116,16 @@ class PlayerLiveTV : public Thread_TYPE, public Callback, public StreamReceiver UCHAR state; const static UCHAR S_STOP = 1; - const static UCHAR S_PREBUFFERING = 2; - const static UCHAR S_VIDEOSTARTUP = 3; + const static UCHAR S_VIDEOSTARTUP = 2; + const static UCHAR S_PREBUFFERING = 3; const static UCHAR S_PLAY = 4; void switchState(UCHAR newState); bool videoStartup; bool stopNow; + int videoStartup2Counter; + void clearStreamChunks(); void chunkToDemuxer(); -- 2.39.5