From de7347bda68bbcecc387963845c3d8b28a5097b7 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Wed, 17 Aug 2005 16:57:01 +0000 Subject: [PATCH] gst/gstpipeline.c (gst_pipeline_change_state): Interpret play-timeout==0 to mean no timeout at all. In that case, don... Original commit message from CVS: 2005-08-17 Andy Wingo * gst/gstpipeline.c (gst_pipeline_change_state): Interpret play-timeout==0 to mean no timeout at all. In that case, don't bother with a get_state or a warning, just return directly, even if it's ASYNC. --- ChangeLog | 5 +++++ gst/gstpipeline.c | 26 ++++++++++++++++---------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 00661f3332..2469834b73 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2005-08-17 Andy Wingo + * gst/gstpipeline.c (gst_pipeline_change_state): Interpret + play-timeout==0 to mean no timeout at all. In that case, don't + bother with a get_state or a warning, just return directly, even + if it's ASYNC. + * gst/base/gstbasetransform.c: Debug changes. * gst/gstutils.h: diff --git a/gst/gstpipeline.c b/gst/gstpipeline.c index e9c4a57f86..cd8edac4d1 100644 --- a/gst/gstpipeline.c +++ b/gst/gstpipeline.c @@ -255,6 +255,7 @@ gst_pipeline_change_state (GstElement * element) GstElementStateReturn result = GST_STATE_SUCCESS; GstPipeline *pipeline = GST_PIPELINE (element); gint transition = GST_STATE_TRANSITION (element); + GstClockTime play_timeout; GstClock *clock; switch (transition) { @@ -339,23 +340,27 @@ gst_pipeline_change_state (GstElement * element) break; } - /* we wait for async state changes ourselves when we are in an - * intermediate state. - * FIXME this can block forever, better do this in a worker - * thread or use a timeout? */ if (result == GST_STATE_ASYNC) { + GST_LOCK (pipeline); + play_timeout = pipeline->play_timeout; + GST_UNLOCK (pipeline); + } else { + play_timeout = 0; + } + + /* we wait for async state changes ourselves when we are in an + * intermediate state. */ + if (play_timeout > 0) { GTimeVal *timeval, timeout; GST_STATE_UNLOCK (pipeline); - GST_LOCK (pipeline); - if (pipeline->play_timeout > 0) { - GST_TIME_TO_TIMEVAL (pipeline->play_timeout, timeout); - timeval = &timeout; - } else { + if (play_timeout == G_MAXUINT64) { timeval = NULL; + } else { + GST_TIME_TO_TIMEVAL (play_timeout, timeout); + timeval = &timeout; } - GST_UNLOCK (pipeline); result = gst_element_get_state (element, NULL, NULL, timeval); if (result == GST_STATE_ASYNC) { @@ -363,6 +368,7 @@ gst_pipeline_change_state (GstElement * element) g_warning ("timeout in PREROLL, forcing next state change"); result = GST_STATE_SUCCESS; } + GST_STATE_LOCK (pipeline); }