diff options
author | Tim-Philipp Müller <tpm@src.gnome.org> | 2006-10-26 18:12:06 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tpm@src.gnome.org> | 2006-10-26 18:12:06 +0000 |
commit | 4df70ee186ab56455f3edea84dd42721c236f24e (patch) | |
tree | a93fff9465e78b1781162f259f1c90493b5138f0 | |
parent | 8214bfca6da0cd2cddd0bf9351680778d9482386 (diff) | |
download | totem-4df70ee186ab56455f3edea84dd42721c236f24e.tar.gz |
Don't use poll_for_state_change() when stopping, it can lead to deadlocks
* src/backend/bacon-video-widget-gst-0.10.c:
(bvw_stop_play_pipeline):
Don't use poll_for_state_change() when stopping, it can lead to
deadlocks when called from the bus handler (e.g. after redirect
message) and isn't really necessary anyway. (Closes: #361787)
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | src/backend/bacon-video-widget-gst-0.10.c | 43 |
2 files changed, 30 insertions, 21 deletions
@@ -1,3 +1,11 @@ +2006-10-26 Tim-Philipp Müller <tim at centricular dot net> + + * src/backend/bacon-video-widget-gst-0.10.c: + (bvw_stop_play_pipeline): + Don't use poll_for_state_change() when stopping, it can lead to + deadlocks when called from the bus handler (e.g. after redirect + message) and isn't really necessary anyway. (Closes: #361787) + 2006-10-26 Bastien Nocera <hadess@hadess.net> * data/mime-type-list.txt: Patch from Jerry Tan <jerry.tan@sun.com> diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c index f72938b8a..d5dccf6db 100644 --- a/src/backend/bacon-video-widget-gst-0.10.c +++ b/src/backend/bacon-video-widget-gst-0.10.c @@ -2531,30 +2531,31 @@ bacon_video_widget_seek (BaconVideoWidget *bvw, float position, GError **error) static void bvw_stop_play_pipeline (BaconVideoWidget * bvw) { - GstElement *playbin = bvw->priv->play; - GstState current_state; - - /* first go to ready, that way our state change handler gets to see - * our state change messages (before the bus goes to flushing) and - * cleans up */ - GST_DEBUG ("stopping"); - bvw->priv->target_state = GST_STATE_NULL; - gst_element_get_state (playbin, ¤t_state, NULL, 0); - if (current_state > GST_STATE_READY) { - GError *err = NULL; - - gst_element_set_state (playbin, GST_STATE_READY); - poll_for_state_change_full (bvw, playbin, GST_STATE_READY, &err, -1); - if (err) - g_error_free (err); + GstState cur_state; + + gst_element_get_state (bvw->priv->play, &cur_state, NULL, 0); + if (cur_state > GST_STATE_READY) { + GstMessage *msg; + GstBus *bus; + + GST_DEBUG ("stopping"); + gst_element_set_state (bvw->priv->play, GST_STATE_READY); + + /* process all remaining state-change messages so everything gets + * cleaned up properly (before the state change to NULL flushes them) */ + GST_DEBUG ("processing pending state-change messages"); + bus = gst_element_get_bus (bvw->priv->play); + while ((msg = gst_bus_poll (bus, GST_MESSAGE_STATE_CHANGED, 0))) { + gst_bus_async_signal_func (bus, msg, NULL); + gst_message_unref (msg); + } + gst_object_unref (bus); } - /* now finally go to null state */ - GST_DEBUG ("almost stopped, setting to NULL"); - gst_element_set_state (playbin, GST_STATE_NULL); - GST_DEBUG ("stopped"); - + gst_element_set_state (bvw->priv->play, GST_STATE_NULL); + bvw->priv->target_state = GST_STATE_NULL; bvw->priv->buffering = FALSE; + GST_DEBUG ("stopped"); } void |