gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/asobj/SoundFfmpeg.cpp se...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/asobj/SoundFfmpeg.cpp se...
Date: Mon, 12 Nov 2007 16:17:03 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/11/12 16:17:03

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

Log message:
        Add a LOADS_IN_SEPARATE_THREAD macro (defined by default) to disable 
threading, make the
        setupDecoder a non-static private and getAudio also private.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4835&r2=1.4836
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/SoundFfmpeg.cpp?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/SoundFfmpeg.h?cvsroot=gnash&r1=1.9&r2=1.10

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4835
retrieving revision 1.4836
diff -u -b -r1.4835 -r1.4836
--- ChangeLog   12 Nov 2007 15:16:27 -0000      1.4835
+++ ChangeLog   12 Nov 2007 16:17:02 -0000      1.4836
@@ -1,5 +1,11 @@
 2007-11-12 Sandro Santilli <address@hidden>
 
+       * server/asobj/SoundFfmpeg.{cpp,h}: Add a LOADS_IN_SEPARATE_THREAD
+         macro (defined by default) to disable threading, make the
+         setupDecoder a non-static private and getAudio also private.
+
+2007-11-12 Sandro Santilli <address@hidden>
+
        * server/asobj/SoundFfmpeg.cpp (getAudio): don't delete 
          allocated memory twice. Fixes bug #21195.
        * gui/gnash.in: Add support for -G list for getting a list

Index: server/asobj/SoundFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/SoundFfmpeg.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- server/asobj/SoundFfmpeg.cpp        12 Nov 2007 15:16:27 -0000      1.15
+++ server/asobj/SoundFfmpeg.cpp        12 Nov 2007 16:17:02 -0000      1.16
@@ -80,8 +80,9 @@
 
 
 void
-SoundFfmpeg::setupDecoder(SoundFfmpeg* so)
+SoundFfmpeg::setupDecoder()
 {
+       SoundFfmpeg* so = this;
 
        boost::intrusive_ptr<NetConnection> nc = so->connection;
        assert(nc);
@@ -91,7 +92,9 @@
        if ( !nc->openConnection(so->externalURL) ) {
                log_error(_("%s could not open audio url: %s"), 
                                __FUNCTION__, so->externalURL.c_str());
+#ifdef LOADS_IN_SEPARATE_THREAD
                delete so->lock;
+#endif
                return;
        }
 
@@ -115,7 +118,9 @@
                log_error(_("%s: could not read from audio url: %s"), 
                                __FUNCTION__, so->externalURL.c_str());
                delete[] pd->buf;
+#ifdef LOADS_IN_SEPARATE_THREAD
                delete so->lock;
+#endif
                return;
        }
 
@@ -134,7 +139,9 @@
        // Open the stream. the 4th argument is the filename, which we ignore.
        if(av_open_input_stream(&so->formatCtx, &so->ByteIOCxt, "", inputFmt, 
NULL) < 0){
                log_error(_("Couldn't open file '%s' for decoding"), 
so->externalURL.c_str());
+#ifdef LOADS_IN_SEPARATE_THREAD
                delete so->lock;
+#endif
                return;
        }
 
@@ -144,7 +151,9 @@
        if (ret < 0)
        {
                log_error(_("Couldn't find stream information from '%s', error 
code: %d"), so->externalURL.c_str(), ret);
+#ifdef LOADS_IN_SEPARATE_THREAD
                delete so->lock;
+#endif
                return;
        }
 
@@ -188,7 +197,9 @@
        {
                log_error(_("No available audio decoder %d to process file: 
'%s'"),
                   so->audioCodecCtx->codec_id, so->externalURL.c_str());
+#ifdef LOADS_IN_SEPARATE_THREAD
                delete so->lock;
+#endif
                return;
        }
     
@@ -197,12 +208,16 @@
        {
                log_error(_("Could not open audio codec %d for %s"),
                   so->audioCodecCtx->codec_id, so->externalURL.c_str());
+#ifdef LOADS_IN_SEPARATE_THREAD
                delete so->lock;
+#endif
                return;
        }
 
        // By deleting this lock we allow start() to start playback
+#ifdef LOADS_IN_SEPARATE_THREAD
        delete so->lock;
+#endif
        return;
 }
 
@@ -377,17 +392,23 @@
        externalSound = true;
        isStreaming = streaming;
 
+#ifdef LOADS_IN_SEPARATE_THREAD
        lock = new boost::mutex::scoped_lock(setupMutex);
 
        // To avoid blocking while connecting, we use a thread.
-       setupThread = new boost::thread(boost::bind(SoundFfmpeg::setupDecoder, 
this));
+       setupThread = new boost::thread(boost::bind(&SoundFfmpeg::setupDecoder, 
this));
+#else
+       setupDecoder();
+#endif
 
 }
 
 void
 SoundFfmpeg::start(int offset, int loops)
 {
+#ifdef LOADS_IN_SEPARATE_THREAD
        boost::mutex::scoped_lock lock(setupMutex);
+#endif
 
        if (externalSound) {
                if (offset > 0) {

Index: server/asobj/SoundFfmpeg.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/SoundFfmpeg.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- server/asobj/SoundFfmpeg.h  24 Jul 2007 20:53:02 -0000      1.9
+++ server/asobj/SoundFfmpeg.h  12 Nov 2007 16:17:02 -0000      1.10
@@ -32,6 +32,10 @@
 #include <boost/bind.hpp> 
 #include <boost/thread/mutex.hpp>
 
+// Undefined the following macro to disable threading
+// TODO: use a global define for disabling all threads at once
+#define LOADS_IN_SEPARATE_THREAD
+
 extern "C" {
 #include <ffmpeg/avformat.h>
 }
@@ -50,10 +54,12 @@
                audioStream(NULL),
                formatCtx(NULL),
                audioFrame(NULL),
-               resampleCtx(NULL),
-               setupThread(NULL),
-               lock(NULL), 
-               inputPos(0),
+               resampleCtx(NULL)
+#ifdef LOADS_IN_SEPARATE_THREAD
+               ,setupThread(NULL)
+               ,lock(NULL)
+#endif
+               ,inputPos(0),
                ByteIOCxt(), // ?
                audioIndex(-1),
                leftOverData(NULL),
@@ -74,10 +80,11 @@
        static int readPacket(void* opaque, uint8_t* buf, int buf_size);
        static offset_t seekMedia(void *opaque, offset_t offset, int whence);
 
-       static void setupDecoder(SoundFfmpeg* so);
-       static bool getAudio(void *owner, uint8_t *stream, int len);
 private:
 
+       void setupDecoder();
+       static bool getAudio(void *owner, uint8_t *stream, int len);
+
        // audio
        AVCodecContext *audioCodecCtx;
        AVStream* audioStream;
@@ -88,11 +95,13 @@
 
        ReSampleContext *resampleCtx;
 
+#ifdef LOADS_IN_SEPARATE_THREAD
        boost::thread *setupThread;
        boost::mutex setupMutex;
 
        // TODO: it makes NO SENSE for a scoped_lock to be allocated on the 
heap !
        boost::mutex::scoped_lock *lock;
+#endif
 
        long inputPos;
 




reply via email to

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