From 84b6bd9a95710ecff1d658e16078b6c3e57f7782 Mon Sep 17 00:00:00 2001 From: David McPaul Date: Thu, 14 Aug 2008 23:09:14 +0000 Subject: [PATCH] Correct display of Duration git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26976 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/mediaplayer/Controller.cpp | 10 +++++++++- src/apps/mediaplayer/InfoWin.cpp | 2 +- .../media_node_framework/video/VideoProducer.cpp | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/apps/mediaplayer/Controller.cpp b/src/apps/mediaplayer/Controller.cpp index e3960a6cc6..3ab9f15046 100644 --- a/src/apps/mediaplayer/Controller.cpp +++ b/src/apps/mediaplayer/Controller.cpp @@ -126,6 +126,7 @@ Controller::~Controller() int64 Controller::Duration() { + // This should really be total frames (video frames at that) // TODO: It is not so nice that the MediaPlayer still measures // in video frames if only playing audio. Here for example, it will // return a duration of 0 if the audio clip happens to be shorter than @@ -221,12 +222,19 @@ Controller::SetTo(const entry_ref &ref) BMediaTrack* t = mf->TrackAt(i); media_format f; err = t->EncodedFormat(&f); - if (err != B_OK || t->Duration() <= 0) { + if (err != B_OK) { printf("Controller::SetTo: EncodedFormat failed for track index %d, error 0x%08lx (%s)\n", i, err, strerror(err)); mf->ReleaseTrack(t); continue; } + + if (t->Duration() <= 0) { + printf("Controller::SetTo: track index %d has no duration\n",i); + mf->ReleaseTrack(t); + continue; + } + if (f.IsAudio()) { if (!fAudioTrackList.AddItem(t)) return B_NO_MEMORY; diff --git a/src/apps/mediaplayer/InfoWin.cpp b/src/apps/mediaplayer/InfoWin.cpp index 712c0edb23..401e5b7844 100644 --- a/src/apps/mediaplayer/InfoWin.cpp +++ b/src/apps/mediaplayer/InfoWin.cpp @@ -321,7 +321,7 @@ printf("InfoWin::Update(0x%08lx)\n", which); if ((which & INFO_STATS) && fController->HasFile()) { fLabelsView->Insert("Duration\n"); BString s; - bigtime_t d = fController->Duration(); + bigtime_t d = fController->TimeDuration(); bigtime_t v; //s << d << "µs; "; diff --git a/src/apps/mediaplayer/media_node_framework/video/VideoProducer.cpp b/src/apps/mediaplayer/media_node_framework/video/VideoProducer.cpp index 96783ab517..d1b9ae12e3 100644 --- a/src/apps/mediaplayer/media_node_framework/video/VideoProducer.cpp +++ b/src/apps/mediaplayer/media_node_framework/video/VideoProducer.cpp @@ -715,7 +715,7 @@ VideoProducer::_FrameGeneratorThread() "Terminating video producer frame generator thread.\n"); TRACE("_FrameGeneratorThread: frame generator thread done.\n"); // do not access any member variables, since this could - // also me the Node has been deleted + // also mean the Node has been deleted return B_OK; } @@ -739,7 +739,7 @@ VideoProducer::_FrameGeneratorThread() // nothing to do } else if (nextWaitUntil < system_time()) { // Drop frame if it's at least a frame late. - //printf("VideoProducer: dropped frame (%ld)\n", fFrame); + printf("VideoProducer: dropped frame (%Ld)\n", fFrame); if (fManager->LockWithTimeout(10000) == B_OK) { fManager->FrameDropped(); fManager->Unlock();