--- xine-lib/src/xine-engine/post.c 2006-01-27 08:46:15.000000000 +0100 +++ xine-lib-vdr.2006-10-08/src/xine-engine/post.c 2006-10-08 21:12:30.000000000 +0200 @@ -149,6 +149,14 @@ if (port->port_lock) pthread_mutex_unlock(port->port_lock); } +static void post_video_trigger_drawing(xine_video_port_t *port_gen) { + post_video_port_t *port = (post_video_port_t *)port_gen; + + if (port->port_lock) pthread_mutex_lock(port->port_lock); + port->original_port->trigger_drawing(port->original_port); + if (port->port_lock) pthread_mutex_unlock(port->port_lock); +} + static int post_video_status(xine_video_port_t *port_gen, xine_stream_t *stream, int *width, int *height, int64_t *img_duration) { post_video_port_t *port = (post_video_port_t *)port_gen; @@ -223,6 +231,7 @@ port->new_port.exit = post_video_exit; port->new_port.get_overlay_manager = post_video_get_overlay_manager; port->new_port.flush = post_video_flush; + port->new_port.trigger_drawing = post_video_trigger_drawing; port->new_port.status = post_video_status; port->new_port.get_property = post_video_get_property; port->new_port.set_property = post_video_set_property; --- xine-lib/src/xine-engine/video_out.c 2006-03-25 02:26:34.000000000 +0100 +++ xine-lib-vdr.2006-10-08/src/xine-engine/video_out.c 2006-10-08 21:12:30.000000000 +0200 @@ -127,6 +127,9 @@ int frame_drop_limit; int frame_drop_cpt; int crop_left, crop_right, crop_top, crop_bottom; + + pthread_mutex_t trigger_drawing_mutex; + pthread_cond_t trigger_drawing; } vos_t; @@ -1039,6 +1042,24 @@ this->redraw_needed = 1; } +static int interruptable_sleep(vos_t *this, int usec_to_sleep) +{ + struct timespec abstime; + + struct timeval now; + gettimeofday(&now, 0); + + abstime.tv_sec = now.tv_sec + usec_to_sleep / 1000000; + abstime.tv_nsec = now.tv_usec * 1000 + (usec_to_sleep % 1000000) * 1000; + + if (abstime.tv_nsec > 1000000000) { + abstime.tv_nsec -= 1000000000; + abstime.tv_sec++; + } + + return pthread_cond_timedwait(&this->trigger_drawing, &this->trigger_drawing_mutex, &abstime); +} + /* special loop for paused mode * needed to update screen due overlay changes, resize, window * movement, brightness adjusting etc. @@ -1084,7 +1105,7 @@ } pthread_mutex_unlock( &this->free_img_buf_queue->mutex ); - xine_usec_sleep (20000); + interruptable_sleep(this, 20000); pthread_mutex_lock( &this->free_img_buf_queue->mutex ); } @@ -1112,6 +1133,8 @@ nice(-2); #endif /* WIN32 */ + pthread_mutex_lock(&this->trigger_drawing_mutex); + /* * here it is - the heart of xine (or rather: one of the hearts * of xine) : the video output loop @@ -1214,7 +1237,10 @@ "video_out: vpts/clock error, next_vpts=%" PRId64 " cur_vpts=%" PRId64 "\n", next_frame_vpts,vpts); if (usec_to_sleep > 0) - xine_usec_sleep (usec_to_sleep); + { + if (0 == interruptable_sleep(this, usec_to_sleep)) + break; + } if (this->discard_frames) break; @@ -1222,6 +1248,8 @@ } while ( (usec_to_sleep > 0) && this->video_loop_running); } + pthread_mutex_unlock(&this->trigger_drawing_mutex); + /* * throw away undisplayed frames */ @@ -1597,6 +1625,9 @@ free (this->free_img_buf_queue); free (this->display_img_buf_queue); + pthread_cond_destroy(&this->trigger_drawing); + pthread_mutex_destroy(&this->trigger_drawing_mutex); + free (this); } @@ -1666,6 +1697,14 @@ } } +static void vo_trigger_drawing (xine_video_port_t *this_gen) { + vos_t *this = (vos_t *) this_gen; + + pthread_mutex_lock (&this->trigger_drawing_mutex); + pthread_cond_signal (&this->trigger_drawing); + pthread_mutex_unlock (&this->trigger_drawing_mutex); +} + /* crop_frame() will allocate a new frame to copy in the given image * while cropping. maybe someday this will be an automatic post plugin. */ @@ -1761,6 +1800,7 @@ this->vo.enable_ovl = vo_enable_overlay; this->vo.get_overlay_manager = vo_get_overlay_manager; this->vo.flush = vo_flush; + this->vo.trigger_drawing = vo_trigger_drawing; this->vo.get_property = vo_get_property; this->vo.set_property = vo_set_property; this->vo.status = vo_status; @@ -1780,6 +1820,9 @@ this->overlay_source->init (this->overlay_source); this->overlay_enabled = 1; + pthread_mutex_init(&this->trigger_drawing_mutex, NULL); + pthread_cond_init(&this->trigger_drawing, NULL); + this->frame_drop_limit = 3; this->frame_drop_cpt = 0; --- xine-lib/src/xine-engine/video_out.h 2006-09-26 07:19:49.000000000 +0200 +++ xine-lib-vdr.2006-10-08/src/xine-engine/video_out.h 2006-10-08 21:12:30.000000000 +0200 @@ -205,6 +205,9 @@ /* flush video_out fifo */ void (*flush) (xine_video_port_t *self); + /* trigger immediate drawing */ + void (*trigger_drawing) (xine_video_port_t *self); + /* Get/Set video property * * See VO_PROP_* bellow