From a9636ad0b376383153e709b302b4ad229b87155f Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Tue, 5 Jul 2005 21:25:10 +0000 Subject: [PATCH] The end of a/v sync problems?! Probably not, but I can hope! --- afeed.cc | 7 ++++- player.cc | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++----- video.cc | 2 +- 3 files changed, 85 insertions(+), 9 deletions(-) diff --git a/afeed.cc b/afeed.cc index bfdfe1c..53808ef 100644 --- a/afeed.cc +++ b/afeed.cc @@ -68,6 +68,8 @@ void AFeed::threadMethod() while(1) { + threadCheckExit(); + if (audioEnabled) { alen = Demuxer::getInstance()->writeAudio(fd); // FIXME ? @@ -84,7 +86,10 @@ void AFeed::threadMethod() } else { - Demuxer::getInstance()->flushAudio(); // FIXME, no delay here now + Demuxer::getInstance()->flushAudio(); + usleep(100000); + + // FIXME, no delay here now // if (demux_get_audio(demuxHandle, buffer, 1000) != 1000) nanosleep(&delayTime, NULL); } } diff --git a/player.cc b/player.cc index d77d5aa..e7d7d04 100644 --- a/player.cc +++ b/player.cc @@ -123,6 +123,7 @@ int Player::play() { Log::getInstance()->log("Player", Log::DEBUG, "DOING RESYNC"); +/* vfeed.stop(); afeed.stop(); video->reset(); @@ -138,6 +139,15 @@ int Player::play() video->sync(); audio->sync(); call(); +*/ + + // resync method 2.. + + video->pause(); + usleep(500000); + video->play(); + video->sync(); + return 1; } @@ -153,10 +163,17 @@ int Player::play() threadStart(); vfeed.start(); afeed.start(); - video->play(); audio->play(); + video->play(); video->sync(); audio->sync(); + + video->pause(); + usleep(500000); // SYNC + video->sync(); + video->unPause(); + video->sync(); + // ------------------------ This one doesn't work, but it should, and would allow for prebuffering. /* @@ -237,7 +254,7 @@ void Player::test() { Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST"); - video->test(); +// video->test(); // static int flipflop = 0; @@ -246,6 +263,7 @@ void Player::test() // flipflop = !flipflop; + } void Player::test2() @@ -290,10 +308,16 @@ void Player::skipForward(int seconds) vfeed.start(); afeed.start(); threadStart(); + audio->play(); + video->play(); video->sync(); audio->sync(); - video->play(); - audio->play(); + + video->pause(); + usleep(500000); // SYNC + video->sync(); + video->unPause(); + video->sync(); } @@ -319,10 +343,17 @@ void Player::skipBackward(int seconds) vfeed.start(); afeed.start(); threadStart(); - video->play(); audio->play(); + video->play(); video->sync(); audio->sync(); + + video->pause(); + usleep(500000); // SYNC + video->sync(); + video->unPause(); + video->sync(); + } void Player::toggleFastForward() @@ -336,12 +367,46 @@ void Player::toggleFastForward() if (ffwd) { ffwd = 0; +// video->unFastForward(); + + + threadStop(); + vfeed.stop(); + afeed.stop(); + video->stop(); + audio->stop(); + video->reset(); + audio->reset(); + demuxer.flush(); +// demuxer.seek(); + vfeed.start(); afeed.enable(); - video->unFastForward(); + afeed.start(); + threadStart(); + video->play(); + audio->play(); + video->sync(); + audio->sync(); + + audio->systemMuteOff(); + + video->pause(); + usleep(500000); // SYNC + video->sync(); + video->unPause(); + video->sync(); + +/* + demuxer.flushAudio(); audio->reset(); + afeed.enable(); + //video->reset(); + audio->play(); + video->play(); video->sync(); audio->sync(); audio->systemMuteOff(); +*/ } else { @@ -400,10 +465,16 @@ void Player::jumpToPercent(int percent) vfeed.start(); afeed.start(); threadStart(); - video->play(); audio->play(); + video->play(); video->sync(); audio->sync(); + + video->pause(); + usleep(500000); // SYNC + video->sync(); + video->unPause(); + video->sync(); } diff --git a/video.cc b/video.cc index 608f7b3..53907ad 100644 --- a/video.cc +++ b/video.cc @@ -256,7 +256,7 @@ int Video::pause() return 1; } -int Video::unPause() +int Video::unPause() // FIXME get rid - same as play!! { if (!initted) return 0; if (ioctl(fdVideo, AV_SET_VID_PLAY, 0) != 0) return 0; -- 2.39.5