[totem/gnome-2-30] Fix constant buffering when playing live streams



commit 261b53120fea3ba2e1959ce56533e7a4d207ae45
Author: Bastien Nocera <hadess hadess net>
Date:   Thu May 6 10:43:34 2010 +0100

    Fix constant buffering when playing live streams
    
    When playing Ogg Theora live streams, we should wait until the
    buffer reaches 100% before we start the actual playback.
    Otherwise the buffer will be consumed as it is downloaded, and
    we'll be constantly buffering, which is problematic visually,
    and could cause hiccups during playback.
    
    Fixes constant buffering with the streams at:
    http://dir.xiph.org/by_format/Ogg_Theora
    
    https://bugzilla.gnome.org/show_bug.cgi?id=617791

 src/backend/bacon-video-widget-gst-0.10.c |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c
index 96b841e..ebd6e8f 100644
--- a/src/backend/bacon-video-widget-gst-0.10.c
+++ b/src/backend/bacon-video-widget-gst-0.10.c
@@ -1956,7 +1956,7 @@ text_tags_changed_cb (GstElement *playbin2, gint stream_id, gpointer user_data)
 }
 
 static gboolean
-bvw_buffering_done (BaconVideoWidget *bvw)
+bvw_download_buffering_done (BaconVideoWidget *bvw)
 {
   /* When we set buffering left to 0, that means it's ready to play */
   if (bvw->priv->buffering_left == 0) {
@@ -2021,20 +2021,17 @@ bvw_handle_buffering_message (GstMessage * message, BaconVideoWidget *bvw)
     /* if the desired state is playing, go back */
     if (bvw->priv->target_state == GST_STATE_PLAYING) {
       GST_DEBUG ("Buffering done, setting pipeline back to PLAYING");
-      gst_element_set_state (bvw->priv->play, GST_STATE_PLAYING);
+      bacon_video_widget_play (bvw, NULL);
     } else {
       GST_DEBUG ("Buffering done, keeping pipeline PAUSED");
     }
-  } else if (bvw->priv->buffering == FALSE &&
-	     bvw->priv->target_state == GST_STATE_PLAYING) {
+  } else if (bvw->priv->target_state == GST_STATE_PLAYING) {
     GstState cur_state;
 
     gst_element_get_state (bvw->priv->play, &cur_state, NULL, 0);
-    if (cur_state == GST_STATE_PLAYING) {
+    if (cur_state != GST_STATE_PAUSED) {
       GST_DEBUG ("Buffering ... temporarily pausing playback");
       gst_element_set_state (bvw->priv->play, GST_STATE_PAUSED);
-    } else {
-      GST_DEBUG ("Buffering ... prerolling, not doing anything");
     }
     bvw->priv->buffering = TRUE;
   } else {
@@ -2503,7 +2500,7 @@ bvw_query_buffering_timeout (BaconVideoWidget *bvw)
       bvw->priv->buffering_left = 0;
 
     /* Start playing when we've downloaded enough */
-    if (bvw_buffering_done (bvw) != FALSE &&
+    if (bvw_download_buffering_done (bvw) != FALSE &&
 	bvw->priv->target_state == GST_STATE_PLAYING) {
       GST_DEBUG ("Starting playback because the download buffer is filled enough");
       bacon_video_widget_play (bvw, NULL);
@@ -3848,11 +3845,17 @@ bacon_video_widget_play (BaconVideoWidget * bvw, GError ** error)
 
   /* Lie when trying to play a file whilst we're download buffering */
   if (bvw->priv->download_buffering != FALSE &&
-      bvw_buffering_done (bvw) == FALSE) {
+      bvw_download_buffering_done (bvw) == FALSE) {
     GST_DEBUG ("download buffering in progress, not playing");
     return TRUE;
   }
 
+  /* Or when we're buffering */
+  if (bvw->priv->buffering != FALSE) {
+    GST_DEBUG ("buffering in progress, not playing");
+    return TRUE;
+  }
+
   /* just lie and do nothing in this case */
   if (bvw->priv->plugin_install_in_progress && cur_state != GST_STATE_PAUSED) {
     GST_DEBUG ("plugin install in progress and nothing to play, not playing");



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