[totem] Avoid problems when pausing before preroll



commit eadad87158e3edcce12cc593e471ff18369b00e0
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Apr 8 20:00:39 2010 +0100

    Avoid problems when pausing before preroll
    
    When pausing before preroll, we would check the length of the file
    and find that we might we using a live stream, and stopping it, thus
    stopping the preroll.
    
    Instead, when pausing when still prerolling, pause, and only when
    the preroll has been done, stop the pipeline if pause was requested.

 src/backend/bacon-video-widget-gst-0.10.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c
index 2afcc20..5dc289a 100644
--- a/src/backend/bacon-video-widget-gst-0.10.c
+++ b/src/backend/bacon-video-widget-gst-0.10.c
@@ -2127,6 +2127,10 @@ bvw_bus_message_cb (GstBus * bus, GstMessage * message, gpointer data)
           /* show a non-fatal warning message if we can't decode the video */
           bvw_check_if_video_decoder_is_missing (bvw);
         }
+	/* Now that we have the length, check whether we wanted
+	 * to pause or to stop the pipeline */
+        if (bvw->priv->target_state == GST_STATE_PAUSED)
+	  bacon_video_widget_pause (bvw);
       } else if (old_state == GST_STATE_PAUSED && new_state == GST_STATE_READY) {
         bvw->priv->media_has_video = FALSE;
         bvw->priv->media_has_audio = FALSE;
@@ -4333,12 +4337,21 @@ bvw_get_logo_pixbuf (BaconVideoWidget * bvw)
 void
 bacon_video_widget_pause (BaconVideoWidget * bvw)
 {
+  GstStateChangeReturn ret;
+  GstState state;
+
   g_return_if_fail (bvw != NULL);
   g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
   g_return_if_fail (GST_IS_ELEMENT (bvw->priv->play));
   g_return_if_fail (bvw->priv->mrl != NULL);
 
-  if (bvw->priv->is_live != FALSE) {
+  /* Get the current state */
+  ret = gst_element_get_state (GST_ELEMENT (bvw->priv->play), &state, NULL, 0);
+
+  if (bvw->priv->is_live != FALSE &&
+      ret != GST_STATE_CHANGE_NO_PREROLL &&
+      ret != GST_STATE_CHANGE_SUCCESS &&
+      state > GST_STATE_READY) {
     GST_LOG ("Stopping because we have a live stream");
     bacon_video_widget_stop (bvw);
     return;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]