From 892e4f21be74818d65a85f3ee76b07b51e814d46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Thu, 16 Sep 2010 12:43:41 +0000 Subject: [PATCH] * Changed the VideoSupplier interface to allow forcing the video generation. This allows step back frame-wise even though it means the video has to seeked back far and re-generated more than five frames ahead to reach the seek frame. * Don't print dropped frames in the producer when the video is paused. * Don't lock the PlaybackManager to report dropped frames, report it later when the manager had to be locked anyway. * Removed a whole bunch of methods that were only implemened because of that old BeOS PPC compiler bug. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38670 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../video/VideoProducer.cpp | 78 +++---------------- .../video/VideoProducer.h | 10 --- .../video/VideoSupplier.h | 2 +- .../supplier/ProxyVideoSupplier.cpp | 5 +- .../mediaplayer/supplier/ProxyVideoSupplier.h | 2 +- 5 files changed, 15 insertions(+), 82 deletions(-) diff --git a/src/apps/mediaplayer/media_node_framework/video/VideoProducer.cpp b/src/apps/mediaplayer/media_node_framework/video/VideoProducer.cpp index bbea398924..badd21bef1 100644 --- a/src/apps/mediaplayer/media_node_framework/video/VideoProducer.cpp +++ b/src/apps/mediaplayer/media_node_framework/video/VideoProducer.cpp @@ -80,13 +80,6 @@ VideoProducer::~VideoProducer() } -port_id -VideoProducer::ControlPort() const -{ - return BMediaNode::ControlPort(); -} - - BMediaAddOn* VideoProducer::AddOn(int32* _internalId) const { @@ -111,13 +104,6 @@ VideoProducer::SetTimeSource(BTimeSource* timeSource) } -status_t -VideoProducer::RequestCompleted(const media_request_info& info) -{ - return BMediaNode::RequestCompleted(info); -} - - void VideoProducer::NodeRegistered() { @@ -173,29 +159,6 @@ VideoProducer::Seek(bigtime_t media_time, bigtime_t performanceTime) } -void -VideoProducer::TimeWarp(bigtime_t at_real_time, bigtime_t to_performance_time) -{ - BMediaEventLooper::TimeWarp(at_real_time, to_performance_time); -} - - -status_t -VideoProducer::AddTimer(bigtime_t at_performance_time, int32 cookie) -{ - return BMediaEventLooper::AddTimer(at_performance_time, cookie); -} - - -void -VideoProducer::SetRunMode(run_mode mode) -{ -printf("VideoProducer::SetRunMode(%d)\n", mode); - TRACE("SetRunMode(%d)\n", mode); - BMediaEventLooper::SetRunMode(mode); -} - - void VideoProducer::HandleEvent(const media_timed_event* event, bigtime_t lateness, bool realTimeEvent) @@ -225,27 +188,6 @@ VideoProducer::HandleEvent(const media_timed_event* event, } -void -VideoProducer::CleanUpEvent(const media_timed_event *event) -{ - BMediaEventLooper::CleanUpEvent(event); -} - - -bigtime_t -VideoProducer::OfflineTime() -{ - return BMediaEventLooper::OfflineTime(); -} - - -void -VideoProducer::ControlLoop() -{ - BMediaEventLooper::ControlLoop(); -} - - status_t VideoProducer::DeleteHook(BMediaNode* node) { @@ -444,7 +386,7 @@ VideoProducer::Connect(status_t error, const media_source& source, ERROR("Connect() - wrong source.\n"); return; } - if (error < B_OK) { + if (error != B_OK) { ERROR("Connect() - consumer error: %s\n", strerror(error)); return; } @@ -696,6 +638,8 @@ VideoProducer::_FrameGeneratorThread() case B_OK: { TRACE("_FrameGeneratorThread: node manager successfully " "locked\n"); + if (droppedFrames > 0) + fManager->FrameDropped(); // get the times for the current and the next frame performanceTime = fManager->TimeForFrame(fFrame); nextPerformanceTime = fManager->TimeForFrame(fFrame + 1); @@ -749,14 +693,12 @@ VideoProducer::_FrameGeneratorThread() if (ignoreEvent || !fRunning || !fEnabled) { TRACE("_FrameGeneratorThread: ignore event\n"); // nothing to do - } else if (nextWaitUntil < system_time() - fBufferLatency + } else if (!forceSendingBuffer + && nextWaitUntil < system_time() - fBufferLatency && droppedFrames < kMaxDroppedFrames) { // Drop frame if it's at least a frame late. - printf("VideoProducer: dropped frame (%Ld)\n", fFrame); - if (fManager->LockWithTimeout(10000) == B_OK) { - fManager->FrameDropped(); - fManager->Unlock(); - } + if (playingDirection > 0) + printf("VideoProducer: dropped frame (%Ld)\n", fFrame); // next frame droppedFrames++; fFrame++; @@ -772,8 +714,7 @@ VideoProducer::_FrameGeneratorThread() * fConnectedFormat.display.line_count, 0LL); if (buffer == NULL) { // Wait until a buffer becomes available again - TRACE("_FrameGeneratorThread: no buffer!\n"); -// ERROR("_FrameGeneratorThread: no buffer!\n"); + ERROR("_FrameGeneratorThread: no buffer!\n"); break; } // Fill out the details about this buffer. @@ -802,7 +743,8 @@ VideoProducer::_FrameGeneratorThread() "playlistFrame: %Ld\n", fFrame, playlistFrame); bool wasCached = false; err = fSupplier->FillBuffer(playlistFrame, - buffer->Data(), fConnectedFormat, wasCached); + buffer->Data(), fConnectedFormat, forceSendingBuffer, + wasCached); // clean the buffer if something went wrong if (err != B_OK) { // TODO: should use "back value" according diff --git a/src/apps/mediaplayer/media_node_framework/video/VideoProducer.h b/src/apps/mediaplayer/media_node_framework/video/VideoProducer.h index 57adbc6cdf..e8a5b1c776 100644 --- a/src/apps/mediaplayer/media_node_framework/video/VideoProducer.h +++ b/src/apps/mediaplayer/media_node_framework/video/VideoProducer.h @@ -36,13 +36,11 @@ public: // BMediaNode interface public: - virtual port_id ControlPort() const; virtual BMediaAddOn* AddOn(int32* _internalId) const; virtual status_t HandleMessage(int32 message, const void* data, size_t size); protected: virtual void SetTimeSource(BTimeSource* timeSource); - virtual status_t RequestCompleted(const media_request_info& info); // BMediaEventLooper interface protected: @@ -51,17 +49,9 @@ protected: virtual void Stop(bigtime_t performanceTime, bool immediate); virtual void Seek(bigtime_t mediaTime, bigtime_t performanceTime); - virtual void TimeWarp(bigtime_t atRealTime, - bigtime_t toPerformanceTime); - virtual status_t AddTimer(bigtime_t atPerformanceTime, - int32 cookie); - virtual void SetRunMode(run_mode mode); virtual void HandleEvent(const media_timed_event* event, bigtime_t lateness, bool realTimeEvent = false); - virtual void CleanUpEvent(const media_timed_event* event); - virtual bigtime_t OfflineTime(); - virtual void ControlLoop(); virtual status_t DeleteHook(BMediaNode* node); // BBufferProducer interface diff --git a/src/apps/mediaplayer/media_node_framework/video/VideoSupplier.h b/src/apps/mediaplayer/media_node_framework/video/VideoSupplier.h index 010853a01a..ae57e4122e 100644 --- a/src/apps/mediaplayer/media_node_framework/video/VideoSupplier.h +++ b/src/apps/mediaplayer/media_node_framework/video/VideoSupplier.h @@ -20,7 +20,7 @@ public: virtual status_t FillBuffer(int64 startFrame, void* buffer, const media_raw_video_format& format, - bool& wasCached) = 0; + bool forceGeneration, bool& wasCached) = 0; virtual void DeleteCaches(); diff --git a/src/apps/mediaplayer/supplier/ProxyVideoSupplier.cpp b/src/apps/mediaplayer/supplier/ProxyVideoSupplier.cpp index a3ba901f16..1fc2d960ce 100644 --- a/src/apps/mediaplayer/supplier/ProxyVideoSupplier.cpp +++ b/src/apps/mediaplayer/supplier/ProxyVideoSupplier.cpp @@ -30,7 +30,8 @@ ProxyVideoSupplier::~ProxyVideoSupplier() status_t ProxyVideoSupplier::FillBuffer(int64 startFrame, void* buffer, - const media_raw_video_format& format, bool& wasCached) + const media_raw_video_format& format, bool forceGeneration, + bool& wasCached) { bigtime_t now = system_time(); @@ -56,7 +57,7 @@ ProxyVideoSupplier::FillBuffer(int64 startFrame, void* buffer, // But don't do it for more than 5 frames, or we will take too much // time. Doing it this way will still catch up to the next keyframe // eventually (we may return the wrong frames until the next keyframe). - if (startFrame - frame > 5) + if (!forceGeneration && startFrame - frame > 5) return B_TIMED_OUT; while (frame < startFrame) { ret = fSupplier->ReadFrame(buffer, &performanceTime, format, diff --git a/src/apps/mediaplayer/supplier/ProxyVideoSupplier.h b/src/apps/mediaplayer/supplier/ProxyVideoSupplier.h index 3a879d8552..0995e97d83 100644 --- a/src/apps/mediaplayer/supplier/ProxyVideoSupplier.h +++ b/src/apps/mediaplayer/supplier/ProxyVideoSupplier.h @@ -20,7 +20,7 @@ public: virtual status_t FillBuffer(int64 startFrame, void* buffer, const media_raw_video_format& format, - bool& wasCached); + bool forceGeneration, bool& wasCached); virtual void DeleteCaches();