diff options
author | Guenter Bartsch <guenter@users.sourceforge.net> | 2002-02-16 23:37:55 +0000 |
---|---|---|
committer | Guenter Bartsch <guenter@users.sourceforge.net> | 2002-02-16 23:37:55 +0000 |
commit | 0af75ff223f83bac429856099c67819b2b877c70 (patch) | |
tree | 0b0eafe24e5d37c4289d49d0a5556982bf6d1ef9 | |
parent | f030f9e939d8949d43a6a4c11fc1e7c16617ca8d (diff) | |
download | xine-lib-0af75ff223f83bac429856099c67819b2b877c70.tar.gz xine-lib-0af75ff223f83bac429856099c67819b2b877c70.tar.bz2 |
bufixes from miguel freitas
CVS patchset: 1500
CVS date: 2002/02/16 23:37:55
-rw-r--r-- | src/xine-engine/metronom.c | 16 | ||||
-rw-r--r-- | src/xine-engine/video_out.c | 52 | ||||
-rw-r--r-- | src/xine-engine/video_out.h | 4 |
3 files changed, 46 insertions, 26 deletions
diff --git a/src/xine-engine/metronom.c b/src/xine-engine/metronom.c index 8dd7d81f3..c2c628c45 100644 --- a/src/xine-engine/metronom.c +++ b/src/xine-engine/metronom.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: metronom.c,v 1.53 2002/02/09 07:13:24 guenter Exp $ + * $Id: metronom.c,v 1.54 2002/02/16 23:37:55 guenter Exp $ */ #ifdef HAVE_CONFIG_H @@ -49,6 +49,7 @@ #define METRONOM_REPORT + #define METRONOM_LOG @@ -132,6 +133,8 @@ static void unixscr_start (scr_plugin_t *scr, int64_t start_vpts) { this->cur_pts = start_vpts; pthread_mutex_unlock (&this->lock); + + unixscr_set_speed (&this->scr, SPEED_NORMAL); } static int64_t unixscr_get_current (scr_plugin_t *scr) { @@ -166,9 +169,10 @@ static scr_plugin_t* unixscr_init () { this->scr.adjust = unixscr_adjust; this->scr.start = unixscr_start; this->scr.get_current = unixscr_get_current; - unixscr_set_speed (&this->scr, SPEED_NORMAL); - + pthread_mutex_init (&this->lock, NULL); + + unixscr_set_speed (&this->scr, SPEED_PAUSE); return &this->scr; } @@ -417,7 +421,8 @@ static void metronom_got_video_frame (metronom_t *this, vo_frame_t *img) { if (abs (diff) > VIDEO_DRIFT_TOLERANCE) { this->video_vpts = vpts; - this->video_wrap_offset = vpts - pts; + /* following line is useless (wrap_offset=wrap_offset) */ + /* this->video_wrap_offset = vpts - pts; */ #ifdef METRONOM_LOG printf ("metronom: video jump, wrap offset is now %lld\n", @@ -427,7 +432,8 @@ static void metronom_got_video_frame (metronom_t *this, vo_frame_t *img) { } else if (diff) { this->video_vpts -= diff / 8; /* FIXME: better heuristics ? */ - this->video_wrap_offset = vpts - pts; + /* make wrap_offset consistent with the drift correction */ + this->video_wrap_offset = this->video_vpts - pts; #ifdef METRONOM_LOG printf ("metronom: video drift, wrap offset is now %lld\n", diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c index 10a327045..ab2b53cbb 100644 --- a/src/xine-engine/video_out.c +++ b/src/xine-engine/video_out.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.c,v 1.71 2002/02/09 07:13:24 guenter Exp $ + * $Id: video_out.c,v 1.72 2002/02/16 23:37:55 guenter Exp $ * * frame allocation / queuing / scheduling / output functions */ @@ -33,6 +33,7 @@ #include <unistd.h> #include <string.h> #include <zlib.h> +#include <assert.h> #include "video_out.h" #include "metronom.h" @@ -62,6 +63,7 @@ #define VIDEO_OUT_LOG + #define NUM_FRAME_BUFFERS 15 typedef struct { @@ -130,11 +132,9 @@ static void vo_append_to_img_buf_queue (img_buf_fifo_t *queue, pthread_mutex_lock (&queue->mutex); - /* img already enqueue? (serious leak) - if( img->next ) - *(char *)0=0; - */ - + /* img already enqueue? (serious leak) */ + assert (img->next==NULL); + img->next = NULL; if (!queue->first) { @@ -270,7 +270,7 @@ static int vo_frame_draw (vo_frame_t *img) { #ifdef VIDEO_OUT_LOG printf ("video_out: got image at master vpts %lld. vpts for picture is %lld (pts was %lld)\n", - cur_vpts, pic_vpts, pic_vpts); + cur_vpts, pic_vpts, img->pts); #endif this->num_frames_delivered++; @@ -509,7 +509,7 @@ static vo_frame_t *get_next_frame (vos_t *this, int64_t cur_vpts) { do { this->metronom->got_video_frame(this->metronom, img); - } while (img->vpts < cur_vpts); + } while (img->vpts < (cur_vpts - img->duration/2) ); return img; @@ -536,7 +536,7 @@ static vo_frame_t *get_next_frame (vos_t *this, int64_t cur_vpts) { #endif if (diff < 0) { - return 0; + return NULL; } if (this->img_backup) { @@ -617,7 +617,7 @@ static void *video_out_loop (void *this_gen) { int64_t vpts, diff; vo_frame_t *img; vos_t *this = (vos_t *) this_gen; - int64_t frame_duration, next_frame_pts; + int64_t frame_duration, next_frame_vpts; int64_t usec_to_sleep; /* @@ -626,7 +626,7 @@ static void *video_out_loop (void *this_gen) { */ frame_duration = 1500; /* default */ - next_frame_pts = 0; + next_frame_vpts = this->metronom->get_current_time (this->metronom); #ifdef VIDEO_OUT_LOG printf ("video_out: loop starting...\n"); @@ -655,40 +655,54 @@ static void *video_out_loop (void *this_gen) { /* * if we haven't heared from the decoder for some time * flush it + * test display fifo empty to protect from deadlocks */ diff = vpts - this->last_delivery_pts; - if (diff > 30000) { + if (diff > 30000 && !this->display_img_buf_queue->first) { if (this->xine->cur_video_decoder_plugin) { this->xine->cur_video_decoder_plugin->flush(this->xine->cur_video_decoder_plugin); #ifdef VIDEO_OUT_LOG printf ("video_out: flushing current video decoder plugin\n"); #endif - } + this->last_delivery_pts = vpts; } /* * wait until it's time to display next frame */ - if (img) + if (img) { frame_duration = img->duration; - - next_frame_pts += frame_duration; - + next_frame_vpts = img->vpts + img->duration; + } else { + next_frame_vpts += frame_duration; + } + #ifdef VIDEO_OUT_LOG - printf ("video_out: next_frame_pts is %lld\n", next_frame_pts); + printf ("video_out: next_frame_vpts is %lld\n", next_frame_vpts); #endif do { vpts = this->metronom->get_current_time (this->metronom); - usec_to_sleep = (next_frame_pts - vpts) * 100 / 9; + usec_to_sleep = (next_frame_vpts - vpts) * 100 / 9; +#ifdef VIDEO_OUT_LOG printf ("video_out: %lld usec to sleep at master vpts %lld\n", usec_to_sleep, vpts); +#endif + + /* + if( usec_to_sleep > 1000000 ) + { + printf ("video_out: master clock changed\n"); + next_frame_vpts = vpts; + usec_to_sleep = 0; + } + */ if (usec_to_sleep>0) xine_usec_sleep (usec_to_sleep); diff --git a/src/xine-engine/video_out.h b/src/xine-engine/video_out.h index 4a7f28644..0539b9bc3 100644 --- a/src/xine-engine/video_out.h +++ b/src/xine-engine/video_out.h @@ -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.h,v 1.41 2002/02/16 22:43:24 guenter Exp $ + * $Id: video_out.h,v 1.42 2002/02/16 23:37:55 guenter Exp $ * * * xine version of video_out.h @@ -91,7 +91,7 @@ struct vo_frame_s { /* additional information to be able to duplicate frames: */ int width, height; int ratio; /* aspect ratio, codes see below */ - int format; /* IMGFMT_YV12 or IMGFMT_RGB */ + int format; /* IMGFMT_YV12 or IMGFMT_YUY2 */ int drawn; /* used by decoder, frame has already been drawn */ |