From 8f0617aa0d39878dfbf872416eaab95cdcfa1742 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Fri, 10 Sep 2010 14:40:04 +0000 Subject: [PATCH] Fixed winding for video. We need to distingish between requested seek-frame and snapped-to-keyframe seek-frame. Not comletely perfect, since sometimes video snaps back to the same keyframe two or more times, but winding works anyway. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38600 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/mediaplayer/Controller.cpp | 20 ++++++++++++++------ src/apps/mediaplayer/Controller.h | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/apps/mediaplayer/Controller.cpp b/src/apps/mediaplayer/Controller.cpp index 2f75ee111b..c372c5fca4 100644 --- a/src/apps/mediaplayer/Controller.cpp +++ b/src/apps/mediaplayer/Controller.cpp @@ -115,6 +115,7 @@ Controller::Controller() fPendingSeekRequests(0), fSeekFrame(-1), + fRequestedSeekFrame(-1), fGlobalSettingsListener(this), @@ -262,6 +263,7 @@ Controller::SetTo(const PlaylistItemRef& item) fPendingSeekRequests = 0; fSeekFrame = -1; + fRequestedSeekFrame = -1; if (fItem.Get() == NULL) return B_BAD_VALUE; @@ -717,10 +719,14 @@ Controller::SetFramePosition(int64 value) BAutolock _(this); fPendingSeekRequests++; - fSeekFrame = max_c(0, min_c(_FrameDuration(), value)); + fRequestedSeekFrame = max_c(0, min_c(_FrameDuration(), value)); + fSeekFrame = fRequestedSeekFrame; - // Snap to video keyframe, since that will be the fastest - // to display and seeking will feel more snappy. + // Snap to a video keyframe, since that will be the fastest + // to display and seeking will feel more snappy. Note that we + // don't store this change in fSeekFrame, since we still want + // to report the originally requested seek frame in TimePosition() + // until we could reach that frame. if (Duration() > 240 && fVideoTrackSupplier != NULL) fVideoTrackSupplier->FindKeyFrameForFrame(&fSeekFrame); @@ -735,7 +741,7 @@ Controller::SetFramePosition(int64 value) // if next current frame == seek frame. return seekFrame; } else - NotifySeekHandled(fSeekFrame); + NotifySeekHandled(fRequestedSeekFrame); return currentFrame; } @@ -940,7 +946,7 @@ Controller::_TimePosition() const // frames asynchronously. int64 frame; if (fPendingSeekRequests > 0) - frame = fSeekFrame; + frame = fRequestedSeekFrame; else frame = fCurrentFrame; @@ -1166,8 +1172,10 @@ Controller::NotifySeekHandled(int64 seekedFrame) const return; fPendingSeekRequests--; - if (fPendingSeekRequests == 0) + if (fPendingSeekRequests == 0) { fSeekFrame = -1; + fRequestedSeekFrame = -1; + } _NotifySeekHandled(seekedFrame); } diff --git a/src/apps/mediaplayer/Controller.h b/src/apps/mediaplayer/Controller.h index 0292d8561b..5e93c2f77a 100644 --- a/src/apps/mediaplayer/Controller.h +++ b/src/apps/mediaplayer/Controller.h @@ -202,6 +202,7 @@ private: mutable int32 fPendingSeekRequests; mutable int64 fSeekFrame; + mutable int64 fRequestedSeekFrame; ListenerAdapter fGlobalSettingsListener;