Index: files/patch-osd__manager.c =================================================================== --- files/patch-osd__manager.c (nonexistent) +++ files/patch-osd__manager.c (working copy) @@ -0,0 +1,64 @@ +--- a/xine/osd_manager.c.orig 2012-05-11 07:37:27 UTC ++++ b/xine/osd_manager.c +@@ -11,7 +11,6 @@ + #include + #include + +-#define XINE_ENGINE_INTERNAL + #include + #include + +@@ -70,18 +69,25 @@ typedef struct osd_manager_impl_s { + /* + * acquire_ticket() + */ +-static void acquire_ticket(osd_manager_impl_t *this) ++static int acquire_ticket(osd_manager_impl_t *this) + { +- if (!this->ticket_acquired) { +- this->stream->xine->port_ticket->acquire(this->stream->xine->port_ticket, 1); ++ if (this->ticket_acquired) { ++ return 1; ++ } ++ ++ if (_x_lock_port_rewiring(this->stream->xine, 200)) { + this->ticket_acquired = 1; ++ return 1; + } ++ ++ LOGMSG("lock_port_rewiring() failed"); ++ return 0; + } + + static void release_ticket(osd_manager_impl_t *this) + { + if (this->ticket_acquired) { +- this->stream->xine->port_ticket->release(this->stream->xine->port_ticket, 1); ++ _x_unlock_port_rewiring(this->stream->xine); + this->ticket_acquired = 0; + } + } +@@ -92,7 +98,10 @@ static void release_ticket(osd_manager_impl_t *this) + video_overlay_manager_t *get_ovl_manager(osd_manager_impl_t *this) + { + /* Get overlay manager. We need ticket ... */ +- acquire_ticket(this); ++ ++ if (!acquire_ticket(this)) ++ return NULL; ++ + video_overlay_manager_t *ovl_manager = this->stream->video_out->get_overlay_manager(this->stream->video_out); + if (!ovl_manager) { + LOGMSG("Stream has no overlay manager !"); +@@ -256,7 +265,10 @@ static int exec_osd_size(osd_manager_impl_t *this, osd + osd->video_window_w = 0; + osd->video_window_h = 0; + +- acquire_ticket(this); ++ if (!acquire_ticket(this)) { ++ return CONTROL_PARAM_ERROR; ++ } ++ + + xine_video_port_t *video_out = this->stream->video_out; + Index: files/patch-xine_frontend.c =================================================================== --- files/patch-xine_frontend.c (nonexistent) +++ files/patch-xine_frontend.c (working copy) @@ -0,0 +1,108 @@ +--- a/xine_frontend.c.orig 2012-05-11 07:37:27 UTC ++++ b/xine_frontend.c +@@ -25,7 +25,6 @@ + # undef boolean + #endif + +-#define XINE_ENGINE_INTERNAL + #include + #include + +@@ -1702,13 +1701,16 @@ static vo_frame_t *yuy2_to_yv12_frame(xine_stream_t *s + { + /* convert yuy12 frames to yv12 */ + if (frame && frame->format == XINE_IMGFMT_YUY2) { +- stream->xine->port_ticket->acquire(stream->xine->port_ticket, 0); +- vo_frame_t *img = stream->video_out->get_frame (stream->video_out, +- frame->width, frame->height, +- frame->ratio, XINE_IMGFMT_YV12, +- VO_BOTH_FIELDS); +- stream->xine->port_ticket->release(stream->xine->port_ticket, 0); ++ vo_frame_t *img = NULL; + ++ if (_x_lock_port_rewiring(stream->xine, 0)) { ++ img = stream->video_out->get_frame (stream->video_out, ++ frame->width, frame->height, ++ frame->ratio, XINE_IMGFMT_YV12, ++ VO_BOTH_FIELDS); ++ _x_unlock_port_rewiring(stream->xine); ++ } ++ + if (!img) { + LOGMSG("yuy2_to_yv12_frame: get_frame failed"); + frame->free(frame); +@@ -1738,6 +1740,8 @@ static char *frame_compress_jpeg(fe_t *this, int *size + + /* convert yuy2 frames to yv12 */ + frame = yuy2_to_yv12_frame(this->stream, frame); ++ if (!frame) ++ return NULL; + + /* Compress JPEG */ + +@@ -1836,13 +1840,16 @@ static vo_frame_t *yv12_to_yuy2_frame(xine_stream_t *s + { + /* convert yv12 frames to yuy2 */ + if (frame && frame->format == XINE_IMGFMT_YV12) { +- stream->xine->port_ticket->acquire(stream->xine->port_ticket, 0); +- vo_frame_t *img = stream->video_out->get_frame (stream->video_out, +- frame->width, frame->height, +- frame->ratio, XINE_IMGFMT_YUY2, +- VO_BOTH_FIELDS); +- stream->xine->port_ticket->release(stream->xine->port_ticket, 0); ++ vo_frame_t *img = NULL; + ++ if (_x_lock_port_rewiring(stream->xine, 0)) { ++ img = stream->video_out->get_frame (stream->video_out, ++ frame->width, frame->height, ++ frame->ratio, XINE_IMGFMT_YUY2, ++ VO_BOTH_FIELDS); ++ _x_unlock_port_rewiring(stream->xine); ++ } ++ + if (!img) { + LOGMSG("yv12_to_yuy2_frame: get_frame failed"); + frame->free(frame); +@@ -2006,11 +2013,16 @@ static char *fe_grab(frontend_t *this_gen, int *size, + height = (MAX(16, MIN(height, 1200)) + 1) & ~1; /* 16...1200, even */ + + /* get last frame */ +- this->stream->xine->port_ticket->acquire(this->stream->xine->port_ticket, 0); + + #ifdef HAVE_XINE_GRAB_VIDEO_FRAME ++ xine_grab_video_frame_t *grab_frame = NULL; + char *img = NULL; +- xine_grab_video_frame_t *grab_frame = xine_new_grab_video_frame(this->stream); ++ ++ if (_x_lock_port_rewiring(this->xine, 0)) { ++ grab_frame = xine_new_grab_video_frame(this->stream); ++ _x_unlock_port_rewiring(this->xine); ++ } ++ + if (grab_frame) { + grab_frame->width = width; + grab_frame->height = height; +@@ -2018,15 +2030,18 @@ static char *fe_grab(frontend_t *this_gen, int *size, + img = fe_compress_grab_frame(this, size, jpeg, quality, width, height, grab_frame); + grab_frame->dispose(grab_frame); + } +- this->stream->xine->port_ticket->release(this->stream->xine->port_ticket, 0); + return img; + #else +- vo_frame_t *frame = this->stream->video_out->get_last_frame (this->stream->video_out); ++ vo_frame_t *frame = NULL; ++ ++ if (_x_lock_port_rewiring(this->xine, 0)) { ++ frame = this->stream->video_out->get_last_frame (this->stream->video_out); + #if XINE_VERSION_CODE < 10190 +- if(frame) +- frame->lock(frame); ++ if (frame) ++ frame->lock(frame); + #endif +- this->stream->xine->port_ticket->release(this->stream->xine->port_ticket, 0); ++ _x_unlock_port_rewiring(this->xine); ++ } + + if(!frame) { + LOGMSG("fe_grab: get_last_frame() failed"); Index: files/patch-xine_input_vdr.c =================================================================== --- files/patch-xine_input_vdr.c (nonexistent) +++ files/patch-xine_input_vdr.c (working copy) @@ -0,0 +1,283 @@ +--- xine_input_vdr.c.orig 2012-05-11 07:37:27 UTC ++++ xine_input_vdr.c +@@ -1573,9 +1573,7 @@ static void set_still_mode(vdr_input_plugin_t *this, i + if (still_mode || this->still_mode) + CHECK_FALSE(this->live_mode); + +- pthread_mutex_lock (&this->stream->first_frame_lock); +- this->stream->first_frame_flag = 2; +- pthread_mutex_unlock (&this->stream->first_frame_lock); ++ _x_trigger_relaxed_frame_drop_mode(this->stream); + + this->still_mode = !!still_mode; + _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HAS_STILL, this->still_mode); +@@ -1719,11 +1717,12 @@ static void queue_blank_yv12(vdr_input_plugin_t *this) + _x_demux_control_newpts(this->stream, 0, BUF_FLAG_SEEK); + + +- this->class->xine->port_ticket->acquire (this->class->xine->port_ticket, 1); +- img = this->stream->video_out->get_frame (this->stream->video_out, +- width, height, dratio, +- XINE_IMGFMT_YV12, VO_BOTH_FIELDS); +- this->class->xine->port_ticket->release (this->class->xine->port_ticket, 1); ++ if (_x_lock_port_rewiring(this->class->xine, 100)) { ++ img = this->stream->video_out->get_frame (this->stream->video_out, ++ width, height, dratio, ++ XINE_IMGFMT_YV12, VO_BOTH_FIELDS); ++ _x_unlock_port_rewiring(this->class->xine); ++ } + + if (img) { + if (img->format == XINE_IMGFMT_YV12 && img->base[0] && img->base[1] && img->base[2]) { +@@ -1977,88 +1976,6 @@ static int vdr_plugin_exec_osd_command(vdr_input_plugi + + /******************************* Control *********************************/ + +-#if XINE_VERSION_CODE < 10111 +-# define DEMUX_MUTEX_LOCK +-# define DEMUX_MUTEX_UNLOCK +-# define DEMUX_RESUME_SIGNAL +-#else +-# define DEMUX_MUTEX_LOCK pthread_mutex_lock(&stream->demux_mutex) +-# define DEMUX_MUTEX_UNLOCK pthread_mutex_unlock(&stream->demux_mutex) +-# define DEMUX_RESUME_SIGNAL pthread_cond_signal(&this->stream->demux_resume) +-#endif +- +-#if XINE_VERSION_CODE < 10200 +-# define RAISE_ACTION_PENDING this->stream->demux_action_pending = 1 +-# define LOWER_ACTION_PENDING this->stream->demux_action_pending = 0 +-#else +-# define RAISE_ACTION_PENDING _x_action_raise(this->stream) +-# define LOWER_ACTION_PENDING _x_action_lower(this->stream) +-#endif +- +-static void suspend_demuxer(vdr_input_plugin_t *this) +-{ +- if (this->is_paused) +- LOGMSG("WARNING: called suspend_demuxer in paused mode !"); +- +- /* request demuxer to release demux_lock */ +- RAISE_ACTION_PENDING; +- +- /* signal all possible sync points to speed up this */ +- pthread_cond_broadcast(&this->engine_flushed); +- signal_buffer_not_empty(this); +- +- /* let demuxer return from vdr_plugin_read_* */ +- if (pthread_mutex_unlock( &this->lock )) +- LOGERR("pthread_mutex_unlock failed !"); +- +- /* lock demuxer */ +- pthread_mutex_lock( &this->stream->demux_lock ); +- +- LOWER_ACTION_PENDING; +- +- pthread_mutex_lock( &this->lock ); +- +- /* must be paired with resume_demuxer !!! */ +-} +- +-static void resume_demuxer(vdr_input_plugin_t *this) +-{ +- /* must be paired with suspend_demuxer !!! */ +- +- DEMUX_RESUME_SIGNAL; +- pthread_mutex_unlock( &this->stream->demux_lock ); +-} +- +-static void vdr_x_demux_control_newpts( xine_stream_t *stream, int64_t pts, +- uint32_t flags ) +-{ +- buf_element_t *buf; +- +- DEMUX_MUTEX_LOCK; +- +- buf = stream->video_fifo ? stream->video_fifo->buffer_pool_try_alloc (stream->video_fifo) : NULL; +- if(buf) { +- buf->type = BUF_CONTROL_NEWPTS; +- buf->decoder_flags = flags; +- buf->disc_off = pts; +- stream->video_fifo->put (stream->video_fifo, buf); +- } else { +- LOGMSG("vdr_x_demux_control_newpts: video fifo full !"); +- } +- +- buf = stream->audio_fifo ? stream->audio_fifo->buffer_pool_try_alloc (stream->audio_fifo) : NULL; +- if (buf) { +- buf->type = BUF_CONTROL_NEWPTS; +- buf->decoder_flags = flags; +- buf->disc_off = pts; +- stream->audio_fifo->put (stream->audio_fifo, buf); +- } else { +- LOGMSG("vdr_x_demux_control_newpts: audio fifo full !"); +- } +- +- DEMUX_MUTEX_UNLOCK; +-} +- + static void vdr_flush_engine(vdr_input_plugin_t *this, uint64_t discard_index) + { + CHECK_LOCKED(this->lock); +@@ -2078,44 +1995,30 @@ static void vdr_flush_engine(vdr_input_plugin_t *this, + return; + } + ++ if (this->is_paused) ++ LOGMSG("WARNING: called suspend_demuxer in paused mode !"); ++ + /* reset speed */ ++ reset_scr_tuning(this); + if(xine_get_param(this->stream, XINE_PARAM_FINE_SPEED) <= 0) { + LOGMSG("vdr_flush_engine: playback is paused <0>"); + xine_set_param(this->stream, XINE_PARAM_FINE_SPEED, XINE_FINE_SPEED_NORMAL); + } + +- /* suspend demuxer */ +- suspend_demuxer(this); ++ pthread_mutex_unlock(&this->lock); + +- reset_scr_tuning(this); ++ _x_demux_seek(this->stream, 0, 0, 1); ++ pthread_mutex_lock(&this->lock); + +- /* reset speed again (adjust_realtime_speed might have set pause) */ +- if(xine_get_param(this->stream, XINE_PARAM_FINE_SPEED) <= 0) { +- LOGMSG("vdr_flush_engine: playback is paused <1>"); +- xine_set_param(this->stream, XINE_PARAM_FINE_SPEED, XINE_FINE_SPEED_NORMAL); +- } +- +-#if 0 +- _x_demux_flush_engine (this->stream); +- /* warning: after clearing decoders fifos an absolute discontinuity +- * indication must be sent. relative discontinuities are likely +- * to cause "jumps" on metronom. +- */ +-#else +- this->stream->demux_plugin->seek (this->stream->demux_plugin, +- 0, 0, this->stream->demux_thread_running); +-#endif +- + #if XINE_VERSION_CODE < 10104 + /* disabled _x_demux_control_start as it causes alsa output driver to exit now and then ... */ + #else + _x_demux_control_start(this->stream); + #endif ++ ++reset_scr_tuning(this); + this->stream_start = 1; + this->I_frames = this->B_frames = this->P_frames = 0; +- this->discard_index = discard_index; +- +- resume_demuxer(this); + } + + static int set_deinterlace_method(vdr_input_plugin_t *this, const char *method_name) +@@ -2327,13 +2230,14 @@ static void select_spu_channel(xine_stream_t *stream, + if (channel == SPU_CHANNEL_NONE) { + /* re-enable overlay for VDR OSD ... */ + if (stream->video_out) { +- pthread_mutex_lock (&stream->frontend_lock); +- stream->xine->port_ticket->acquire (stream->xine->port_ticket, 0); +- +- stream->video_out->enable_ovl (stream->video_out, 1); ++ //pthread_mutex_lock (&stream->frontend_lock); + +- stream->xine->port_ticket->release (stream->xine->port_ticket, 0); +- pthread_mutex_unlock (&stream->frontend_lock); ++ if (_x_lock_port_rewiring(stream->xine, 100)) { ++ stream->video_out->enable_ovl (stream->video_out, 1); ++ _x_unlock_port_rewiring(stream->xine); ++ } ++ ++ //pthread_mutex_unlock (&stream->frontend_lock); + } + } + } +@@ -2957,12 +2861,13 @@ static int vdr_plugin_flush(vdr_input_plugin_t *this, + return 1; + } + +- this->class->xine->port_ticket->acquire(this->class->xine->port_ticket, 1); +- result = MAX(0, pool->size(pool)) + +- MAX(0, buffer->size(buffer)) + +- this->stream->video_out->get_property(this->stream->video_out, +- VO_PROP_BUFS_IN_FIFO); +- this->class->xine->port_ticket->release(this->class->xine->port_ticket, 1); ++ if (_x_lock_port_rewiring(this->class->xine, 100)) { ++ result = MAX(0, pool->size(pool)) + ++ MAX(0, buffer->size(buffer)) + ++ this->stream->video_out->get_property(this->stream->video_out, ++ VO_PROP_BUFS_IN_FIFO); ++ _x_unlock_port_rewiring(this->class->xine); ++ } + + put_control_buf(buffer, pool, BUF_CONTROL_FLUSH_DECODER); + put_control_buf(buffer, pool, BUF_CONTROL_NOP); +@@ -2985,12 +2890,14 @@ static int vdr_plugin_flush(vdr_input_plugin_t *this, + &pool->buffer_pool_mutex, &abstime); + pthread_mutex_unlock(&pool->buffer_pool_mutex); + +- this->class->xine->port_ticket->acquire(this->class->xine->port_ticket, 1); +- result = MAX(0, pool->size(pool)) + +- MAX(0, buffer->size(buffer)) + +- this->stream->video_out->get_property(this->stream->video_out, +- VO_PROP_BUFS_IN_FIFO); +- this->class->xine->port_ticket->release(this->class->xine->port_ticket, 1); ++ result = 0; ++ if (_x_lock_port_rewiring(this->class->xine, 100)) { ++ result = MAX(0, pool->size(pool)) + ++ MAX(0, buffer->size(buffer)) + ++ this->stream->video_out->get_property(this->stream->video_out, ++ VO_PROP_BUFS_IN_FIFO); ++ _x_unlock_port_rewiring(this->class->xine); ++ } + } + + TRACE("vdr_plugin_flush returns %d (%d+%d used, %d frames)\n", result, +@@ -4775,7 +4682,6 @@ static buf_element_t *preprocess_buf(vdr_input_plugin_ + this->block_buffer->fifo_size, + this->stream->video_fifo->fifo_size); + } else { +- vdr_x_demux_control_newpts(this->stream, 0, BUF_FLAG_SEEK); + queue_blank_yv12(this); + } + pthread_mutex_unlock(&this->lock); +@@ -4815,9 +4721,7 @@ static buf_element_t *preprocess_buf(vdr_input_plugin_ + /* First packet ? */ + if (this->stream_start) { + this->stream_start = 0; +- pthread_mutex_lock (&this->stream->first_frame_lock); +- this->stream->first_frame_flag = 2; +- pthread_mutex_unlock (&this->stream->first_frame_lock); ++ _x_trigger_relaxed_frame_drop_mode(this->stream); + + memset(&this->scr_buf, 0, sizeof(this->scr_buf)); + +@@ -4900,7 +4804,9 @@ static void handle_disconnect(vdr_input_plugin_t *this + reset_trick_speed(this); + this->live_mode = 0; + reset_scr_tuning(this); ++#if XINE_VERSION_CODE < 10209 + this->stream->emergency_brake = 1; ++#endif + + this->control_running = 0; + errno = ENOTCONN; +@@ -5869,11 +5775,12 @@ static int vdr_plugin_open_net (input_plugin_t *this_g + return 0; + } + +- this->class->xine->port_ticket->acquire(this->class->xine->port_ticket, 1); +- if(!(this->stream->video_out->get_capabilities(this->stream->video_out) & +- VO_CAP_UNSCALED_OVERLAY)) +- LOGMSG("WARNING: Video output driver reports it does not support unscaled overlays !"); +- this->class->xine->port_ticket->release(this->class->xine->port_ticket, 1); ++ if (_x_lock_port_rewiring(this->class->xine, 0)) { ++ if(!(this->stream->video_out->get_capabilities(this->stream->video_out) & ++ VO_CAP_UNSCALED_OVERLAY)) ++ LOGMSG("WARNING: Video output driver reports it does not support unscaled overlays !"); ++ _x_unlock_port_rewiring(this->class->xine); ++ } + + this->threads_initialized = 1; + return 1;