gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/asobj/NetStreamFfmpeg.cp...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/asobj/NetStreamFfmpeg.cp...
Date: Tue, 29 May 2007 11:01:42 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/05/29 11:01:41

Modified files:
        .              : ChangeLog 
        server/asobj   : NetStreamFfmpeg.cpp NetStreamFfmpeg.h 

Log message:
                * server/asobj/NetStreamFfmpeg.{cpp,h}: drop
                  the decode_wait_mutex, use decoding_mutex instead.
                  Document which function lock it and which not, adding
                  more locking. Seems to fix bug #19978, but exposes
                  a deadlock playing youtube with a full-offline setup
                  with reduced bandwidth.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3392&r2=1.3393
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamFfmpeg.cpp?cvsroot=gnash&r1=1.61&r2=1.62
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamFfmpeg.h?cvsroot=gnash&r1=1.34&r2=1.35

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3392
retrieving revision 1.3393
diff -u -b -r1.3392 -r1.3393
--- ChangeLog   29 May 2007 09:16:28 -0000      1.3392
+++ ChangeLog   29 May 2007 11:01:40 -0000      1.3393
@@ -1,3 +1,12 @@
+2007-05-29 Sandro Santilli <address@hidden>
+
+       * server/asobj/NetStreamFfmpeg.{cpp,h}: drop
+         the decode_wait_mutex, use decoding_mutex instead.
+         Document which function lock it and which not, adding
+         more locking. Seems to fix bug #19978, but exposes
+         a deadlock playing youtube with a full-offline setup
+         with reduced bandwidth.
+
 2007-05-29 Udo Giacomozzi <address@hidden>
 
        * testsuite/misc-ming.all/DrawingApiTestRunner.cpp: testing for gray

Index: server/asobj/NetStreamFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamFfmpeg.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- server/asobj/NetStreamFfmpeg.cpp    29 May 2007 01:10:48 -0000      1.61
+++ server/asobj/NetStreamFfmpeg.cpp    29 May 2007 11:01:40 -0000      1.62
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: NetStreamFfmpeg.cpp,v 1.61 2007/05/29 01:10:48 martinwguy Exp $ */
+/* $Id: NetStreamFfmpeg.cpp,v 1.62 2007/05/29 11:01:40 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -81,6 +81,8 @@
 
 void NetStreamFfmpeg::pause(int mode)
 {
+       boost::mutex::scoped_lock lock(decoding_mutex);
+
        if (mode == -1)
        {
                if (m_pause) unpauseDecoding();
@@ -102,6 +104,8 @@
 void NetStreamFfmpeg::close()
 {
 
+       boost::mutex::scoped_lock lock(decoding_mutex);
+
        if (m_go)
        {
                // terminate thread
@@ -123,9 +127,6 @@
                s->detach_aux_streamer((void*) NULL);
        }
 
-       // Make sure al decoding has stopped
-       boost::mutex::scoped_lock lock(decoding_mutex);
-
        if (m_Frame) av_free(m_Frame);
        m_Frame = NULL;
 
@@ -209,6 +210,7 @@
 void
 NetStreamFfmpeg::play(const std::string& c_url)
 {
+       boost::mutex::scoped_lock  lock(decoding_mutex);
 
        // Is it already playing ?
        if (m_go)
@@ -599,6 +601,8 @@
 {
        GNASH_REPORT_FUNCTION;
 
+       boost::mutex::scoped_lock lock(ns->decoding_mutex);
+
        // This should only happen if close() is called before this thread is 
ready
        if (!ns->m_go)
        {
@@ -633,8 +637,6 @@
 
        ns->m_unqueued_data = NULL;
 
-       boost::mutex::scoped_lock lock(ns->decode_wait_mutex);
-
        // Loop while we're playing
        while (ns->m_go)
        {
@@ -1160,6 +1162,9 @@
 void
 NetStreamFfmpeg::advance()
 {
+       boost::mutex::scoped_lock lock(decoding_mutex);
+
+       // Make sure al decoding has stopped
        // This can happen in 2 cases: 
        // 1) When playback has just started and we've been waiting for the 
buffer 
        //    to be filled (buffersize set by setBufferTime() and default is 100
@@ -1197,6 +1202,8 @@
 
 void NetStreamFfmpeg::pauseDecoding()
 {
+       // assert(decoding_mutex is locked by this thread!)
+
        if (m_pause) return;
 
        m_pause = true;
@@ -1207,6 +1214,8 @@
 
 void NetStreamFfmpeg::unpauseDecoding()
 {
+       // assert(decoding_mutex is locked by this thread!)
+
        if (!m_pause) return;
 
        m_pause = false;        

Index: server/asobj/NetStreamFfmpeg.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamFfmpeg.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- server/asobj/NetStreamFfmpeg.h      29 May 2007 09:54:11 -0000      1.34
+++ server/asobj/NetStreamFfmpeg.h      29 May 2007 11:01:41 -0000      1.35
@@ -15,7 +15,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-/* $Id: NetStreamFfmpeg.h,v 1.34 2007/05/29 09:54:11 strk Exp $ */
+/* $Id: NetStreamFfmpeg.h,v 1.35 2007/05/29 11:01:41 strk Exp $ */
 
 #ifndef __NETSTREAMFFMPEG_H__
 #define __NETSTREAMFFMPEG_H__
