[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ./ChangeLog plugin/player.cpp plugin/play...
From: |
Rob Savoye |
Subject: |
[Gnash-commit] gnash ./ChangeLog plugin/player.cpp plugin/play... |
Date: |
Thu, 02 Mar 2006 21:21:56 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Branch:
Changes by: Rob Savoye <address@hidden> 06/03/02 21:21:55
Modified files:
. : ChangeLog
plugin : player.cpp player.h plugin.cpp plugin.h
Log message:
* plugin/plugin.cpp: Always lock the display before locking X. Add
the locking to the function calls themselves, rather than wrapping
all the function calls. Add debug background thread for now. We
don't need SDL in the plugin now at all. Changes what gets setup
and when. Use a POSIX condition to signal the threads when they
have a movie to play.
* plugin.h: Add unsetGL() to unset the context. important for
threads. Add tons of silly debug messages.
* player.cpp: Extern the mutexes, and condition variables. Always
lock the display before locking X.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/ChangeLog.diff?tr1=1.168&tr2=1.169&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/plugin/player.cpp.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/plugin/player.h.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/plugin/plugin.cpp.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/plugin/plugin.h.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
Patches:
Index: gnash/ChangeLog
diff -u gnash/ChangeLog:1.168 gnash/ChangeLog:1.169
--- gnash/ChangeLog:1.168 Thu Mar 2 17:34:36 2006
+++ gnash/ChangeLog Thu Mar 2 21:21:55 2006
@@ -1,5 +1,15 @@
2006-03-02 Rob Savoye <address@hidden>
+ * plugin/plugin.cpp: Always lock the display before locking X. Add
+ the locking to the function calls themselves, rather than wrapping
+ all the function calls. Add debug background thread for now. We
+ don't need SDL in the plugin now at all. Changes what gets setup
+ and when. Use a POSIX condition to signal the threads when they
+ have a movie to play.
+ * plugin.h: Add unsetGL() to unset the context. important for
+ threads. Add tons of silly debug messages.
+ * player.cpp: Extern the mutexes, and condition variables. Always
+ lock the display before locking X.
* macros/hashmap.m4: New configure test for hash_map extension.
* configure.as: Look for hash_map extension. Check for vsnprintf,
strcasecmp, and stricmp.
Index: gnash/plugin/player.cpp
diff -u gnash/plugin/player.cpp:1.6 gnash/plugin/player.cpp:1.7
--- gnash/plugin/player.cpp:1.6 Mon Feb 27 15:19:25 2006
+++ gnash/plugin/player.cpp Thu Mar 2 21:21:55 2006
@@ -58,6 +58,11 @@
bool GLinitialized = false;
bool processing = false;
+extern Display *gxDisplay;
+extern SDL_mutex *glMutex;
+extern SDL_cond *gCond;
+extern SDL_mutex *playerMutex;
+
#define OVERSIZE 1.0f
static int runThread(void *nothing);
@@ -153,9 +158,9 @@
gnash::register_file_opener_callback(file_opener);
gnash::register_fscommand_callback(fs_callback);
- if (s_verbose == true) {
- gnash::register_log_callback(log_callback);
- }
+// if (s_verbose == true) {
+ gnash::register_log_callback(log_callback);
+// }
//gnash::set_antialiased(s_antialiased);
gnash::sound_handler *sound = NULL;
@@ -166,9 +171,15 @@
gnash::set_sound_handler(sound);
}
#endif
+ // Grab control of the display
+ inst->lockGL();
inst->lockX();
+ inst->setGL();
render = gnash::create_render_handler_ogl();
gnash::set_render_handler(render);
+ // Release control of the display
+ inst->freeX();
+ inst->freeGL();
// Get info about the width & height of the movie.
int movie_version = 0;
@@ -204,7 +215,6 @@
exit(1);
}
gnash::set_current_root(m);
- inst->freeX();
// Mouse state.
@@ -232,7 +242,9 @@
// Auto exit now.
break;
}
- inst->lockX();
+#ifdef TEST_GRAPHIC
+ inst->drawTestScene();
+#else
m = gnash::get_current_root();
gnash::delete_unused_root();
@@ -245,20 +257,22 @@
// glDrawBuffer(GL_BACK);
// }
-#ifdef TEST_GRAPHIC
- inst->drawTestScene();
-#else
+ // Grab control of the display
+ inst->lockGL();
+ inst->lockX();
inst->setGL();
m->display();
+ // Release control of the display
inst->freeX();
+ inst->freeGL();
#endif
frame_counter++;
- // See if we should exit. FIXME:
- if (m->get_current_frame() + 1 == md->get_frame_count()) {
- // We're reached the end of the movie; exit.
- break;
- }
+ // See if we should exit
+ if (m->get_current_frame() + 1 == md->get_frame_count()) {
+ // We're reached the end of the movie; exit.
+ break;
+ }
//glPopAttrib ();
@@ -268,10 +282,6 @@
// SDL_KillThread(thread); // kill the network read thread
// SDL_Quit();
- inst->lockX();
- if (md) {
- md->drop_ref();
- }
if (m) {
m->drop_ref();
}
@@ -281,7 +291,6 @@
// Clean up as much as possible, so valgrind will help find actual leaks.
gnash::clear();
- inst->freeX();
return 0;
}
@@ -351,32 +360,49 @@
int
playerThread(void *arg)
{
- printf("%s: at pid %d\n", __PRETTY_FUNCTION__, getpid());
- nsPluginInstance *inst = (nsPluginInstance *)arg;
int retries = 0;
+ nsPluginInstance *inst = (nsPluginInstance *)arg;
+ printf("%s: instance is %p for %s\n", __PRETTY_FUNCTION__, inst,
+ inst->getFilename());
+
+ SDL_CondWait(gCond, playerMutex);
#ifdef TEST_GRAPHIC
- while (!inst->getShutting()) {
- inst->lockX();
- inst->setGL();
- inst->drawTestScene();
- inst->swapBuffers();
- inst->freeX();
- sleep(15);
+ while (retries++ < 10) {
+ inst->drawTestScene();
+ printf("%s: Loop #%d... %s\n", __PRETTY_FUNCTION__, retries,
+ inst->getFilename());
+ sleep(1+retries);
}
#else
main_loop(inst);
#endif
+ printf("%s: Done this = %p...\n", __PRETTY_FUNCTION__, inst);
+ pthread_exit(inst);
+ return 0;
+}
-//#endif
-// SDL_Delay(20); // don't trash the CPU
- // So we don't run forever for now.
-// printf("%s(%d): FIXME: loop timed out\n",
-// __PRETTY_FUNCTION__, __LINE__);
-// }
+int
+playerThread3(void *arg)
+{
+ int retries = 0;
+ nsPluginInstance *inst = (nsPluginInstance *)arg;
+
+ printf("%s: instance is %p\n", __PRETTY_FUNCTION__, inst);
+
+ SDL_CondWait(gCond, playerMutex);
+
+ while (retries++ < 3) {
+ printf("%s: Looping... %s\n", __PRETTY_FUNCTION__, inst->getFilename());
+ sleep(1+retries);
+ }
+ printf("%s: Done this = %p...\n", __PRETTY_FUNCTION__, inst);
+
+ pthread_exit(arg);
+
return 0;
}
Index: gnash/plugin/player.h
diff -u gnash/plugin/player.h:1.2 gnash/plugin/player.h:1.3
--- gnash/plugin/player.h:1.2 Sat Jan 28 01:14:33 2006
+++ gnash/plugin/player.h Thu Mar 2 21:21:55 2006
@@ -20,6 +20,8 @@
#define __GNASH_PLAYER_H__
int playerThread(void *inst);
+int playerThread2(void *inst);
+int playerThread3(void *inst);
int main_loop(nsPluginInstance *inst);
// EOF of __GNASH_PLAYER_H__
Index: gnash/plugin/plugin.cpp
diff -u gnash/plugin/plugin.cpp:1.15 gnash/plugin/plugin.cpp:1.16
--- gnash/plugin/plugin.cpp:1.15 Sat Feb 25 15:43:35 2006
+++ gnash/plugin/plugin.cpp Thu Mar 2 21:21:55 2006
@@ -40,7 +40,7 @@
#include <X11/XKBlib.h>
#include <X11/keysym.h>
#include <X11/Sunkeysym.h>
-#include <SDL.h>
+// #include <SDL.h>
#include <SDL_thread.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -48,13 +48,14 @@
#include <string>
-#include "player.h"
-#include "xmlsocket.h"
-
#include "tu_file.h"
#include "tu_types.h"
+#include "Thread.h"
+#include "player.h"
+#include "xmlsocket.h"
using namespace std;
+using namespace gnash;
extern bool processing;
@@ -63,8 +64,10 @@
// These aren't static members of the class because we have to
// call these from the C callback for the Mozilla SDK.
-Display *gxDisplay;
-SDL_mutex *glMutex;
+Display *gxDisplay = NULL;
+SDL_mutex *glMutex = NULL;
+SDL_cond *gCond = NULL;
+SDL_mutex *playerMutex = NULL;
// static int streamfd = -1;
// static float s_scale = 1.0f;
@@ -76,9 +79,6 @@
static void xt_event_handler(Widget xtwidget, nsPluginInstance *plugin,
XEvent *xevent, Boolean *b);
-
-//Display *_xDisplay = NULL;
-
#if 0
static int attributeList_noFSAA[] = { GLX_RGBA, GLX_DOUBLEBUFFER,
GLX_STENCIL_SIZE, 1, None };
#else
@@ -114,10 +114,11 @@
NPError
NS_PluginInitialize()
{
- printf("%s: Initializing the Plugin\n",
- __PRETTY_FUNCTION__);
-// SDL_Init(SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE);
+ printf("%s: Initializing the Plugin\n", __PRETTY_FUNCTION__);
glMutex = SDL_CreateMutex();
+ playerMutex = SDL_CreateMutex();
+ gCond = SDL_CreateCond();
+
gxDisplay = XOpenDisplay(NULL);
return NPERR_NO_ERROR;
@@ -136,7 +137,11 @@
XCloseDisplay(gxDisplay);
gxDisplay = NULL;
SDL_DestroyMutex(glMutex);
-// SDL_Quit();
+ glMutex = NULL;
+ SDL_DestroyMutex(playerMutex);
+ playerMutex = NULL;
+ SDL_DestroyCond(gCond);
+ gCond = NULL;
}
/// \brief Retrieve values from the plugin for the Browser
@@ -230,11 +235,9 @@
// if (mThread != NULL) {
// SDL_KillThread(mThread);
// }
-#if 0
- if (cond) {
- SDL_DestroyCond(cond);
- }
-#endif
+// if (gCond) {
+// SDL_DestroyCond(gCond);
+// }
}
/// \brief Initialize an instance of the plugin object
@@ -250,7 +253,7 @@
return FALSE;
} else {
printf("%s: X origin = %d, Y Origin = %d, Width = %d,"
- " Height = %d WindowID = %p this = %p\n",
+ " Height = %d, WindowID = %p, this = %p\n",
__PRETTY_FUNCTION__,
aWindow->x, aWindow->y, aWindow->width, aWindow->height,
aWindow->window, this);
@@ -273,21 +276,14 @@
_plugInitialized = TRUE;
+ mThread = SDL_CreateThread(playerThread3, this);
+
// char SDL_windowhack[32];
// sprintf (SDL_windowhack,"SDL_WINDOWID=%d", aWindow->window);
// putenv (SDL_windowhack);
// _plugInitialized = TRUE;
- // We're only keeping track of the instantiations for debugging
- // purposes, so this variable should basically be ignored.
-// _instantiations++;
-// char tmp[100];
-// memset(tmp, 0, 100);
-// sprintf(tmp, "%s: Instantiations count: %d\n",
-// __PRETTY_FUNCTION__, _instantiations);
-// WriteStatus(tmp);
-
return TRUE;
}
@@ -295,7 +291,7 @@
///
/// This shuts down an object, and is called for every movie that gets
/// played. This is where the movie playing specific shutdown code
-/// goes.
+/// goes.
void
nsPluginInstance::shut()
{
@@ -307,15 +303,6 @@
SDL_KillThread(mThread);
mThread = NULL;
}
-
- // We're only keeping track of the instantiations for debugging
- // purposes, so this variable should basically be ignored.
-// _instantiations--;
-// char tmp[100];
-// memset(tmp, 0, 100);
-// sprintf(tmp, "%s: Instantiations count: %d\n",
-// __PRETTY_FUNCTION__, _instantiations);
-// WriteStatus(tmp);
}
/// \brief Set the window to be used to render in
@@ -333,19 +320,16 @@
return FALSE;
} else {
printf("%s: X origin = %d, Y Origin = %d, Width = %d,"
- " Height = %d WindowID = %p this = %p\n",
+ " Height = %d, WindowID = %p, this = %p\n",
__PRETTY_FUNCTION__,
aWindow->x, aWindow->y, aWindow->width, aWindow->height,
aWindow->window, this);
}
- if (_glInitialized) {
- printf("%s Already initialized...\n", __PRETTY_FUNCTION__);
- return TRUE;
- }
-
- if(aWindow == NULL)
- return FALSE;
+// if (_glInitialized) {
+// printf("%s Already initialized...\n", __PRETTY_FUNCTION__);
+// return TRUE;
+// }
if (aWindow->x == mX && aWindow->y == mY
&& aWindow->width == mWidth
@@ -353,6 +337,9 @@
&& (unsigned long)(aWindow->window) == mWindow) {
return TRUE;
}
+
+ lockX();
+ lockGL();
mX = aWindow->x;
mY = aWindow->y;
@@ -385,9 +372,11 @@
mContext = glXCreateContext(gxDisplay, vi, 0, GL_TRUE);
if (mContext) {
- printf("Got new glx Context\n");
+ printf("%s: Got new glxContext %p\n", __PRETTY_FUNCTION__,
mContext);
_glInitialized = TRUE;
setGL();
+ } else {
+ printf("%s: ERROR: Couldn't get new glxContext!\n",
__PRETTY_FUNCTION__);
}
#if 0
@@ -408,6 +397,8 @@
}
#endif
}
+ freeGL();
+ freeX();
resizeWindow(mWidth,mHeight);
@@ -472,6 +463,9 @@
unsigned int start, end, eq;
bool dumpopts = false;
+ printf("%s: this = %p, URL is %s\n", __PRETTY_FUNCTION__,
+ (void *)this, stream->url);
+
end = url.find(".swf", 0) + 4;
start = url.rfind("/", end) + 1;
fname = "/tmp/";
@@ -522,7 +516,8 @@
}
// printf("%s: URL is %s\n", __PRETTY_FUNCTION__, url.c_str());
- printf("%s: Open stream for %s (%d, %d)\n", __PRETTY_FUNCTION__,
fname.c_str(), start, end);
+ printf("%s: Open stream for %s, this = %p\n", __PRETTY_FUNCTION__,
+ fname.c_str(), (void *)this);
sprintf(tmp, "Loading Flash movie %s", fname.c_str());
WriteStatus(tmp);
@@ -548,7 +543,14 @@
NPError
nsPluginInstance::DestroyStream(NPStream * stream, NPError reason)
{
- printf("%s (%i): %s\n", __PRETTY_FUNCTION__, reason, stream->url);
+ char tmp[300];
+ memset(tmp, 0, 300);
+ nsPluginInstance *arg = (nsPluginInstance *)this;
+ sprintf(tmp, "Done Flash movie %s", swf_file.c_str());
+ WriteStatus(tmp);
+
+ printf("%s: this = %p, URL is %s\n", __PRETTY_FUNCTION__,
+ (void *)arg, stream->url);
processing = false;
if (_streamfd) {
@@ -567,11 +569,19 @@
}
}
-// cond = SDL_CreateCond();
-// mThread = SDL_CreateThread(playerThread, (void *)this);
-// SDL_CondSignal(cond);
-
+#if 0 // def TEST_GRAPHIC
drawTestScene();
+#else
+ printf("%s: Starting player Thread for this = %p\n",
+ __PRETTY_FUNCTION__, (void *)this);
+ mThread = SDL_CreateThread(playerThread, this);
+#endif
+
+ SDL_mutexP(playerMutex);
+ SDL_CondBroadcast(gCond);
+
+ sprintf(tmp, "Started thread for Flash movie %s", swf_file.c_str());
+ WriteStatus(tmp);
return NPERR_NO_ERROR;
}
@@ -622,8 +632,8 @@
// Grab control of the display
lockGL();
- setGL();
lockX();
+ setGL();
printf("%s: Initializing OpenGL...\n", __PRETTY_FUNCTION__);
@@ -646,6 +656,7 @@
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
// Release control of the display
+ unsetGL();
freeX();
freeGL();
}
@@ -664,15 +675,17 @@
if (gxDisplay && mContext) {
// Grab control of the display
lockGL();
- setGL();
lockX();
+ setGL();
- printf("%s: Destroying GLX Context...\n", __PRETTY_FUNCTION__);
+ printf("%s: Destroying GLX Context %p...\n", __PRETTY_FUNCTION__,
+ mContext);
glXDestroyContext(gxDisplay, mContext);
_glInitialized = FALSE;
mContext = NULL;
// Release control of the display
+ unsetGL();
freeX();
freeGL();
}
@@ -692,8 +705,8 @@
// Grab control of the display
lockGL();
- setGL();
lockX();
+ setGL();
printf("%s: Resizing window...\n", __PRETTY_FUNCTION__);
@@ -724,6 +737,7 @@
// glLoadIdentity();
// Release control of the display
+ unsetGL();
freeX();
freeGL();
@@ -737,12 +751,12 @@
void
nsPluginInstance::drawTestScene( void )
{
- printf("%s: \n", __PRETTY_FUNCTION__);
+ printf("%s: for instance %p\n", __PRETTY_FUNCTION__, this);
// Grab control of the display
lockGL();
- setGL();
lockX();
+ setGL();
printf("%s: Drawing graphic...\n", __PRETTY_FUNCTION__);
@@ -772,7 +786,9 @@
glEnd( ); // Done Drawing The Quad
swapBuffers();
+
// Release control of the display
+ unsetGL();
freeX();
freeGL();
}
Index: gnash/plugin/plugin.h
diff -u gnash/plugin/plugin.h:1.6 gnash/plugin/plugin.h:1.7
--- gnash/plugin/plugin.h:1.6 Sat Feb 25 05:19:16 2006
+++ gnash/plugin/plugin.h Thu Mar 2 21:21:55 2006
@@ -66,7 +66,7 @@
// accessors
const char *getVersion();
Window getWindow() { return mWindow; };
-// Display *getDisplay() { return gxDisplay; };
+ Display *getDisplay() { return gxDisplay; };
unsigned int getDepth() { return mDepth; };
int getWidth() { return mWidth; };
int getHeight() { return mHeight; };
@@ -74,35 +74,42 @@
// Set the current GL context
void setGL() {
-// printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
- glXMakeCurrent(gxDisplay, mWindow, mContext);
+ printf("%s: Entering gxDisplay = %p, mWindow = %p, mContext = %p\n",
+ __PRETTY_FUNCTION__, gxDisplay, (void *)mWindow, (void
*)mContext);
+ if (mContext) {
+ glXMakeCurrent(gxDisplay, mWindow, mContext);
+ }
+ }
+ void unsetGL() {
+ printf("%s: Entering, this is %p\n", __PRETTY_FUNCTION__, this);
+ glXMakeCurrent(gxDisplay, None, NULL);
}
// Protect the GL state from multiple threads
void lockGL() {
-// printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+ printf("%s: Entering, this is %p\n", __PRETTY_FUNCTION__, this);
SDL_mutexP(glMutex);
}
void freeGL() {
-// printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+ printf("%s: Entering, this is %p\n", __PRETTY_FUNCTION__, this);
SDL_mutexV(glMutex);
}
// Protect the X context
void lockX() {
-// printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+ printf("%s: Entering, this is %p\n", __PRETTY_FUNCTION__, this);
XLockDisplay(gxDisplay);
}
void freeX() {
-// printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+ printf("%s: Entering, this is %p\n", __PRETTY_FUNCTION__, this);
XUnlockDisplay(gxDisplay);
}
void swapBuffers() {
-// printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+ printf("%s: Entering, this is %p\n", __PRETTY_FUNCTION__, this);
glXSwapBuffers(gxDisplay, mWindow);
}
void drawTestScene();
- bool getShutting() { return bShutting; }
+ bool getShutting() { return bShutting; }
void initGL();
void destroyContext();
@@ -126,6 +133,7 @@
SDL_Thread *mThread;
GLXContext mContext;
Window mWindow;
+// Display *_xdisplay;
int _streamfd;
NPBool _glInitialized;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ./ChangeLog plugin/player.cpp plugin/play...,
Rob Savoye <=