gst/playback/: Some more work on making sure seeking pauses the pipeline and that...
authorWim Taymans <wim.taymans@gmail.com>
Tue, 14 Sep 2004 16:54:14 +0000 (16:54 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Tue, 14 Sep 2004 16:54:14 +0000 (16:54 +0000)
Original commit message from CVS:
* gst/playback/gstplaybasebin.c: (queue_overrun), (no_more_pads),
(setup_source), (gst_play_base_bin_set_property),
(gst_play_base_bin_add_element):
* gst/playback/gstplaybin.c: (gst_play_bin_send_event):
Some more work on making sure seeking pauses the pipeline and
that changing the uri actually does something.

ChangeLog
gst/playback/gstplaybasebin.c
gst/playback/gstplaybin.c

index c90d6d4..80f1794 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2004-09-17  Wim Taymans  <wim@fluendo.com>
 
+       * gst/playback/gstplaybasebin.c: (queue_overrun), (no_more_pads),
+       (setup_source), (gst_play_base_bin_set_property),
+       (gst_play_base_bin_add_element):
+       * gst/playback/gstplaybin.c: (gst_play_bin_send_event):
+       Some more work on making sure seeking pauses the pipeline and
+       that changing the uri actually does something.
+
+2004-09-17  Wim Taymans  <wim@fluendo.com>
+
        * gst/tcp/gstfdset.c: (gst_fdset_wait):
        * gst/tcp/gstmultifdsink.c: (gst_multifdsink_close):
        * gst/tcp/gsttcpserversink.c: (gst_tcpserversink_init_send),
index e225bf1..e6169ff 100644 (file)
@@ -196,8 +196,11 @@ gst_play_base_bin_dispose (GObject * object)
 static void
 queue_overrun (GstElement * element, GstPlayBaseBin * play_base_bin)
 {
+  GST_DEBUG ("queue %s overrun", gst_element_get_name (element));
   g_mutex_lock (play_base_bin->preroll_lock);
+  GST_DEBUG ("signal preroll done");
   g_cond_signal (play_base_bin->preroll_cond);
+  GST_DEBUG ("signaled preroll done");
   g_mutex_unlock (play_base_bin->preroll_lock);
 }
 
@@ -259,7 +262,9 @@ no_more_pads (GstElement * element, GstPlayBaseBin * play_base_bin)
 {
   GST_DEBUG ("no more pads");
   g_mutex_lock (play_base_bin->preroll_lock);
+  GST_DEBUG ("signal preroll done");
   g_cond_signal (play_base_bin->preroll_cond);
+  GST_DEBUG ("signaled preroll done");
   g_mutex_unlock (play_base_bin->preroll_lock);
 }
 
@@ -384,7 +389,9 @@ setup_source (GstPlayBaseBin * play_base_bin)
      */
     g_mutex_lock (play_base_bin->preroll_lock);
     gst_element_set_state (play_base_bin->thread, GST_STATE_PLAYING);
+    GST_DEBUG ("waiting for preroll...");
     g_cond_wait (play_base_bin->preroll_cond, play_base_bin->preroll_lock);
+    GST_DEBUG ("preroll done !");
     g_mutex_unlock (play_base_bin->preroll_lock);
 
     g_signal_handler_disconnect (G_OBJECT (play_base_bin->decoder), sig3);
@@ -416,10 +423,14 @@ gst_play_base_bin_set_property (GObject * object, guint prop_id,
         g_warning ("cannot set NULL uri");
         return;
       }
-      if (!play_base_bin->uri || strcmp (play_base_bin->uri, uri) != 0) {
+      /* if we have no previous uri, or the new uri is different from the
+       * old one, replug */
+      if (play_base_bin->uri == NULL || strcmp (play_base_bin->uri, uri) != 0) {
         g_free (play_base_bin->uri);
         play_base_bin->uri = g_strdup (uri);
 
+        GST_DEBUG ("setting new uri to %s", uri);
+
         play_base_bin->need_rebuild = TRUE;
       }
       break;
@@ -562,11 +573,15 @@ gst_play_base_bin_add_element (GstBin * bin, GstElement * element)
     }
     gst_bin_add (GST_BIN (play_base_bin->thread), element);
 
+    /* hack */
     sched = gst_element_get_scheduler (GST_ELEMENT (play_base_bin->thread));
     clock = gst_scheduler_get_clock (sched);
     gst_scheduler_set_clock (sched, clock);
 
-    //gst_element_sync_state_with_parent (element);
+    /* FIXME set element to READY so that negotiation can happen. This
+     * currently fails because of weird negotiation problems. */
+    /* gst_element_set_state (element, GST_STATE_READY); */
+
   } else {
     g_warning ("adding elements is not allowed in NULL");
   }
index f468995..5bbd97f 100644 (file)
@@ -458,9 +458,17 @@ gst_play_bin_send_event (GstElement * element, GstEvent * event)
   gboolean res = FALSE;
   GList *s;
   GstPlayBin *play_bin;
+  GstElementState state;
+  gboolean need_pause = FALSE;
 
   play_bin = GST_PLAY_BIN (element);
 
+  state = gst_element_get_state (element);
+  if (state == GST_STATE_PLAYING) {
+    need_pause = TRUE;
+    gst_element_set_state (element, GST_STATE_PAUSED);
+  }
+
   s = play_bin->seekables;
 
   for (s = play_bin->seekables; s; s = g_list_next (s)) {
@@ -472,6 +480,10 @@ gst_play_bin_send_event (GstElement * element, GstEvent * event)
     res |= ok;
   }
   gst_event_unref (event);
+
+  if (need_pause)
+    gst_element_set_state (element, GST_STATE_PLAYING);
+
   return res;
 }