[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash/server movie_def_impl.cpp movie_def_impl.h
From: |
Vitaly Alexeev |
Subject: |
[Gnash-commit] gnash/server movie_def_impl.cpp movie_def_impl.h |
Date: |
Mon, 21 Aug 2006 09:53:10 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Vitaly Alexeev <alexeev> 06/08/21 09:53:10
Modified files:
server : movie_def_impl.cpp movie_def_impl.h
Log message:
SDL MovieLoader stuff
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_def_impl.cpp?cvsroot=gnash&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_def_impl.h?cvsroot=gnash&r1=1.20&r2=1.21
Patches:
Index: movie_def_impl.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/movie_def_impl.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- movie_def_impl.cpp 19 Aug 2006 13:15:40 -0000 1.22
+++ movie_def_impl.cpp 21 Aug 2006 09:53:10 -0000 1.23
@@ -77,18 +77,85 @@
namespace gnash
{
+#ifdef HAVE_SDL_H
+
+MovieLoader::MovieLoader(movie_def_impl& md)
+ :
+ _waiting_for_frame(0),
+ _movie_def(md)
+{
+ _frame_reached_condition = SDL_CreateCond();
+ _mutex = SDL_CreateMutex();
+}
+
+MovieLoader::~MovieLoader()
+{
+ SDL_DestroyMutex(_mutex);
+ SDL_DestroyCond(_frame_reached_condition);
+}
+
+int MovieLoader::execute(void* arg)
+{
+ movie_def_impl* md = static_cast<movie_def_impl*>(arg);
+ md->read_all_swf();
+ return 0;
+}
+
+bool MovieLoader::start()
+{
+ _thread = SDL_CreateThread(execute, &_movie_def);
+ if (_thread == NULL)
+ {
+ return false;
+ }
+ return true;
+}
+
+void MovieLoader::signal_frame_loaded(size_t frameno)
+{
+ SDL_CondSignal(_frame_reached_condition);
+}
+
+void MovieLoader::wait_for_frame(size_t framenum)
+{
+ if (_movie_def.get_loading_frame() >= framenum)
+ {
+ return;
+ }
+
+ SDL_mutexP(_mutex);
+
+ do
+ {
+ SDL_CondWait(_frame_reached_condition, _mutex);
+ }
+ while (_movie_def.get_loading_frame() < framenum);
+
+ SDL_mutexV(_mutex);
+}
+
+void MovieLoader::lock()
+{
+}
+
+void MovieLoader::unlock()
+{
+}
+
+#else
+
MovieLoader::MovieLoader(movie_def_impl& md)
:
- waiting_for_frame(0),
+ _waiting_for_frame(0),
_movie_def(md)
{
- pthread_cond_init(&frame_reached_condition, NULL);
+ pthread_cond_init(&_frame_reached_condition, NULL);
pthread_mutex_init(&_mutex, NULL);
}
MovieLoader::~MovieLoader()
{
- pthread_cond_destroy(&frame_reached_condition);
+ pthread_cond_destroy(&_frame_reached_condition);
pthread_mutex_destroy(&_mutex);
}
@@ -118,10 +185,10 @@
void
MovieLoader::signal_frame_loaded(size_t frameno)
{
- if ( waiting_for_frame &&
- frameno >= waiting_for_frame )
+ if (_waiting_for_frame &&
+ frameno >= _waiting_for_frame )
{
- pthread_cond_signal(&frame_reached_condition);
+ pthread_cond_signal(&_frame_reached_condition);
}
}
@@ -184,15 +251,16 @@
if ( _movie_def.get_loading_frame() < framenum )
{
- assert(waiting_for_frame == 0);
- waiting_for_frame = framenum;
- pthread_cond_wait(&frame_reached_condition, &_mutex);
- waiting_for_frame = 0;
+ assert(_waiting_for_frame == 0);
+ _waiting_for_frame = framenum;
+ pthread_cond_wait(&_frame_reached_condition, &_mutex);
+ _waiting_for_frame = 0;
}
unlock();
}
+#endif // PTHREAD MovieLoader
//
Index: movie_def_impl.h
===================================================================
RCS file: /sources/gnash/gnash/server/movie_def_impl.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- movie_def_impl.h 19 Aug 2006 13:15:40 -0000 1.20
+++ movie_def_impl.h 21 Aug 2006 09:53:10 -0000 1.21
@@ -56,10 +56,12 @@
#include <string>
#include <memory> // for auto_ptr
-#if defined(_WIN32) || defined(WIN32)
-# include <pthread.h>
+#ifdef HAVE_SDL_H
+# include "SDL.h"
+# include "SDL_thread.h"
#endif
+
namespace gnash
{
@@ -131,18 +133,28 @@
private:
- size_t waiting_for_frame;
+ size_t _waiting_for_frame;
+ movie_def_impl& _movie_def;
- pthread_cond_t frame_reached_condition;
+#ifdef HAVE_SDL_H
- pthread_mutex_t _mutex;
+ static int execute(void* arg);
+
+ SDL_Thread* _thread;
+ SDL_cond* _frame_reached_condition;
+ SDL_mutex* _mutex;
+
+#else
+ pthread_cond_t _frame_reached_condition;
+ pthread_mutex_t _mutex;
pthread_t _thread;
/// Entry point for the actual thread
static void *execute(void* arg);
- movie_def_impl& _movie_def;
+#endif
+
};
/// The Characters dictionary associated with each SWF file.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash/server movie_def_impl.cpp movie_def_impl.h,
Vitaly Alexeev <=