gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-


From: Sandro Santilli
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-271-gcccdbe9
Date: Fri, 15 Apr 2011 11:49:48 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  cccdbe9fbf889549d7e48db4a358f91b2dbcf8a3 (commit)
      from  a5b6f14cc13cee27af900ae43a9448ec9ecdd915 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=cccdbe9fbf889549d7e48db4a358f91b2dbcf8a3


commit cccdbe9fbf889549d7e48db4a358f91b2dbcf8a3
Author: Sandro Santilli <address@hidden>
Date:   Fri Apr 15 13:34:26 2011 +0200

    Some steps forward in MediaParserFfmpeg::seek(). Fixes the google dict case 
(ticket #33085) and shouldn't break anyting since prior to this commit the 
function simply returned false...

diff --git a/libmedia/ffmpeg/MediaParserFfmpeg.cpp 
b/libmedia/ffmpeg/MediaParserFfmpeg.cpp
index 214f9a5..19c8136 100644
--- a/libmedia/ffmpeg/MediaParserFfmpeg.cpp
+++ b/libmedia/ffmpeg/MediaParserFfmpeg.cpp
@@ -94,44 +94,52 @@ MediaParserFfmpeg::probeStream()
 bool
 MediaParserFfmpeg::seek(boost::uint32_t& pos)
 {
-       LOG_ONCE(log_unimpl("MediaParserFfmpeg::seek()"));
-       return false;
-
-       log_debug("MediaParserFfmpeg::seek(%d) TESTING", pos);
-
-       AVStream* videostream = _formatCtx->streams[_videoStreamIndex];
-       double timebase = static_cast<double>(videostream->time_base.num / 
videostream->time_base.den);
-       long newpos = static_cast<long>(pos / timebase);
-               
-       if (av_seek_frame(_formatCtx, _videoStreamIndex, newpos, 0) < 0)
-       {
-               log_error(_("%s: seeking failed"), __FUNCTION__);
-               return 0;
-       }
-
-       AVPacket Packet;
-       av_init_packet(&Packet);
-       double newtime = 0;
-       while (newtime == 0)
-       {
-               if (av_read_frame(_formatCtx, &Packet) < 0) 
-               {
-                       log_error("Error in av_read_frame (while seeking)");
-                       av_seek_frame(_formatCtx, -1, 0, AVSEEK_FLAG_BACKWARD);
-                       //av_free_packet( &Packet );
-                       return 0; // ??
-               }
-
-               newtime = timebase * 
static_cast<double>(_formatCtx->streams[_videoStreamIndex]->cur_dts);
-       }
-
-       //av_free_packet( &Packet );
-       av_seek_frame(_formatCtx, _videoStreamIndex, newpos, 0);
+    // lock the stream while reading from it, so actionscript
+    // won't mess with the parser on seek  or on getBytesLoaded
+    boost::mutex::scoped_lock streamLock(_streamMutex);
+
+    // NOTE: seeking when timestamps are unknown is a pain
+    // See https://savannah.gnu.org/bugs/index.php?33085
+    // TODO: newer ffmpeg versions seem to have an
+    //  av_seek_frame_generic() function 
+    // which may help us. May be worth taking a look
+    //
+    if ( pos == 0 ) {
+        // Handle 0 by seeking to byte 0
+        // Doing this saves lots of headakes in absence
+        // of correct timestamps (which is the case for mp3)
+        log_debug("Seeking MediaParserFfmpeg input to byte offset zero");
+        if (av_seek_frame(_formatCtx, -1, pos, AVSEEK_FLAG_BYTE) < 0) {
+            log_error(_("%s: seeking failed"), __FUNCTION__);
+            return 0;
+        }
+    }
+    else {
+        // This is most likely wrong
+           log_debug("MediaParserFfmpeg::seek(%d) TESTING", pos);
+        long newpos = static_cast<long>(pos / AV_TIME_BASE);
+        if (av_seek_frame(_formatCtx, -1, newpos, 0) < 0) {
+            log_error(_("%s: seeking failed"), __FUNCTION__);
+            return 0;
+        }
+    }
 
-       newtime = static_cast<boost::int32_t>(newtime / 1000.0);
-       log_debug("Seek requested to time %d triggered seek to key frame at "
-            "time %d", pos, newtime);
-       pos = newtime;
+    // We'll restart parsing
+    _parsingComplete = false;
+
+    // Finally, clear the buffers.
+    // The call will also wake the parse up if it was sleeping.
+    // WARNING: a race condition might be pending here:
+    // If we handled to do all the seek work in the *small*
+    // time that the parser runs w/out mutex locked (ie:
+    // after it unlocked the stream mutex and before it locked
+    // the queue mutex), it will still push an old encoded frame
+    // to the queue; if the pushed frame alone makes it block
+    // again (bufferFull) we'll have a problem.
+    // Note though, that a single frame can't reach a bufferFull
+    // condition, as it takes at least two for anything != 0.
+    //
+    clearBuffers();
 
     return true;
 }

-----------------------------------------------------------------------

Summary of changes:
 libmedia/ffmpeg/MediaParserFfmpeg.cpp |   84 ++++++++++++++++++---------------
 1 files changed, 46 insertions(+), 38 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]