wtay gst-plugins-base: gst-plugins-base/ gst-plugins-base/gst/playback/

[email protected] Sat, 20 Dec 2008 04:48:57 -0800 (PST)
Newsgroups gmane.comp.video.gstreamer.cvs
Message-ID <[email protected]>
CVS Root:       /cvs/gstreamer
Module:         gst-plugins-base
Changes by:     wtay
Date:           Sat Dec 20 2008  12:48:57 UTC

Log message:
* gst/playback/gstplaybin2.c: (no_more_pads_cb):
Add some debug info.
* gst/playback/gstplaysink.c: (gen_video_chain), (gen_audio_chain),
(gst_play_sink_reconfigure), (gst_play_sink_request_pad),
(gst_play_sink_release_pad):
Add some more debug info.
Reconfigure the audio chain when we switch between raw and encoded audio
in gapless playback.

Modified files:
    .               : ChangeLog
    gst/playback    : gstplaybin2.c gstplaysink.c

Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/ChangeLog.diff?r1=1.4260&r2=1.4261
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst/playback/gstplaybin2.c.diff?r1=1.30&r2=1.31
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst/playback/gstplaysink.c.diff?r1=1.23&r2=1.24

====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-base/ChangeLog,v
retrieving revision 1.4260
retrieving revision 1.4261
diff -u -d -r1.4260 -r1.4261
--- ChangeLog	20 Dec 2008 12:45:00 -0000	1.4260
+++ ChangeLog	20 Dec 2008 12:48:41 -0000	1.4261
@@ -1,5 +1,17 @@
 2008-12-20  Wim Taymans  <[email protected]>
 
+	* gst/playback/gstplaybin2.c: (no_more_pads_cb):
+	Add some debug info.
+
+	* gst/playback/gstplaysink.c: (gen_video_chain), (gen_audio_chain),
+	(gst_play_sink_reconfigure), (gst_play_sink_request_pad),
+	(gst_play_sink_release_pad):
+	Add some more debug info.
+	Reconfigure the audio chain when we switch between raw and encoded audio
+	in gapless playback.
+2008-12-20  Wim Taymans  <[email protected]>
 	* gst-libs/gst/audio/gstbaseaudiosink.c:
 	(gst_base_audio_sink_setcaps):
 	Pause the write thread before deactivating and releasing the ringbuffer
