[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog backend/sound_handler.h backend...
From: |
Tomas Groth |
Subject: |
[Gnash-commit] gnash ChangeLog backend/sound_handler.h backend... |
Date: |
Thu, 24 May 2007 22:27:10 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Tomas Groth <tgc> 07/05/24 22:27:09
Modified files:
. : ChangeLog
backend : sound_handler.h sound_handler_gst.h
sound_handler_sdl.h
libbase : LoadThread.cpp LoadThread.h curl_adapter.cpp
Log message:
* libbase/LoadThread.{cpp,h}: Made the download loop sleep when
read() wants to get a lock on the mutex.
* libbase/curl_adapter.cpp: Decreased the sleeping time in
fill_cache.
*
backend/{sound_handler.h,sound_handler_gst.h,sound_handler_sdl.h}:
Moved sound_data class to the base header.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3347&r2=1.3348
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler.h?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_gst.h?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_sdl.h?cvsroot=gnash&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/LoadThread.cpp?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/LoadThread.h?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/curl_adapter.cpp?cvsroot=gnash&r1=1.35&r2=1.36
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3347
retrieving revision 1.3348
diff -u -b -r1.3347 -r1.3348
--- ChangeLog 24 May 2007 22:06:09 -0000 1.3347
+++ ChangeLog 24 May 2007 22:27:09 -0000 1.3348
@@ -1,3 +1,11 @@
+2007-05-24 Tomas Groth Christensen <address@hidden>
+
+ * libbase/LoadThread.{cpp,h}: Made the download loop sleep when
+ read() wants to get a lock on the mutex.
+ * libbase/curl_adapter.cpp: Decreased the sleeping time in fill_cache.
+ * backend/{sound_handler.h,sound_handler_gst.h,sound_handler_sdl.h}:
+ Moved sound_data class to the base header.
+
2007-05-24 Sandro Santilli <address@hidden>
* libbase/curl_adapter.cpp (CurlStreamFile::seek): use the _cached
Index: backend/sound_handler.h
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- backend/sound_handler.h 24 May 2007 08:48:02 -0000 1.9
+++ backend/sound_handler.h 24 May 2007 22:27:09 -0000 1.10
@@ -17,7 +17,7 @@
//
//
-/* $Id: sound_handler.h,v 1.9 2007/05/24 08:48:02 strk Exp $ */
+/* $Id: sound_handler.h,v 1.10 2007/05/24 22:27:09 tgc Exp $ */
/// \page sound_handler_intro Sound handler introduction
///
@@ -42,6 +42,37 @@
namespace gnash {
+/// Used to hold the sounddata when doing on-demand-decoding
+class sound_data
+{
+public:
+ // The (un)compressed data
+ guint8* data;
+
+ // data format
+ int format;
+
+ // data size
+ long data_size;
+
+ // stereo or not
+ bool stereo;
+
+ // number of samples
+ int sample_count;
+
+ // sample rate
+ int sample_rate;
+
+ // Volume, SWF range: 0-100, GST range 0-10 (we only use 0-1, the rest
is amplified)
+ // It's the SWF range that is represented here
+ int volume;
+
+ // gstreamer objects
+ std::vector<gst_elements*> m_gst_elements;
+
+};
+
//
// Sound callback handler.
//
Index: backend/sound_handler_gst.h
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_gst.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- backend/sound_handler_gst.h 24 May 2007 08:48:02 -0000 1.5
+++ backend/sound_handler_gst.h 24 May 2007 22:27:09 -0000 1.6
@@ -62,38 +62,6 @@
};
-
-// Used to hold the sounddata when doing on-demand-decoding
-class sound_data
-{
-public:
- // The (un)compressed data
- guint8* data;
-
- // data format
- int format;
-
- // data size
- long data_size;
-
- // stereo or not
- bool stereo;
-
- // number of samples
- int sample_count;
-
- // sample rate
- int sample_rate;
-
- // Volume, SWF range: 0-100, GST range 0-10 (we only use 0-1, the rest
is amplified)
- // It's the SWF range that is represented here
- int volume;
-
- // gstreamer objects
- std::vector<gst_elements*> m_gst_elements;
-
-};
-
// Use gstreamer to handle sounds.
class GST_sound_handler : public gnash::sound_handler
{
Index: backend/sound_handler_sdl.h
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_sdl.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- backend/sound_handler_sdl.h 24 May 2007 11:46:28 -0000 1.21
+++ backend/sound_handler_sdl.h 24 May 2007 22:27:09 -0000 1.22
@@ -14,7 +14,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: sound_handler_sdl.h,v 1.21 2007/05/24 11:46:28 strk Exp $
+// $Id: sound_handler_sdl.h,v 1.22 2007/05/24 22:27:09 tgc Exp $
#ifndef SOUND_HANDLER_SDL_H
#define SOUND_HANDLER_SDL_H
@@ -109,39 +109,6 @@
};
-
-/// Used to hold the sounddata when doing on-demand-decoding
-class sound_data
-{
-public:
- /// The undecoded data
- uint8_t* data;
-
- /// Format of the sound (MP3, raw, etc).
- int format;
-
- /// The size of the undecoded data
- long data_size;
-
- /// Stereo or not
- bool stereo;
-
- /// Number of samples
- int sample_count;
-
- /// Sample rate
- int sample_rate;
-
- /// Volume for AS-sounds, range: 0-100.
- /// It's the SWF range that is represented here.
- int volume;
-
- /// Vector containing the active instances of this sounds being played
- std::vector<active_sound*> m_active_sounds;
-
-};
-
-
// Use SDL and ffmpeg/mad/nothing to handle sounds.
class SDL_sound_handler : public gnash::sound_handler
{
Index: libbase/LoadThread.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/LoadThread.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- libbase/LoadThread.cpp 7 May 2007 07:25:06 -0000 1.10
+++ libbase/LoadThread.cpp 24 May 2007 22:27:09 -0000 1.11
@@ -16,10 +16,17 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-// $Id: LoadThread.cpp,v 1.10 2007/05/07 07:25:06 strk Exp $
+// $Id: LoadThread.cpp,v 1.11 2007/05/24 22:27:09 tgc Exp $
#include "LoadThread.h"
+#if defined(_WIN32) || defined(WIN32)
+# include <windows.h> // for sleep()
+# define usleep(x) Sleep(x/1000)
+#else
+# include "unistd.h" // for usleep()
+#endif
+
LoadThread::LoadThread()
:
_completed(false),
@@ -31,7 +38,8 @@
_cachedData(0),
_cacheSize(0),
_chunkSize(56),
- _streamSize(0)
+ _streamSize(0),
+ _needAccess(false)
{
}
@@ -107,6 +115,9 @@
// so we now either load more data into the cache, or completely
// replace the content.
+ // Tell the download loop to be nice and take a break
+ _needAccess = true;
+
#ifdef THREADED_LOADS
boost::mutex::scoped_lock lock(_mutex);
#endif
@@ -129,6 +140,7 @@
_cachedData = _userPosition - _cacheStart + ret;
_userPosition += ret;
_actualPosition = _userPosition;
+ _needAccess = false;
return ret;
}
@@ -170,6 +182,8 @@
_cachedData = ret;
_cacheStart = newcachestart;
+ _needAccess = false;
+
if (ret < _userPosition - newcachestart) return 0;
int newret = bytes;
@@ -243,8 +257,15 @@
{
// Until the download is completed keep downloading
while (!lt->_completed) {
+ // If the cache is full just "warm up" the data using
download(),
+ // else put data directly into the cache using fillCache().
if (lt->_chunkSize + lt->_loadPosition > lt->_cacheStart +
lt->_cacheSize) lt->download();
else lt->fillCache();
+
+ // If the read() fuction needs to get access to the stream we
take a break.
+ if (lt->_needAccess) {
+ usleep(100000); // 1/10 second
+ }
}
}
@@ -260,8 +281,11 @@
boost::mutex::scoped_lock lock(_mutex);
#endif
+ // If we're not at the reading head, move to it
if (_loadPosition != _actualPosition)
_stream->set_position(_loadPosition);
+ // If loading the next chunk will overflow the cache, only fill the
cache
+ // the "the edge", and "warm up" the remaining data.
int ret;
if (_cachedData + _chunkSize > _cacheSize) {
ret = _stream->read_bytes(_cache + _cachedData, _cacheSize -
_cachedData);
@@ -319,5 +343,6 @@
_loadPosition = pos;
assert(_loadPosition <= _streamSize);
_actualPosition = pos;
+
}
Index: libbase/LoadThread.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/LoadThread.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- libbase/LoadThread.h 8 May 2007 09:39:25 -0000 1.8
+++ libbase/LoadThread.h 24 May 2007 22:27:09 -0000 1.9
@@ -145,6 +145,13 @@
// size of the stream
long _streamSize;
+
+ // Tell the download loop to be nice and take a break
+ // This is needed since the loop in downloadThread() calls fillCache()
and
+ // download() which locks _mutex, and sometimes the read() function
can't
+ // get a lock because fillCache() and download() just "keeps" it, which
can
+ // makes read() wait for for a really long time.
+ volatile bool _needAccess;
};
#endif // __LOADTHREAD_H__
Index: libbase/curl_adapter.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/curl_adapter.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- libbase/curl_adapter.cpp 24 May 2007 22:06:09 -0000 1.35
+++ libbase/curl_adapter.cpp 24 May 2007 22:27:09 -0000 1.36
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: curl_adapter.cpp,v 1.35 2007/05/24 22:06:09 strk Exp $ */
+/* $Id: curl_adapter.cpp,v 1.36 2007/05/24 22:27:09 tgc Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -283,8 +283,8 @@
// to nap between curl_multi_perform calls if the amount
// of data requested haven't arrived yet.
//
- const long unsigned minSleep = 100000; // 1/10 second
- const long unsigned maxSleep = 300000; // 3/10 second
+ const long unsigned minSleep = 10000; // 1/100 second
+ const long unsigned maxSleep = 100000; // 1/10 second
CURLMcode mcode;
#if VERBOSE_POLLING_LOOP