cache the track duration

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17483 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Marcus Overhagen
2006-05-16 19:07:53 +00:00
parent afc66bbbc3
commit d38c8112a7
2 changed files with 12 additions and 4 deletions
+11 -4
View File
@@ -66,6 +66,7 @@ Controller::Controller()
, fSeekAudio(false) , fSeekAudio(false)
, fSeekVideo(false) , fSeekVideo(false)
, fSeekPosition(0) , fSeekPosition(0)
, fDuration(0)
{ {
} }
@@ -119,6 +120,7 @@ Controller::SetTo(const entry_ref &ref)
fPosition = 0; fPosition = 0;
fPaused = false; fPaused = false;
fStopped = true; fStopped = true;
fDuration = 0;
fName = ref.name; fName = ref.name;
status_t err; status_t err;
@@ -208,6 +210,10 @@ Controller::SelectAudioTrack(int n)
return B_ERROR; return B_ERROR;
fAudioTrack = t; fAudioTrack = t;
bigtime_t a = fAudioTrack ? fAudioTrack->Duration() : 0;
bigtime_t v = fVideoTrack ? fVideoTrack->Duration() : 0;
fDuration = max_c(a, v);
StartAudioPlayback(); StartAudioPlayback();
return B_OK; return B_OK;
} }
@@ -223,6 +229,10 @@ Controller::SelectVideoTrack(int n)
return B_ERROR; return B_ERROR;
fVideoTrack = t; fVideoTrack = t;
bigtime_t a = fAudioTrack ? fAudioTrack->Duration() : 0;
bigtime_t v = fVideoTrack ? fVideoTrack->Duration() : 0;
fDuration = max_c(a, v);
StartVideoPlayback(); StartVideoPlayback();
return B_OK; return B_OK;
} }
@@ -231,10 +241,7 @@ Controller::SelectVideoTrack(int n)
bigtime_t bigtime_t
Controller::Duration() Controller::Duration()
{ {
bigtime_t a = fAudioTrack ? fAudioTrack->Duration() : 0; return fDuration;
bigtime_t v = fVideoTrack ? fVideoTrack->Duration() : 0;
// printf("Controller::Duration: audio %.6f, video %.6f\n", a / 1000000.0, v / 1000000.0);
return max_c(a, v);
} }
+1
View File
@@ -110,6 +110,7 @@ private:
volatile bool fSeekAudio; volatile bool fSeekAudio;
volatile bool fSeekVideo; volatile bool fSeekVideo;
volatile bigtime_t fSeekPosition; volatile bigtime_t fSeekPosition;
bigtime_t fDuration;
}; };