Index: gstplaybin2.c
RCS file: /cvs/gstreamer/gst-plugins-base/gst/playback/gstplaybin2.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- gstplaybin2.c	12 Dec 2008 13:06:48 -0000	1.30
+++ gstplaybin2.c	20 Dec 2008 12:48:43 -0000	1.31
@@ -1876,6 +1876,7 @@
      * and link it. We only do this if we have not yet requested the sinkpad
      * before. */
     if (select->selector && select->sinkpad == NULL) {
+      GST_DEBUG_OBJECT (playbin, "requesting new sink pad %d", select->type);
       select->sinkpad =
           gst_play_sink_request_pad (playbin->playsink, select->type);
       res = gst_pad_link (select->srcpad, select->sinkpad);
@@ -1892,8 +1893,10 @@
   if (group->pending == 0) {
     /* we are the last group to complete, we will configure the output and then
      * signal the other waiters. */
+    GST_LOG_OBJECT (playbin, "last group complete");
     configure = TRUE;
   } else {
+    GST_LOG_OBJECT (playbin, "have more pending groups");
     configure = FALSE;
     /* check if there are more decodebins to wait for */
     while (group->pending) {
@@ -1906,6 +1909,7 @@
   GST_SOURCE_GROUP_UNLOCK (group);
   if (configure) {
+    GST_LOG_OBJECT (playbin, "reconfigure sink");
     /* we configure the modes if we were the last decodebin to complete. */
     gst_play_sink_reconfigure (playbin->playsink);
Index: gstplaysink.c
RCS file: /cvs/gstreamer/gst-plugins-base/gst/playback/gstplaysink.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- gstplaysink.c	11 Dec 2008 11:04:14 -0000	1.23
+++ gstplaysink.c	20 Dec 2008 12:48:43 -0000	1.24
@@ -44,6 +44,7 @@
   GstElement *bin;
   gboolean added;
   gboolean activated;
+  gboolean raw;
 } GstPlayChain;
 typedef struct
@@ -651,6 +652,7 @@
   chain = g_new0 (GstPlayVideoChain, 1);
   chain->chain.playsink = gst_object_ref (playsink);
+  chain->chain.raw = raw;
   GST_DEBUG_OBJECT (playsink, "making video chain %p", chain);
@@ -882,6 +884,7 @@
   chain = g_new0 (GstPlayAudioChain, 1);
   GST_DEBUG_OBJECT (playsink, "making audio chain %p", chain);
@@ -1231,6 +1234,7 @@
       playsink->videochain = gen_video_chain (playsink, raw, async);
     }
     if (playsink->videochain) {
+      GST_DEBUG_OBJECT (playsink, "adding video chain");
       add_chain (GST_PLAY_CHAIN (playsink->videochain), TRUE);
       activate_chain (GST_PLAY_CHAIN (playsink->videochain), TRUE);
       /* if we are not part of vis or subtitles, set the ghostpad target */
@@ -1241,7 +1245,9 @@
       }
+    GST_DEBUG_OBJECT (playsink, "no video needed");
+      GST_DEBUG_OBJECT (playsink, "removing video chain");
       add_chain (GST_PLAY_CHAIN (playsink->videochain), FALSE);
       activate_chain (GST_PLAY_CHAIN (playsink->videochain), FALSE);
@@ -1252,9 +1258,11 @@
   if (need_text) {
     GST_DEBUG_OBJECT (playsink, "adding text");
     if (!playsink->textchain) {
+      GST_DEBUG_OBJECT (playsink, "creating text chain");
       playsink->textchain = gen_text_chain (playsink);
     if (playsink->textchain) {
+      GST_DEBUG_OBJECT (playsink, "adding text chain");
       add_chain (GST_PLAY_CHAIN (playsink->textchain), TRUE);
       gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (playsink->text_pad),
           playsink->textchain->textsinkpad);
@@ -1264,8 +1272,10 @@
       activate_chain (GST_PLAY_CHAIN (playsink->textchain), TRUE);
+    GST_DEBUG_OBJECT (playsink, "no text needed");
     /* we have no subtitles/text or we are requested to not show them */
+      GST_DEBUG_OBJECT (playsink, "removing text chain");
       add_chain (GST_PLAY_CHAIN (playsink->textchain), FALSE);
       activate_chain (GST_PLAY_CHAIN (playsink->textchain), FALSE);
@@ -1276,34 +1286,56 @@
   }
   if (need_audio) {
+    gboolean create_chain = FALSE;
+    gboolean raw, queue;
     GST_DEBUG_OBJECT (playsink, "adding audio");
-    if (!playsink->audiochain) {
-      gboolean raw, queue;
-      /* get a raw sink if we are asked for a raw pad */
-      raw = playsink->audio_pad_raw;
-      if (need_vis) {
-        /* If we are dealing with visualisations, we need to add a queue to
-         * decouple the audio from the video part. We only have to do this when
-         * the video part is async=true */
-        queue = ((GstPlayVideoChain *) playsink->videochain)->async;
-        GST_DEBUG_OBJECT (playsink, "need audio queue for vis: %d", queue);
-      } else {
-        /* no vis, we can avoid a queue */
-        GST_DEBUG_OBJECT (playsink, "don't need audio queue");
-        queue = FALSE;
+    /* get a raw sink if we are asked for a raw pad */
+    raw = playsink->audio_pad_raw;
+    if (need_vis && playsink->videochain) {
+      /* If we are dealing with visualisations, we need to add a queue to
+       * decouple the audio from the video part. We only have to do this when
+       * the video part is async=true */
+      queue = ((GstPlayVideoChain *) playsink->videochain)->async;
+      GST_DEBUG_OBJECT (playsink, "need audio queue for vis: %d", queue);
+    } else {
+      /* no vis, we can avoid a queue */
+      GST_DEBUG_OBJECT (playsink, "don't need audio queue");
+      queue = FALSE;
+    }
+    if (!playsink->audiochain) {
+      /* create chain if we don't already have one */
+      create_chain = TRUE;
+      /* we have a chain, check if it's also raw */
+      if (playsink->audiochain->chain.raw != raw) {
+        GST_DEBUG_OBJECT (playsink, "removing current audio chain");
+        gst_pad_unlink (playsink->audio_tee_asrc,
+            playsink->audiochain->sinkpad);
+        add_chain (GST_PLAY_CHAIN (playsink->audiochain), FALSE);
+        activate_chain (GST_PLAY_CHAIN (playsink->audiochain), FALSE);
+        create_chain = TRUE;
+    if (create_chain) {
+      GST_DEBUG_OBJECT (playsink, "creating new audio chain");
       playsink->audiochain = gen_audio_chain (playsink, raw, queue);
     if (playsink->audiochain) {
+      GST_DEBUG_OBJECT (playsink, "adding audio chain");
       add_chain (GST_PLAY_CHAIN (playsink->audiochain), TRUE);
       gst_pad_link (playsink->audio_tee_asrc, playsink->audiochain->sinkpad);
       activate_chain (GST_PLAY_CHAIN (playsink->audiochain), TRUE);
+    GST_DEBUG_OBJECT (playsink, "no audio needed");
     /* we have no audio or we are requested to not play audio */
+      GST_DEBUG_OBJECT (playsink, "removing audio chain");
       gst_pad_unlink (playsink->audio_tee_asrc, playsink->audiochain->sinkpad);
       add_chain (GST_PLAY_CHAIN (playsink->audiochain), FALSE);
       activate_chain (GST_PLAY_CHAIN (playsink->audiochain), FALSE);
@@ -1319,6 +1351,7 @@
     GST_DEBUG_OBJECT (playsink, "adding visualisation");
     if (playsink->vischain) {
+      GST_DEBUG_OBJECT (playsink, "setting up vis chain");
       srcpad =
           gst_element_get_static_pad (GST_ELEMENT_CAST (playsink->vischain->
               chain.bin), "src");
@@ -1329,7 +1362,9 @@
       activate_chain (GST_PLAY_CHAIN (playsink->vischain), TRUE);
+    GST_DEBUG_OBJECT (playsink, "no vis needed");
+      GST_DEBUG_OBJECT (playsink, "removing vis chain");
       add_chain (GST_PLAY_CHAIN (playsink->vischain), FALSE);
       activate_chain (GST_PLAY_CHAIN (playsink->vischain), FALSE);
@@ -1487,12 +1522,15 @@
   gboolean created = FALSE;
   gboolean raw = FALSE;
+  GST_DEBUG_OBJECT (playsink, "request pad type %d", type);
   GST_PLAY_SINK_LOCK (playsink);
   switch (type) {
     case GST_PLAY_SINK_TYPE_AUDIO_RAW:
       raw = TRUE;
     case GST_PLAY_SINK_TYPE_AUDIO:
       if (!playsink->audio_tee) {
+        GST_LOG_OBJECT (playsink, "creating tee");
         /* create tee when needed. This element will feed the audio sink chain
          * and the vis chain. */
         playsink->audio_tee = gst_element_factory_make ("tee", "audiotee");
@@ -1507,6 +1545,7 @@
         gst_element_set_state (playsink->audio_tee, GST_STATE_PAUSED);
       if (!playsink->audio_pad) {
+        GST_LOG_OBJECT (playsink, "ghosting tee sinkpad");
         playsink->audio_pad =
             gst_ghost_pad_new ("audio_sink", playsink->audio_tee_sink);
         created = TRUE;
@@ -1518,6 +1557,7 @@
     case GST_PLAY_SINK_TYPE_VIDEO:
       if (!playsink->video_pad) {
+        GST_LOG_OBJECT (playsink, "ghosting videosink");
         playsink->video_pad =
             gst_ghost_pad_new_no_target ("video_sink", GST_PAD_SINK);
@@ -1526,6 +1566,7 @@
       res = playsink->video_pad;
       break;
     case GST_PLAY_SINK_TYPE_TEXT:
+      GST_LOG_OBJECT (playsink, "ghosting text");
       if (!playsink->text_pad) {
         playsink->text_pad =
             gst_ghost_pad_new_no_target ("text_sink", GST_PAD_SINK);
@@ -1552,6 +1593,8 @@
 {
   GstPad **res = NULL;
+  GST_DEBUG_OBJECT (playsink, "release pad %" GST_PTR_FORMAT, pad);
   if (pad == playsink->video_pad) {
     res = &playsink->video_pad;
@@ -1563,7 +1606,9 @@
   GST_PLAY_SINK_UNLOCK (playsink);
   if (*res) {
+    GST_DEBUG_OBJECT (playsink, "deactivate pad %" GST_PTR_FORMAT, *res);
     gst_pad_set_active (*res, FALSE);
+    GST_DEBUG_OBJECT (playsink, "remove pad %" GST_PTR_FORMAT, *res);
     gst_element_remove_pad (GST_ELEMENT_CAST (playsink), *res);
     *res = NULL;

------------------------------------------------------------------------------