[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog libbase/LoadThread.cpp libbase/...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog libbase/LoadThread.cpp libbase/... |
Date: |
Sat, 20 Oct 2007 09:33:28 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/10/20 09:33:28
Modified files:
. : ChangeLog
libbase : LoadThread.cpp LoadThread.h
Log message:
* libbase/LoadThread.{cpp,h}: add support for cancelling load
(untested).
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4655&r2=1.4656
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/LoadThread.cpp?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/LoadThread.h?cvsroot=gnash&r1=1.12&r2=1.13
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4655
retrieving revision 1.4656
diff -u -b -r1.4655 -r1.4656
--- ChangeLog 20 Oct 2007 09:27:40 -0000 1.4655
+++ ChangeLog 20 Oct 2007 09:33:27 -0000 1.4656
@@ -1,5 +1,10 @@
2007-10-20 Sandro Santilli <address@hidden>
+ * libbase/LoadThread.{cpp,h}: add support for cancelling load
+ (untested).
+
+2007-10-20 Sandro Santilli <address@hidden>
+
* testsuite/: .cvsignore, Makefile.am, gnashrc.in:
Add a testsuite-local gnashrc to enable loading local
resources from the MEDIADIR.
Index: libbase/LoadThread.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/LoadThread.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- libbase/LoadThread.cpp 1 Jul 2007 10:54:06 -0000 1.15
+++ libbase/LoadThread.cpp 20 Oct 2007 09:33:28 -0000 1.16
@@ -16,7 +16,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-// $Id: LoadThread.cpp,v 1.15 2007/07/01 10:54:06 bjacques Exp $
+// $Id: LoadThread.cpp,v 1.16 2007/10/20 09:33:28 strk Exp $
#include "LoadThread.h"
@@ -33,6 +33,7 @@
_loadPosition(0),
_userPosition(0),
_actualPosition(0),
+ _cancelRequested(false),
_cache(),
_cacheStart(0),
_cachedData(0),
@@ -43,6 +44,25 @@
{
}
+void
+LoadThread::reset()
+{
+ _completed=false;
+ _loadPosition=0;
+ _userPosition=0;
+ _actualPosition=0;
+ _cache.reset();
+ _cancelRequested=false;
+ _cacheStart=0;
+ _cachedData=0;
+ _cacheSize=0;
+ _chunkSize=56;
+ _streamSize=0;
+ _needAccess=false;
+ _stream.reset();
+ _thread.reset();
+}
+
LoadThread::~LoadThread()
{
// stop the download thread if it's still runnning
@@ -57,12 +77,29 @@
#endif
}
+void
+LoadThread::requestCancel()
+{
+ boost::mutex::scoped_lock lock(_mutex);
+ _cancelRequested=true;
+ _thread->join();
+ reset();
+}
+
+bool
+LoadThread::cancelRequested() const
+{
+ boost::mutex::scoped_lock lock(_mutex);
+ return _cancelRequested;
+}
+
bool LoadThread::setStream(std::auto_ptr<tu_file> stream)
{
_stream = stream;
if (_stream.get() != NULL) {
// Start the downloading.
setupCache();
+ _cancelRequested = false;
#ifdef THREADED_LOADS
_thread.reset( new
boost::thread(boost::bind(LoadThread::downloadThread, this)) );
#else
@@ -253,7 +290,8 @@
void LoadThread::downloadThread(LoadThread* lt)
{
// Until the download is completed keep downloading
- while (!lt->_completed) {
+ while ( (!lt->_completed) && (!lt->cancelRequested()) )
+ {
// 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();
@@ -264,7 +302,6 @@
usleep(100000); // 1/10 second
}
}
-
}
void LoadThread::fillCache()
Index: libbase/LoadThread.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/LoadThread.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- libbase/LoadThread.h 1 Jul 2007 10:54:06 -0000 1.12
+++ libbase/LoadThread.h 20 Oct 2007 09:33:28 -0000 1.13
@@ -100,8 +100,14 @@
return (static_cast<int32_t>(pos) <= _loadPosition);
}
+ /// Request download cancel
+ void requestCancel();
+
private:
+ /// Return true if cancel was requested
+ bool cancelRequested() const;
+
/// The thread function used to download from the stream
static void downloadThread(LoadThread* lt);
@@ -120,7 +126,7 @@
volatile bool _completed;
#ifdef THREADED_LOADS
- boost::mutex _mutex;
+ mutable boost::mutex _mutex;
std::auto_ptr<boost::thread> _thread;
#endif
@@ -129,6 +135,8 @@
volatile long _userPosition;
volatile long _actualPosition;
+ bool _cancelRequested;
+
// Cache...
boost::scoped_array<uint8_t> _cache;
@@ -153,6 +161,9 @@
// get a lock because fillCache() and download() just "keeps" it, which
can
// makes read() wait for for a really long time.
volatile bool _needAccess;
+
+ /// Reset all values to original state
+ void reset();
};
#endif // __LOADTHREAD_H__
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog libbase/LoadThread.cpp libbase/...,
Sandro Santilli <=