@@ -179,18 +179,32 @@
 public:
        NetStreamFfmpeg();
        ~NetStreamFfmpeg();
+
+       // Locks decoding_mutex
        void close();
+
+       /// Locks decoding_mutex
        void pause(int mode);
+
+       /// Locks decoding_mutex
        void play(const std::string& source);
+
+       /// Locks decoding_mutex
        void seek(double pos);
+
        int64_t time();
+
+       // Locks decoding_mutex
        void advance();
 
        // Used for ffmpeg data read and seek callbacks with non-FLV
        static int readPacket(void* opaque, uint8_t* buf, int buf_size);
        static offset_t seekMedia(void *opaque, offset_t offset, int whence);
 
-       // The decoding thread. Sets up the decoder, and decodes.
+       /// The decoding thread. Sets up the decoder, and decodes.
+       //
+       /// Locks decoding_mutex
+       ///
        static void av_streamer(NetStreamFfmpeg* ns);
 
        /// Callback used by sound_handler to get audio data
@@ -199,6 +213,8 @@
        ///
        /// It will be invoked by a separate thread (neither main, nor decoder 
thread).
        ///
+       /// Locks decoding_mutex
+       ///
        static bool audio_streamer(void *udata, uint8_t *stream, int len);
 
 private:
@@ -207,18 +223,30 @@
        bool startPlayback();
 
        // Pauses the decoding - don't directly modify m_pause!!
+       //
+       // does NOT lock decoding_mutex, use ::pause() for that
+       //
        void pauseDecoding();
 
        // Unpauses/resumes the decoding - don't directly modify m_pause!!
+       //
+       // does NOT lock decoding_mutex, used by ::av_streamer() which locks
+       //
        void unpauseDecoding();
 
        // Check is we need to update the video frame
+       //
+       // does NOT lock decoding_mutex, uses by ::advance() which locks
+       //
        void refreshVideoFrame();
 
        // Used to decode and push the next available (non-FLV) frame to the 
audio or video queue
        bool decodeMediaFrame();
 
        // Used to decode push the next available FLV frame to the audio or 
video queue
+       //
+       // does NOT lock decoding_mutex, uses by ::advance() which locks
+       //
        bool decodeFLVFrame();
 
        // Used to decode a video frame and push it on the videoqueue
@@ -258,9 +286,11 @@
        // Mutex used to make sure things arn't messed up when seeking and 
decoding (is it really necessary?)
        boost::mutex decoding_mutex;
 
-       // Mutex and condition used to pause the decoding thread/loop when
+       // Condition used to pause the decoding thread/loop when
        // playback is paused, or when the video and audio queues are full
-       boost::mutex decode_wait_mutex;
+       //
+       // Associated with the decoding_mutex
+       //
        boost::condition decode_wait;
 
        // The timestamp of the last decoded video frame




reply via email to

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