From 9980d4358e76551dab945e1e6235338da903e367 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Thu, 21 Sep 2006 21:11:01 +0000 Subject: [PATCH] Seperate the two pause types into their own states --- player.cc | 133 ++++++++++++++++++++++++++++++++++++++++----------- player.h | 100 +++++++++++++++++++++----------------- vvideorec.cc | 9 ++-- 3 files changed, 165 insertions(+), 77 deletions(-) diff --git a/player.cc b/player.cc index 6dfb7da..adb1063 100644 --- a/player.cc +++ b/player.cc @@ -144,7 +144,7 @@ void Player::play() if (state == S_PLAY) return; lock(); bool doUnlock = false; - if (state == S_PAUSE) doUnlock = true; + if (state == S_PAUSE_P) doUnlock = true; switchState(S_PLAY); if (doUnlock) unLock(); } @@ -163,8 +163,20 @@ void Player::togglePause() { if (!initted) return; lock(); - if (state == S_PAUSE) switchState(S_PLAY); - else switchState(S_PAUSE); + + if ((state == S_FFWD) || (state == S_FBWD)) + { + switchState(S_PAUSE_I); + } + else if ((state == S_PAUSE_I) || (state == S_PAUSE_P)) + { + switchState(S_PLAY); + } + else + { + switchState(S_PAUSE_P); + } + unLock(); } @@ -233,11 +245,16 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame) { return; } - case S_PAUSE: // to S_PAUSE + case S_PAUSE_P: // to S_PAUSE_P { video->pause(); audio->pause(); - state = S_PAUSE; + state = S_PAUSE_P; + return; + } + case S_PAUSE_I: // to S_PAUSE_I + { + // can't occur return; } case S_FFWD: // to S_FFWD @@ -285,27 +302,22 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame) } } } - case S_PAUSE: // from S_PAUSE ----------------------------------- + case S_PAUSE_P: // from S_PAUSE_P ----------------------------------- { switch(toState) { case S_PLAY: // to S_PLAY { - if (threadIsActive()) - { - video->unPause(); - audio->unPause(); - state = S_PLAY; - } - else - { - state = S_PLAY; - restartAtFrame(currentFrameNumber); - } - + video->unPause(); + audio->unPause(); + state = S_PLAY; + return; + } + case S_PAUSE_P: // to S_PAUSE_P + { return; } - case S_PAUSE: // to S_PAUSE + case S_PAUSE_I: // to S_PAUSE_I { return; } @@ -315,7 +327,7 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame) audio->systemMuteOn(); vfeed.stop(); afeed.stop(); - if (threadIsActive()) threadStop(); + threadStop(); video->unPause(); audio->unPause(); state = S_FFWD; @@ -328,7 +340,7 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame) audio->systemMuteOn(); vfeed.stop(); afeed.stop(); - if (threadIsActive()) threadStop(); + threadStop(); video->unPause(); audio->unPause(); state = S_FBWD; @@ -339,7 +351,7 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame) { vfeed.stop(); afeed.stop(); - if (threadIsActive()) threadStop(); + threadStop(); video->stop(); video->blank(); audio->stop(); @@ -347,7 +359,7 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame) audio->unPause(); demuxer->reset(); audio->systemMuteOff(); - state = S_FFWD; + state = S_STOP; return; } case S_JUMP: // to S_JUMP @@ -359,6 +371,55 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame) } } } + case S_PAUSE_I: // from S_PAUSE_I ----------------------------------- + { + switch(toState) + { + case S_PLAY: // to S_PLAY + { + state = S_PLAY; + restartAtFrame(currentFrameNumber); + return; + } + case S_PAUSE_P: // to S_PAUSE_P + { + return; + } + case S_PAUSE_I: // to S_PAUSE_I + { + return; + } + case S_FFWD: // to S_FFWD + { + state = S_FFWD; + threadStart(); + return; + } + case S_FBWD: // to S_FBWD + { + state = S_FBWD; + threadStart(); + return; + } + case S_STOP: // to S_STOP + { + video->stop(); + video->blank(); + audio->stop(); + video->reset(); + demuxer->reset(); + audio->systemMuteOff(); + state = S_STOP; + return; + } + case S_JUMP: // to S_JUMP + { + state = S_PLAY; + restartAtFrame(jumpFrame); + return; + } + } + } case S_FFWD: // from S_FFWD ----------------------------------- { switch(toState) @@ -369,10 +430,15 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame) restartAtFrame(currentFrameNumber); return; } - case S_PAUSE: // to S_PAUSE + case S_PAUSE_P: // to S_PAUSE_P + { + // can't occur + return; + } + case S_PAUSE_I: // to S_PAUSE_I { threadStop(); - state = S_PAUSE; + state = S_PAUSE_I; return; } case S_FFWD: // to S_FFWD @@ -415,10 +481,15 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame) restartAtFrame(currentFrameNumber); return; } - case S_PAUSE: // to S_PAUSE + case S_PAUSE_P: // to S_PAUSE_P + { + // can't occur + return; + } + case S_PAUSE_I: // to S_PAUSE_I { threadStop(); - state = S_PAUSE; + state = S_PAUSE_I; return; } case S_FFWD: // to S_FFWD @@ -492,7 +563,11 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame) } return; } - case S_PAUSE: // to S_PAUSE + case S_PAUSE_P: // to S_PAUSE_P + { + return; + } + case S_PAUSE_I: // to S_PAUSE_I { return; } @@ -527,7 +602,7 @@ void Player::lock() logger->log("Player", Log::DEBUG, "LOCKED"); #else - WaitForSingleObject(mutex, INFINITE ); + WaitForSingleObject(mutex, INFINITE); #endif } diff --git a/player.h b/player.h index c8a1ed0..9203926 100644 --- a/player.h +++ b/player.h @@ -68,11 +68,12 @@ class Player : public Thread_TYPE, public Callback void call(void*); // for callback interface const static UCHAR S_PLAY = 1; - const static UCHAR S_PAUSE = 2; - const static UCHAR S_FFWD = 3; - const static UCHAR S_FBWD = 4; - const static UCHAR S_STOP = 5; - const static UCHAR S_JUMP = 6; + const static UCHAR S_PAUSE_P = 2; + const static UCHAR S_PAUSE_I = 3; + const static UCHAR S_FFWD = 4; + const static UCHAR S_FBWD = 5; + const static UCHAR S_STOP = 6; + const static UCHAR S_JUMP = 7; #ifdef DEV void test1(); @@ -136,44 +137,55 @@ Possible states: Play, Pause, FFwd, FBwd, (Stop), [Jump] - Possible Working - -Play -> Pause * * - -> FFwd * * - -> FBwd * * - -> Stop * * - -> Jump * * - - From prev.play / prev.fast - -Pause -> Play * * * - -> FFwd * * * - -> FBwd * * * - -> Stop * * * - -> Jump * * * - -FFwd -> Play * * - -> Pause * * - -> FBwd * * - -> Stop * * - -> Jump * * - -FBwd -> Play * * - -> Pause * * - -> FFwd * * - -> Stop * * - -> Jump * * - -Stop -> Play * * - -> Pause - -> FFwd - -> FBwd - -> Jump - -Jump -> Play - -> Pause - -> FFwd - -> FBwd - -> Stop + Possible Working + +Play -> PauseP * * + -> PauseI + -> FFwd * * + -> FBwd * * + -> Stop * * + -> Jump * * + +PauseP -> Play * * + -> PauseI + -> FFwd * * + -> FBwd * * + -> Stop * * + -> Jump * * + +PauseI -> Play * * + -> PauseP + -> FFwd * * + -> FBwd * * + -> Stop * * + -> Jump * * + +FFwd -> Play * * + -> PauseP + -> PauseI * * + -> FBwd * * + -> Stop * * + -> Jump * * + +FBwd -> Play * * + -> PauseP + -> PauseI * * + -> FFwd * * + -> Stop * * + -> Jump * * + +Stop -> Play * * + -> PauseP + -> PauseI + -> FFwd + -> FBwd + -> Jump + +Jump -> Play + -> PauseP + -> PauseI + -> FFwd + -> FBwd + -> Stop */ diff --git a/vvideorec.cc b/vvideorec.cc index 2b86724..873e9b7 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -342,10 +342,11 @@ void VVideoRec::doBar(int action) else { UCHAR playerState = player->getState(); - if (playerState == Player::S_PAUSE) w.nextSymbol = WSymbol::PAUSE; - else if (playerState == Player::S_FFWD) w.nextSymbol = WSymbol::FFWD; - else if (playerState == Player::S_FBWD) w.nextSymbol = WSymbol::FBWD; - else w.nextSymbol = WSymbol::PLAY; + if (playerState == Player::S_PAUSE_P) w.nextSymbol = WSymbol::PAUSE; + else if (playerState == Player::S_PAUSE_I) w.nextSymbol = WSymbol::PAUSE; + else if (playerState == Player::S_FFWD) w.nextSymbol = WSymbol::FFWD; + else if (playerState == Player::S_FBWD) w.nextSymbol = WSymbol::FBWD; + else w.nextSymbol = WSymbol::PLAY; } w.draw(); -- 2.39.5