From: Claudio C. <kl...@us...> - 2006-11-23 16:38:57
|
Update of /cvsroot/xine/xine-plugin/src In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv11883 Modified Files: plugin.c Log Message: Avoid calling XInitThreads and use the new x11 visual instead. Calling XInitThreads from the plugin is a bit buggy because XInitThreads should be called before other Xlib functions. Index: plugin.c =================================================================== RCS file: /cvsroot/xine/xine-plugin/src/plugin.c,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- plugin.c 19 Nov 2006 11:46:49 -0000 1.40 +++ plugin.c 23 Nov 2006 16:38:42 -0000 1.41 @@ -108,11 +108,11 @@ /*****************************************************************************/ -static void -dest_size_cb (void *data, - int video_width, int video_height, - double video_pixel_aspect, - int *dest_width, int *dest_height, double *dest_pixel_aspect) +static void dest_size_cb (void *data, + int video_width, int video_height, + double video_pixel_aspect, + int *dest_width, int *dest_height, + double *dest_pixel_aspect) { xine_plugin_t *this = data; @@ -121,13 +121,12 @@ *dest_pixel_aspect = video_pixel_aspect ? : 1.0; } -static void -frame_output_cb (void *data, - int video_width, int video_height, - double video_pixel_aspect, - int *dest_x, int *dest_y, - int *dest_width, int *dest_height, - double *dest_pixel_aspect, int *win_x, int *win_y) +static void frame_output_cb (void *data, + int video_width, int video_height, + double video_pixel_aspect, + int *dest_x, int *dest_y, + int *dest_width, int *dest_height, + double *dest_pixel_aspect, int *win_x, int *win_y) { xine_plugin_t *this = data; @@ -140,6 +139,24 @@ *dest_pixel_aspect = video_pixel_aspect ? : 1.0; } +#ifdef XINE_VISUAL_TYPE_X11_2 +static void lock_display_cb (void *data) +{ + xine_plugin_t *this = data; + + pthread_mutex_lock (&this->mutex); + XLockDisplay (this->display); +} + +static void unlock_display_cb (void *data) +{ + xine_plugin_t *this = data; + + XUnlockDisplay (this->display); + pthread_mutex_unlock (&this->mutex); +} +#endif + /*****************************************************************************/ static void osd_show_text (xine_plugin_t *this, const char *text) { @@ -279,9 +296,8 @@ switch (key) { case XK_Escape: osd_show_text (this, OSD_TEXT_QUIT); - xine_stop (this->stream); - xine_close (this->stream); - return (void *) 0; + this->playing = 0; + break; case XK_Return: if (xine_get_status (this->stream) == XINE_STATUS_PLAY) { xine_stop (this->stream); @@ -588,17 +604,23 @@ visual.screen = this->screen; visual.d = this->window; + visual.user_data = this; visual.dest_size_cb = dest_size_cb; visual.frame_output_cb = frame_output_cb; - visual.user_data = this; + +#ifdef XINE_VISUAL_TYPE_X11_2 + visual.lock_display = lock_display_cb; + visual.unlock_display = unlock_display_cb; this->vo_driver = xine_open_video_driver (this->xine, driver, - XINE_VISUAL_TYPE_X11, - &visual); + XINE_VISUAL_TYPE_X11_2, &visual); +#else + this->vo_driver = xine_open_video_driver (this->xine, driver, + XINE_VISUAL_TYPE_X11, &visual); +#endif } else { this->vo_driver = xine_open_video_driver (this->xine, "none", - XINE_VISUAL_TYPE_NONE, - NULL); + XINE_VISUAL_TYPE_NONE, NULL); } if (!this->vo_driver) { @@ -713,10 +735,13 @@ NPError NPP_Initialize (void) { log ("NPP_Initialize()"); + /* XInitThreads is buggy when called after other Xlib functions! */ +#ifndef XINE_VISUAL_TYPE_X11_2 if (!XInitThreads ()) { log ("XInitThreads() failed!"); return NPERR_GENERIC_ERROR; } +#endif return NPERR_NO_ERROR; } @@ -724,14 +749,15 @@ NPError NPP_New (NPMIMEType mimetype, NPP instance, uint16 mode, int16 argc, char *argn[], char *argv[], NPSavedData * saved) { - xine_plugin_t *this; - char *mrl = NULL; - int loop = 1; - char *demux; - int i; + xine_plugin_t *this; + pthread_mutexattr_t attr; + char *mrl = NULL; + int loop = 1; + char *demux; + int i; - log ("NPP_New( mimetype=%s, instance=%p, mode=%d )", - mimetype, instance, mode); + log ("NPP_New( mimetype=%s, instance=%p, mode=%d, saved=%p )", + mimetype, instance, mode, saved); if (!instance) return NPERR_INVALID_INSTANCE_ERROR; @@ -797,7 +823,10 @@ if (mrl && *mrl) this->track = playlist_insert (&this->list, mrl); - pthread_mutex_init (&this->mutex, NULL); + pthread_mutexattr_init (&attr); + pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init (&this->mutex, &attr); + pthread_mutexattr_destroy (&attr); instance->pdata = this; |