From 8856fd5fcfde9a92c1fbd17d8b753b1bc6022089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Tue, 14 Jul 2009 21:54:45 +0000 Subject: [PATCH] Have MediaPlayer supports files with unknown duration: * Controller: accept streams with unknown duration. * PlaybackManager: trusts the current frame start and end when frameCount not positive. Also don't stop playing when fStopPlayingFrame is zero. * MediaTrackAudioSupplier: only fills with silent when the frame count is not zero. * added some traces. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31569 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/mediaplayer/Controller.cpp | 4 +--- .../media_node_framework/PlaybackManager.cpp | 11 ++++++----- .../media_node_framework/video/VideoConsumer.cpp | 3 ++- .../mediaplayer/supplier/MediaTrackAudioSupplier.cpp | 5 +++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/apps/mediaplayer/Controller.cpp b/src/apps/mediaplayer/Controller.cpp index a663b19d39..78e3bc6774 100644 --- a/src/apps/mediaplayer/Controller.cpp +++ b/src/apps/mediaplayer/Controller.cpp @@ -255,9 +255,7 @@ Controller::SetTo(const PlaylistItemRef& item) } if (t->Duration() <= 0) { - printf("Controller::SetTo: track index %d has no duration\n",i); - mf->ReleaseTrack(t); - continue; + printf("Controller::SetTo: warning! track index %d has no duration\n", i); } if (f.IsAudio()) { diff --git a/src/apps/mediaplayer/media_node_framework/PlaybackManager.cpp b/src/apps/mediaplayer/media_node_framework/PlaybackManager.cpp index a3ba605965..56ac8f65d2 100644 --- a/src/apps/mediaplayer/media_node_framework/PlaybackManager.cpp +++ b/src/apps/mediaplayer/media_node_framework/PlaybackManager.cpp @@ -224,6 +224,7 @@ PlaybackManager::MessageReceived(BMessage* message) void PlaybackManager::StartPlaying(bool atBeginning) { + TRACE("PlaybackManager::StartPlaying()\n"); int32 playMode = PlayMode(); if (playMode == MODE_PLAYING_PAUSED_FORWARD) SetPlayMode(MODE_PLAYING_FORWARD, !atBeginning); @@ -235,6 +236,7 @@ PlaybackManager::StartPlaying(bool atBeginning) void PlaybackManager::StopPlaying() { + TRACE("PlaybackManager::StopPlaying()\n"); int32 playMode = PlayMode(); if (playMode == MODE_PLAYING_FORWARD) SetPlayMode(MODE_PLAYING_PAUSED_FORWARD, true); @@ -729,7 +731,7 @@ PlaybackManager::GetPlaylistTimeInterval(bigtime_t startTime, bigtime_t endTimeForFrame = TimeForFrame(endFrame); endTime = min(endTime, endTimeForFrame); bigtime_t intervalLength = endTime - startTime; - + // Finally determine the time bounds for the Playlist interval (depending // on the playing direction). switch (playingDirection) { @@ -1418,10 +1420,9 @@ TRACE("PlaybackManager::_FrameForRangeFrame(%lld)\n", index); TRACE(" frame range: %lld - %lld, count: %lld\n", startFrame, endFrame, frameCount); // map the index into the index interval of the playing range - if (frameCount > 0) + if (frameCount > 1) index = (index % frameCount + frameCount) % frameCount; - else - index = 0; + // get the frame for the index int32 frame = startFrame; switch (state->loop_mode) { @@ -1576,7 +1577,7 @@ void PlaybackManager::_CheckStopPlaying() { //printf("_CheckStopPlaying() - %lld, next: %lld\n", fStopPlayingFrame, NextFrame()); - if (fStopPlayingFrame >= 0 && fStopPlayingFrame <= NextFrame()) { + if (fStopPlayingFrame > 0 && fStopPlayingFrame <= NextFrame()) { StopPlaying(); NotifyStopFrameReached(); } diff --git a/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.cpp b/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.cpp index 67c8764e9e..167d70e04f 100644 --- a/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.cpp +++ b/src/apps/mediaplayer/media_node_framework/video/VideoConsumer.cpp @@ -212,7 +212,8 @@ VideoConsumer::CreateBuffers(const media_format& format) uint32 width = format.u.raw_video.display.line_width; uint32 height = format.u.raw_video.display.line_count; color_space colorSpace = format.u.raw_video.display.format; - PROGRESS("VideoConsumer::CreateBuffers - Colorspace = %d\n", colorSpace); + PROGRESS("VideoConsumer::CreateBuffers - Width = %ld - Height = %ld - " + "Colorspace = %d\n", width, height, colorSpace); fBuffers = new BBufferGroup(); status = fBuffers->InitCheck(); diff --git a/src/apps/mediaplayer/supplier/MediaTrackAudioSupplier.cpp b/src/apps/mediaplayer/supplier/MediaTrackAudioSupplier.cpp index e791db799f..cbcbe3f85e 100644 --- a/src/apps/mediaplayer/supplier/MediaTrackAudioSupplier.cpp +++ b/src/apps/mediaplayer/supplier/MediaTrackAudioSupplier.cpp @@ -127,14 +127,14 @@ MediaTrackAudioSupplier::Read(void* buffer, int64 pos, int64 frames) status_t error = InitCheck(); if (error != B_OK) { - TRACE("Read() done\n"); + TRACE("Read() InitCheck failed\n"); return error; } // convert pos according to our offset pos += fOutOffset; // Fill the frames after the end of the track with silence. - if (pos + frames > fCountFrames) { + if (fCountFrames > 0 && pos + frames > fCountFrames) { int64 size = max(0LL, fCountFrames - pos); ReadSilence(SkipFrames(buffer, size), frames - size); frames = size; @@ -528,6 +528,7 @@ status_t MediaTrackAudioSupplier::_ReadUncachedFrames(void* buffer, int64 position, int64 frames, bigtime_t time) { + TRACE("_ReadUncachedFrames()\n"); status_t error = B_OK; // seek to the position int64 currentPos = position;