diff options
author | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2006-01-26 12:13:23 +0000 |
---|---|---|
committer | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2006-01-26 12:13:23 +0000 |
commit | 97636f227a81901634bd63902a85ac31fb59e9b3 (patch) | |
tree | 3742cced7b82d08a4d74e29d5aea8bed15fc05ce /src | |
parent | 325c49cf90cb8d35fe5766fe9b6a4b7581411c91 (diff) | |
download | xine-lib-97636f227a81901634bd63902a85ac31fb59e9b3.tar.gz xine-lib-97636f227a81901634bd63902a85ac31fb59e9b3.tar.bz2 |
commit Barry Scott's patch for speed changing race
(it was supposed to be part of 1.1.1)
CVS patchset: 7845
CVS date: 2006/01/26 12:13:23
Diffstat (limited to 'src')
-rw-r--r-- | src/xine-engine/xine.c | 33 | ||||
-rw-r--r-- | src/xine-engine/xine_internal.h | 5 |
2 files changed, 26 insertions, 12 deletions
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 2b789bed0..9bc0aa6b2 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.319 2005/10/30 02:18:35 miguelfreitas Exp $ + * $Id: xine.c,v 1.320 2006/01/26 12:13:23 miguelfreitas Exp $ */ /* @@ -294,7 +294,11 @@ void xine_stop (xine_stream_t *stream) { pthread_mutex_lock (&stream->frontend_lock); + /* make sure that other threads cannot change the speed, especially pauseing the stream */ + pthread_mutex_lock(&stream->speed_change_lock); stream->ignore_speed_change = 1; + pthread_mutex_unlock(&stream->speed_change_lock); + stream->xine->port_ticket->acquire(stream->xine->port_ticket, 1); if (stream->audio_out) @@ -333,7 +337,11 @@ static void close_internal (xine_stream_t *stream) { } if( !stream->gapless_switch ) { + /* make sure that other threads cannot change the speed, especially pauseing the stream */ + pthread_mutex_lock(&stream->speed_change_lock); stream->ignore_speed_change = 1; + pthread_mutex_unlock(&stream->speed_change_lock); + stream->xine->port_ticket->acquire(stream->xine->port_ticket, 1); if (stream->audio_out) @@ -530,6 +538,7 @@ xine_stream_t *xine_stream_new (xine_t *this, 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); + pthread_mutex_init (&stream->speed_change_lock, NULL); /* warning: frontend_lock is a recursive mutex. it must NOT be * used with neither pthread_cond_wait() or pthread_cond_timedwait() @@ -1639,18 +1648,20 @@ int xine_get_status (xine_stream_t *stream) { */ void _x_set_fine_speed (xine_stream_t *stream, int speed) { + pthread_mutex_lock(&stream->speed_change_lock); - if (stream->ignore_speed_change) - return; - - if (speed <= XINE_SPEED_PAUSE) - speed = XINE_SPEED_PAUSE; - - xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "set_speed %d\n", speed); - set_speed_internal (stream, speed); + if (!stream->ignore_speed_change) + { + if (speed <= XINE_SPEED_PAUSE) + speed = XINE_SPEED_PAUSE; - if (stream->slave && (stream->slave_affection & XINE_MASTER_SLAVE_SPEED)) - set_speed_internal (stream->slave, speed); + xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "set_speed %d\n", speed); + set_speed_internal (stream, speed); + + if (stream->slave && (stream->slave_affection & XINE_MASTER_SLAVE_SPEED)) + set_speed_internal (stream->slave, speed); + } + pthread_mutex_unlock(&stream->speed_change_lock); } int _x_get_fine_speed (xine_stream_t *stream) { diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h index 718349ea3..b3cb7d65c 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.169 2005/10/30 02:18:35 miguelfreitas Exp $ + * $Id: xine_internal.h,v 1.170 2006/01/26 12:13:23 miguelfreitas Exp $ * */ @@ -243,6 +243,9 @@ struct xine_stream_s { /* these are private variables, plugins must not access them */ int status; + + /* lock controlling speed change access */ + pthread_mutex_t speed_change_lock; int ignore_speed_change; /* speed changes during stop can be disastrous */ input_class_t *eject_class; |