summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Freitas <miguelfreitas@users.sourceforge.net>2003-04-16 11:30:13 +0000
committerMiguel Freitas <miguelfreitas@users.sourceforge.net>2003-04-16 11:30:13 +0000
commit0f0934859de929f191b0b0a6c58fb8fd3c5c6c67 (patch)
tree0fc9c36cee9021d3d720b7de037172c8cac9900f
parenta422e816b62c4e26047d0d781acae3c0a402c339 (diff)
downloadxine-lib-0f0934859de929f191b0b0a6c58fb8fd3c5c6c67.tar.gz
xine-lib-0f0934859de929f191b0b0a6c58fb8fd3c5c6c67.tar.bz2
die completion events, die die die
i fell stupid: how didn't i realized before that handling completion events was not needed? the only trick is to call XSync after drawing! this not only improves smoothness and schedulability issues but also moves the frame dropping to video_out.c were they can be accounted properly. not to mention it makes frontend programming a lot easier. CVS patchset: 4621 CVS date: 2003/04/16 11:30:13
-rw-r--r--src/video_out/video_out_xshm.c146
-rw-r--r--src/video_out/video_out_xv.c153
2 files changed, 94 insertions, 205 deletions
diff --git a/src/video_out/video_out_xshm.c b/src/video_out/video_out_xshm.c
index c3c7dff07..9775e641d 100644
--- a/src/video_out/video_out_xshm.c
+++ b/src/video_out/video_out_xshm.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: video_out_xshm.c,v 1.108 2003/03/06 16:49:32 guenter Exp $
+ * $Id: video_out_xshm.c,v 1.109 2003/04/16 11:30:13 miguelfreitas Exp $
*
* video_out_xshm.c, X11 shared memory extension interface for xine
*
@@ -60,10 +60,6 @@
#include "xineutils.h"
#include "vo_scale.h"
-#ifndef XShmGetEventBase
-extern int XShmGetEventBase(Display *);
-#endif
-
/*
#define LOG
*/
@@ -115,10 +111,7 @@ typedef struct xshm_driver_s {
vo_scale_t sc;
- int expecting_event; /* completion event */
- int completion_event;
-
- xshm_frame_t *cur_frame; /* for completion event handling */
+ xshm_frame_t *cur_frame;
vo_overlay_t *overlay;
int (*x11_old_error_handler) (Display *, XErrorEvent *);
@@ -715,98 +708,67 @@ static void xshm_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) {
printf ("video_out_xshm: display frame...\n");
#endif
- if (this->expecting_event) {
- XEvent event;
- int received;
-
- /*
- * fallback mechanism: try to get the event directly in case frontend has
- * not forwarded it to us (yet).
- */
- XLockDisplay (this->display);
- received = XCheckTypedEvent(this->display, this->completion_event, &event);
- XUnlockDisplay (this->display);
-
- if(received)
- this->expecting_event = 0;
- }
-
- if (this->expecting_event) {
-#ifdef LOG
- printf ("video_out_xshm: display frame...expecting event (%d)\n",
- this->expecting_event);
-#endif
- this->expecting_event--;
- frame->vo_frame.displayed (&frame->vo_frame);
- } else {
-
#ifdef LOG
- printf ("video_out_xshm: about to draw frame %d x %d...\n",
- frame->sc.output_width, frame->sc.output_height);
+ printf ("video_out_xshm: about to draw frame %d x %d...\n",
+ frame->sc.output_width, frame->sc.output_height);
#endif
- /*
- * tell gui that we are about to display a frame,
- * ask for offset
- */
+ /*
+ * tell gui that we are about to display a frame,
+ * ask for offset
+ */
- this->sc.delivered_height = frame->sc.delivered_height;
- this->sc.delivered_width = frame->sc.delivered_width;
- this->sc.video_pixel_aspect = frame->sc.video_pixel_aspect;
- if( vo_scale_redraw_needed( &this->sc ) ) {
+ this->sc.delivered_height = frame->sc.delivered_height;
+ this->sc.delivered_width = frame->sc.delivered_width;
+ this->sc.video_pixel_aspect = frame->sc.video_pixel_aspect;
+ if( vo_scale_redraw_needed( &this->sc ) ) {
- clean_output_area (this, frame);
- }
+ clean_output_area (this, frame);
+ }
- if (this->cur_frame) {
+ if (this->cur_frame) {
- if ( (this->cur_frame->sc.output_width != frame->sc.output_width)
- || (this->cur_frame->sc.output_height != frame->sc.output_height)
- || (this->cur_frame->sc.output_xoffset != frame->sc.output_xoffset)
- || (this->cur_frame->sc.output_yoffset != frame->sc.output_yoffset) )
- clean_output_area (this, frame);
+ if ( (this->cur_frame->sc.output_width != frame->sc.output_width)
+ || (this->cur_frame->sc.output_height != frame->sc.output_height)
+ || (this->cur_frame->sc.output_xoffset != frame->sc.output_xoffset)
+ || (this->cur_frame->sc.output_yoffset != frame->sc.output_yoffset) )
+ clean_output_area (this, frame);
- this->cur_frame->vo_frame.displayed (&this->cur_frame->vo_frame);
- }
+ this->cur_frame->vo_frame.displayed (&this->cur_frame->vo_frame);
+ }
- this->cur_frame = frame;
+ this->cur_frame = frame;
- XLockDisplay (this->display);
+ XLockDisplay (this->display);
#ifdef LOG
- printf ("video_out_xshm: display locked...\n");
+ printf ("video_out_xshm: display locked...\n");
#endif
- if (this->use_shm) {
+ if (this->use_shm) {
#ifdef LOG
- printf ("video_out_xshm: put image (shm)\n");
+ printf ("video_out_xshm: put image (shm)\n");
#endif
- XShmPutImage(this->display,
- this->drawable, this->gc, frame->image,
- 0, 0, frame->sc.output_xoffset, frame->sc.output_yoffset,
- frame->sc.output_width, frame->sc.output_height, True);
+ XShmPutImage(this->display,
+ this->drawable, this->gc, frame->image,
+ 0, 0, frame->sc.output_xoffset, frame->sc.output_yoffset,
+ frame->sc.output_width, frame->sc.output_height, True);
- this->expecting_event = 10;
-
- XFlush(this->display);
-
- } else {
+ } else {
#ifdef LOG
- printf ("video_out_xshm: put image (plain/remote)\n");
+ printf ("video_out_xshm: put image (plain/remote)\n");
#endif
- XPutImage(this->display,
- this->drawable, this->gc, frame->image,
- 0, 0, frame->sc.output_xoffset, frame->sc.output_yoffset,
- frame->sc.output_width, frame->sc.output_height);
-
- XFlush(this->display);
- }
-
- XUnlockDisplay (this->display);
+ XPutImage(this->display,
+ this->drawable, this->gc, frame->image,
+ 0, 0, frame->sc.output_xoffset, frame->sc.output_yoffset,
+ frame->sc.output_width, frame->sc.output_height);
}
+ XSync(this->display, False);
+
+ XUnlockDisplay (this->display);
#ifdef LOG
printf ("video_out_xshm: display frame done\n");
@@ -913,27 +875,11 @@ static int xshm_gui_data_exchange (vo_driver_t *this_gen,
xshm_driver_t *this = (xshm_driver_t *) this_gen;
switch (data_type) {
- case XINE_GUI_SEND_COMPLETION_EVENT: {
-
- XShmCompletionEvent *cev = (XShmCompletionEvent *) data;
-
- if (cev->drawable == this->drawable) {
- this->expecting_event = 0;
-
- /*
- if (this->cur_frame) {
- this->cur_frame->vo_frame.displayed (&this->cur_frame->vo_frame);
- this->cur_frame = NULL;
- }
- */
- }
-
- }
- break;
+ case XINE_GUI_SEND_COMPLETION_EVENT:
+ break;
case XINE_GUI_SEND_EXPOSE_EVENT:
- /* FIXME : take care of completion events */
#ifdef LOG
printf ("video_out_xshm: expose event\n");
#endif
@@ -972,7 +918,7 @@ static int xshm_gui_data_exchange (vo_driver_t *this_gen,
this->sc.border[i].w, this->sc.border[i].h);
}
- XFlush (this->display);
+ XSync(this->display, False);
XUnlockDisplay (this->display);
}
@@ -1132,7 +1078,6 @@ static vo_driver_t *xshm_open_plugin (video_driver_class_t *class_gen, const voi
_("disable all video scaling (faster!)"),
NULL, 10, NULL, NULL);
this->drawable = visual->d;
- this->expecting_event = 0;
this->cur_frame = NULL;
this->gc = XCreateGC (this->display, this->drawable,
0, NULL);
@@ -1204,11 +1149,6 @@ static vo_driver_t *xshm_open_plugin (video_driver_class_t *class_gen, const voi
myimage = create_ximage (this, &myshminfo, 100, 100);
dispose_ximage (this, &myshminfo, myimage);
- if(this->use_shm)
- this->completion_event = XShmGetEventBase(display) + ShmCompletion;
- else
- this->completion_event = -1;
-
/*
* Is the same byte order in use on the X11 client and server?
*/
diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c
index 7c0a37e8d..27f5d75d1 100644
--- a/src/video_out/video_out_xv.c
+++ b/src/video_out/video_out_xv.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: video_out_xv.c,v 1.162 2003/03/18 23:41:48 hadess Exp $
+ * $Id: video_out_xv.c,v 1.163 2003/04/16 11:30:17 miguelfreitas Exp $
*
* video_out_xv.c, X11 video extension interface for xine
*
@@ -66,10 +66,6 @@
#include "xineutils.h"
#include "vo_scale.h"
-#ifndef XShmGetEventBase
-extern int XShmGetEventBase(Display *);
-#endif
-
/*
#define LOG
*/
@@ -115,8 +111,7 @@ struct xv_driver_s {
GC gc;
XvPortID xv_port;
XColor black;
- int expecting_event; /* completion event handling */
- int completion_event;
+
int use_shm;
int use_pitch_alignment;
xv_property_t props[VO_NUM_PROPERTIES];
@@ -690,95 +685,66 @@ static void xv_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) {
printf ("video_out_xv: xv_display_frame...\n");
*/
- if (this->expecting_event) {
- XEvent event;
- int received;
-
- /*
- * fallback mechanism: try to get the event directly in case frontend has
- * not forwarded it to us (yet).
- */
- XLockDisplay (this->display);
- received = XCheckTypedEvent(this->display, this->completion_event, &event);
- XUnlockDisplay (this->display);
-
- if(received)
- this->expecting_event = 0;
- }
-
- if (this->expecting_event) {
-
- frame->vo_frame.displayed (&frame->vo_frame);
- this->expecting_event--;
-#ifdef LOG
- printf ("video_out_xv: xv_display_frame... not displayed, waiting for completion event\n");
-#endif
- } else {
-
- /*
- * queue frames (deinterlacing)
- * free old frames
- */
-
- xv_add_recent_frame (this, frame); /* deinterlacing */
-
- this->cur_frame = frame;
+ /*
+ * queue frames (deinterlacing)
+ * free old frames
+ */
+ xv_add_recent_frame (this, frame); /* deinterlacing */
+ this->cur_frame = frame;
- /*
- * let's see if this frame is different in size / aspect
- * ratio from the previous one
- */
- if ( (frame->width != this->sc.delivered_width)
- || (frame->height != this->sc.delivered_height)
- || (frame->ratio_code != this->sc.delivered_ratio_code) ) {
+ /*
+ * let's see if this frame is different in size / aspect
+ * ratio from the previous one
+ */
+ if ( (frame->width != this->sc.delivered_width)
+ || (frame->height != this->sc.delivered_height)
+ || (frame->ratio_code != this->sc.delivered_ratio_code) ) {
#ifdef LOG
- printf("video_out_xv: frame format changed\n");
+ printf("video_out_xv: frame format changed\n");
#endif
- this->sc.force_redraw = 1; /* trigger re-calc of output size */
- }
+ this->sc.force_redraw = 1; /* trigger re-calc of output size */
+ }
- /*
- * deinterlace frame if necessary
- * (currently only working for YUV images)
- */
+ /*
+ * deinterlace frame if necessary
+ * (currently only working for YUV images)
+ */
- if (this->deinterlace_enabled && this->deinterlace_method
- && frame->format == XINE_IMGFMT_YV12)
- xv_deinterlace_frame (this);
+ if (this->deinterlace_enabled && this->deinterlace_method
+ && frame->format == XINE_IMGFMT_YV12)
+ xv_deinterlace_frame (this);
- /*
- * tell gui that we are about to display a frame,
- * ask for offset and output size
- */
- xv_redraw_needed (this_gen);
+ /*
+ * tell gui that we are about to display a frame,
+ * ask for offset and output size
+ */
+ xv_redraw_needed (this_gen);
- XLockDisplay (this->display);
+ XLockDisplay (this->display);
- if (this->use_shm) {
- XvShmPutImage(this->display, this->xv_port,
- this->drawable, this->gc, this->cur_frame->image,
- this->sc.displayed_xoffset, this->sc.displayed_yoffset,
- this->sc.displayed_width, this->sc.displayed_height,
- this->sc.output_xoffset, this->sc.output_yoffset,
- this->sc.output_width, this->sc.output_height, True);
+ if (this->use_shm) {
+ XvShmPutImage(this->display, this->xv_port,
+ this->drawable, this->gc, this->cur_frame->image,
+ this->sc.displayed_xoffset, this->sc.displayed_yoffset,
+ this->sc.displayed_width, this->sc.displayed_height,
+ this->sc.output_xoffset, this->sc.output_yoffset,
+ this->sc.output_width, this->sc.output_height, True);
- this->expecting_event = 10;
- } else {
- XvPutImage(this->display, this->xv_port,
- this->drawable, this->gc, this->cur_frame->image,
- this->sc.displayed_xoffset, this->sc.displayed_yoffset,
- this->sc.displayed_width, this->sc.displayed_height,
- this->sc.output_xoffset, this->sc.output_yoffset,
- this->sc.output_width, this->sc.output_height);
- }
+ } else {
+ XvPutImage(this->display, this->xv_port,
+ this->drawable, this->gc, this->cur_frame->image,
+ this->sc.displayed_xoffset, this->sc.displayed_yoffset,
+ this->sc.displayed_width, this->sc.displayed_height,
+ this->sc.output_xoffset, this->sc.output_yoffset,
+ this->sc.output_width, this->sc.output_height);
+ }
- XFlush(this->display);
+ XSync(this->display, False);
- XUnlockDisplay (this->display);
+ XUnlockDisplay (this->display);
- }
/*
printf ("video_out_xv: xv_display_frame... done\n");
*/
@@ -909,24 +875,13 @@ static int xv_gui_data_exchange (vo_driver_t *this_gen,
xv_driver_t *this = (xv_driver_t *) this_gen;
switch (data_type) {
- case XINE_GUI_SEND_COMPLETION_EVENT: {
-
- XShmCompletionEvent *cev = (XShmCompletionEvent *) data;
-
- if (cev->drawable == this->drawable) {
- this->expecting_event = 0;
-
- }
-
- }
- break;
+ case XINE_GUI_SEND_COMPLETION_EVENT:
+ break;
case XINE_GUI_SEND_EXPOSE_EVENT: {
/* XExposeEvent * xev = (XExposeEvent *) data; */
- /* FIXME : take care of completion events */
-
if (this->cur_frame) {
int i;
@@ -957,7 +912,7 @@ static int xv_gui_data_exchange (vo_driver_t *this_gen,
this->sc.border[i].w, this->sc.border[i].h);
}
- XFlush(this->display);
+ XSync(this->display, False);
XUnlockDisplay (this->display);
}
@@ -1201,7 +1156,6 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi
this->gc = XCreateGC (this->display, this->drawable, 0, NULL);
XUnlockDisplay (this->display);
this->capabilities = 0;
- this->expecting_event = 0;
this->use_shm = 1;
this->deinterlace_method = 0;
this->deinterlace_frame.image = NULL;
@@ -1357,11 +1311,6 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi
(this->xv_format_yv12 != 0) ? XINE_IMGFMT_YV12 : XINE_IMGFMT_YUY2);
dispose_ximage (this, &myshminfo, myimage);
- if(this->use_shm)
- this->completion_event = XShmGetEventBase(display) + ShmCompletion;
- else
- this->completion_event = -1;
-
XUnlockDisplay (this->display);
this->use_pitch_alignment = config->register_bool (config, "video.xv_pitch_alignment", 0,