diff options
author | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2003-01-10 19:15:16 +0000 |
---|---|---|
committer | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2003-01-10 19:15:16 +0000 |
commit | 84016d72f4b91bae918551bd5501123088e826f5 (patch) | |
tree | eeffcfbad60306d9c891fb3c52969caad11bf5fb | |
parent | 519cd1f3de64e2992d3d7c2509f6c6e6ba575849 (diff) | |
download | xine-lib-84016d72f4b91bae918551bd5501123088e826f5.tar.gz xine-lib-84016d72f4b91bae918551bd5501123088e826f5.tar.bz2 |
protect update of current_extra_info
CVS patchset: 3854
CVS date: 2003/01/10 19:15:16
-rw-r--r-- | src/xine-engine/audio_out.c | 4 | ||||
-rw-r--r-- | src/xine-engine/video_out.c | 8 | ||||
-rw-r--r-- | src/xine-engine/xine.c | 19 | ||||
-rw-r--r-- | src/xine-engine/xine_internal.h | 4 |
4 files changed, 28 insertions, 7 deletions
diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index 2b5e0973e..7cb1e1d74 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -17,7 +17,7 @@ * along with self program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: audio_out.c,v 1.96 2003/01/09 02:44:39 miguelfreitas Exp $ + * $Id: audio_out.c,v 1.97 2003/01/10 19:15:16 miguelfreitas Exp $ * * 22-8-2001 James imported some useful AC3 sections from the previous alsa driver. * (c) 2001 Andy Lo A Foe <andy@alsaplayer.org> @@ -625,7 +625,9 @@ static void *ao_loop (void *this_gen) { if( in_buf && in_buf->stream && !in_buf->stream->video_decoder_plugin ) { + pthread_mutex_lock( &in_buf->stream->current_extra_info_lock ); extra_info_merge( in_buf->stream->current_extra_info, in_buf->extra_info ); + pthread_mutex_unlock( &in_buf->stream->current_extra_info_lock ); } /* diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c index 1336a6315..7610a5a07 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.131 2003/01/10 13:12:20 miguelfreitas Exp $ + * $Id: video_out.c,v 1.132 2003/01/10 19:15:16 miguelfreitas Exp $ * * frame allocation / queuing / scheduling / output functions */ @@ -357,7 +357,9 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { #ifdef LOG printf ("video_out: bad_frame\n"); #endif + pthread_mutex_lock( &stream->current_extra_info_lock ); extra_info_merge( stream->current_extra_info, img->extra_info ); + pthread_mutex_unlock( &stream->current_extra_info_lock ); this->num_frames_skipped++; } @@ -491,7 +493,9 @@ static void expire_frames (vos_t *this, int64_t cur_vpts) { img = vo_remove_from_img_buf_queue_int (this->display_img_buf_queue); + pthread_mutex_lock( &img->stream->current_extra_info_lock ); extra_info_merge( img->stream->current_extra_info, img->extra_info ); + pthread_mutex_unlock( &img->stream->current_extra_info_lock ); /* when flushing frames, keep the first one as backup */ if( this->flush_frames ) { @@ -656,7 +660,9 @@ static void overlay_and_display_frame (vos_t *this, if( img->copy && !img->copy_called ) vo_frame_driver_copy(img); + pthread_mutex_lock( &img->stream->current_extra_info_lock ); extra_info_merge( img->stream->current_extra_info, img->extra_info ); + pthread_mutex_unlock( &img->stream->current_extra_info_lock ); if (this->overlay_source) { this->overlay_source->multiple_overlay_blend (this->overlay_source, diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 7330d1df5..7f38bb5f7 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.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: xine.c,v 1.210 2003/01/10 13:12:21 miguelfreitas Exp $ + * $Id: xine.c,v 1.211 2003/01/10 19:15:17 miguelfreitas Exp $ * * top-level xine functions * @@ -370,6 +370,7 @@ xine_stream_t *xine_stream_new (xine_t *this, pthread_cond_init (&stream->counter_changed, NULL); pthread_mutex_init (&stream->first_frame_lock, NULL); pthread_cond_init (&stream->first_frame_reached, NULL); + pthread_mutex_init (&stream->current_extra_info_lock, NULL); /* * event queues @@ -751,7 +752,9 @@ static int xine_play_internal (xine_stream_t *stream, int start_pos, int start_t * start/seek demux */ if (start_pos) { + pthread_mutex_lock( &stream->current_extra_info_lock ); len = stream->current_extra_info->input_length; + pthread_mutex_unlock( &stream->current_extra_info_lock ); /* FIXME: do we need to protect concurrent access to input plugin here? */ if (len == 0) len = stream->input_plugin->get_length (stream->input_plugin); share = (double) start_pos / 65535; @@ -790,7 +793,9 @@ static int xine_play_internal (xine_stream_t *stream, int start_pos, int start_t pthread_mutex_lock (&stream->first_frame_lock); stream->first_frame_flag = 1; pthread_mutex_unlock (&stream->first_frame_lock); + pthread_mutex_lock( &stream->current_extra_info_lock ); extra_info_reset( stream->current_extra_info ); + pthread_mutex_unlock( &stream->current_extra_info_lock ); printf ("xine: xine_play_internal ...done\n"); @@ -854,6 +859,7 @@ void xine_dispose (xine_stream_t *stream) { pthread_mutex_destroy (&stream->counter_lock); pthread_mutex_destroy (&stream->osd_lock); pthread_mutex_destroy (&stream->event_queues_lock); + pthread_mutex_destroy (&stream->current_extra_info_lock); pthread_cond_destroy (&stream->counter_changed); stream->metronom->exit (stream->metronom); @@ -1017,9 +1023,13 @@ static int xine_get_current_position (xine_stream_t *stream) { return -1; /* position not yet known */ } + pthread_mutex_lock( &stream->current_extra_info_lock ); len = stream->current_extra_info->input_length; + share = (double) stream->current_extra_info->input_pos; + pthread_mutex_unlock( &stream->current_extra_info_lock ); + if (len == 0) len = stream->input_plugin->get_length (stream->input_plugin); - share = (double) stream->current_extra_info->input_pos / (double) len * 65535; + share /= (double) len * 65536; pthread_mutex_unlock (&stream->frontend_lock); @@ -1084,8 +1094,11 @@ int xine_get_pos_length (xine_stream_t *stream, int *pos_stream, if (pos_stream) *pos_stream = pos; - if (pos_time) + if (pos_time) { + pthread_mutex_lock( &stream->current_extra_info_lock ); *pos_time = stream->current_extra_info->input_time; + pthread_mutex_unlock( &stream->current_extra_info_lock ); + } if (length_time) *length_time = xine_get_stream_length (stream) * 1000; diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h index c615c5601..c046b92d8 100644 --- a/src/xine-engine/xine_internal.h +++ b/src/xine-engine/xine_internal.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: xine_internal.h,v 1.122 2003/01/10 11:57:19 miguelfreitas Exp $ + * $Id: xine_internal.h,v 1.123 2003/01/10 19:15:17 miguelfreitas Exp $ * */ @@ -128,7 +128,6 @@ struct extra_info_s { uint32_t frame_number; /* number of current frame if known */ int seek_count; /* internal engine use */ - pthread_mutex_t lock; /* keep consistency */ int64_t vpts; /* set on output layers only */ }; @@ -235,6 +234,7 @@ struct xine_stream_s { int demux_action_pending; extra_info_t *current_extra_info; + pthread_mutex_t current_extra_info_lock; int video_seek_count; xine_post_out_t video_source; |