wtay gst-plugins-bad: gst-plugins-bad/ gst-plugins-bad/examples/app/ gst-plugins-bad/gst-libs/gst/app/

[email protected] Mon, 15 Dec 2008 04:02:40 -0800 (PST)
Newsgroups gmane.comp.video.gstreamer.cvs
Message-ID <[email protected]>
CVS Root:       /cvs/gstreamer
Module:         gst-plugins-bad
Changes by:     wtay
Date:           Mon Dec 15 2008  12:02:40 UTC

Log message:
* examples/app/appsrc-ra.c: (feed_data):
* examples/app/appsrc-seekable.c: (feed_data):
* examples/app/appsrc-stream.c: (read_data):
* examples/app/appsrc-stream2.c: (feed_data):
Fix example to unref after emiting the push-buffer action.
* gst-libs/gst/app/gstappsrc.c: (gst_app_src_class_init),
(gst_app_src_push_buffer_full), (gst_app_src_push_buffer),
(gst_app_src_push_buffer_action):
Don't take the ref on the buffer in push-buffer action because it's too
awkward for bindings. Fixes #564482.

Modified files:
    .               : ChangeLog
    examples/app    : appsrc-ra.c appsrc-seekable.c appsrc-stream.c
                      appsrc-stream2.c
    gst-libs/gst/app: gstappsrc.c

Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ChangeLog.diff?r1=1.3808&r2=1.3809
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/examples/app/appsrc-ra.c.diff?r1=1.2&r2=1.3
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/examples/app/appsrc-seekable.c.diff?r1=1.2&r2=1.3
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/examples/app/appsrc-stream.c.diff?r1=1.3&r2=1.4
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/examples/app/appsrc-stream2.c.diff?r1=1.2&r2=1.3
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst-libs/gst/app/gstappsrc.c.diff?r1=1.12&r2=1.13

====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/ChangeLog,v
retrieving revision 1.3808
retrieving revision 1.3809
diff -u -d -r1.3808 -r1.3809
--- ChangeLog	13 Dec 2008 16:26:35 -0000	1.3808
+++ ChangeLog	15 Dec 2008 12:02:24 -0000	1.3809
@@ -1,3 +1,17 @@
+2008-12-15  Wim Taymans  <[email protected]>
+
+	* examples/app/appsrc-ra.c: (feed_data):
+	* examples/app/appsrc-seekable.c: (feed_data):
+	* examples/app/appsrc-stream.c: (read_data):
+	* examples/app/appsrc-stream2.c: (feed_data):
+	Fix example to unref after emiting the push-buffer action.
+	* gst-libs/gst/app/gstappsrc.c: (gst_app_src_class_init),
+	(gst_app_src_push_buffer_full), (gst_app_src_push_buffer),
+	(gst_app_src_push_buffer_action):
+	Don't take the ref on the buffer in push-buffer action because it's too
+	awkward for bindings. Fixes #564482.
 2008-12-13  Edward Hervey  <[email protected]>
 
 	* m4/Makefile.am:
Index: appsrc-ra.c
RCS file: /cvs/gstreamer/gst-plugins-bad/examples/app/appsrc-ra.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- appsrc-ra.c	18 Jun 2008 06:31:11 -0000	1.2
+++ appsrc-ra.c	15 Dec 2008 12:02:25 -0000	1.3
@@ -92,6 +92,7 @@
   GST_DEBUG ("feed buffer %p, offset %" G_GUINT64_FORMAT "-%u", buffer,
       app->offset, size);
   g_signal_emit_by_name (app->appsrc, "push-buffer", buffer, &ret);
+  gst_buffer_unref (buffer);
   app->offset += size;
Index: appsrc-seekable.c
RCS file: /cvs/gstreamer/gst-plugins-bad/examples/app/appsrc-seekable.c,v
--- appsrc-seekable.c	18 Jun 2008 06:31:11 -0000	1.2
+++ appsrc-seekable.c	15 Dec 2008 12:02:25 -0000	1.3
@@ -95,6 +95,7 @@
       app->offset, len);
   app->offset += len;
Index: appsrc-stream.c
RCS file: /cvs/gstreamer/gst-plugins-bad/examples/app/appsrc-stream.c,v
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- appsrc-stream.c	18 Jun 2008 06:31:11 -0000	1.3
+++ appsrc-stream.c	15 Dec 2008 12:02:25 -0000	1.4
@@ -102,6 +102,7 @@
   if (ret != GST_FLOW_OK) {
     /* some error, stop sending data */
     return FALSE;
Index: appsrc-stream2.c
RCS file: /cvs/gstreamer/gst-plugins-bad/examples/app/appsrc-stream2.c,v
--- appsrc-stream2.c	18 Jun 2008 06:31:11 -0000	1.2
+++ appsrc-stream2.c	15 Dec 2008 12:02:26 -0000	1.3
Index: gstappsrc.c
RCS file: /cvs/gstreamer/gst-plugins-bad/gst-libs/gst/app/gstappsrc.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- gstappsrc.c	1 Dec 2008 19:36:35 -0000	1.12
+++ gstappsrc.c	15 Dec 2008 12:02:26 -0000	1.13
@@ -127,6 +127,8 @@
 static gboolean gst_app_src_is_seekable (GstBaseSrc * src);
 static gboolean gst_app_src_check_get_range (GstBaseSrc * src);
 static gboolean gst_app_src_do_get_size (GstBaseSrc * src, guint64 * size);
+static GstFlowReturn gst_app_src_push_buffer_action (GstAppSrc * appsrc,
+    GstBuffer * buffer);
 static guint gst_app_src_signals[LAST_SIGNAL] = { 0 };
@@ -302,7 +304,8 @@
     * @buffer: a buffer to push
     *
     * Adds a buffer to the queue of buffers that the appsrc element will
-    * push to its source pad. This function will take ownership of @buffer.
+    * push to its source pad. This function does not take ownership of the
+    * buffer so the buffer needs to be unreffed after calling this function.
     * When the block property is TRUE, this function can block until free space
     * becomes available in the queue.
@@ -335,7 +338,7 @@
   basesrc_class->check_get_range = gst_app_src_check_get_range;
   basesrc_class->get_size = gst_app_src_do_get_size;
-  klass->push_buffer = gst_app_src_push_buffer;
+  klass->push_buffer = gst_app_src_push_buffer_action;
   klass->end_of_stream = gst_app_src_end_of_stream;
 }
@@ -916,20 +919,9 @@
   return result;
-/**
- * gst_app_src_push_buffer:
- * @appsrc: a #GstAppSrc
- * @buffer: a #GstBuffer to push
- *
- * Adds a buffer to the queue of buffers that the appsrc element will
- * push to its source pad.  This function takes ownership of the buffer.
- * Returns: #GST_FLOW_OK when the buffer was successfuly queued.
- * #GST_FLOW_WRONG_STATE when @appsrc is not PAUSED or PLAYING.
- * #GST_FLOW_UNEXPECTED when EOS occured.
- */
-GstFlowReturn
-gst_app_src_push_buffer (GstAppSrc * appsrc, GstBuffer * buffer)
+static GstFlowReturn
+gst_app_src_push_buffer_full (GstAppSrc * appsrc, GstBuffer * buffer,
+    gboolean steal_ref)
 {
   gboolean first = TRUE;
@@ -979,6 +971,8 @@
   }
   GST_DEBUG_OBJECT (appsrc, "queueing buffer %p", buffer);
+  if (!steal_ref)
+    gst_buffer_ref (buffer);
   g_queue_push_tail (appsrc->queue, buffer);
   appsrc->queued_bytes += GST_BUFFER_SIZE (buffer);
   g_cond_broadcast (appsrc->cond);
@@ -990,20 +984,48 @@
 flushing:
   {
     GST_DEBUG_OBJECT (appsrc, "refuse buffer %p, we are flushing", buffer);
-    gst_buffer_unref (buffer);
+    if (steal_ref)
+      gst_buffer_unref (buffer);
     g_mutex_unlock (appsrc->mutex);
     return GST_FLOW_WRONG_STATE;
 eos:
     GST_DEBUG_OBJECT (appsrc, "refuse buffer %p, we are EOS", buffer);
     return GST_FLOW_UNEXPECTED;
 /**
+ * gst_app_src_push_buffer:
+ * @appsrc: a #GstAppSrc
+ * @buffer: a #GstBuffer to push
+ *
+ * Adds a buffer to the queue of buffers that the appsrc element will
+ * push to its source pad.  This function takes ownership of the buffer.
+ * Returns: #GST_FLOW_OK when the buffer was successfuly queued.
+ * #GST_FLOW_WRONG_STATE when @appsrc is not PAUSED or PLAYING.
+ * #GST_FLOW_UNEXPECTED when EOS occured.
+ */
+GstFlowReturn
+gst_app_src_push_buffer (GstAppSrc * appsrc, GstBuffer * buffer)
+{
+  return gst_app_src_push_buffer_full (appsrc, buffer, TRUE);
+}
+/* push a buffer without stealing the ref of the buffer. This is used for the
+ * action signal. */
+gst_app_src_push_buffer_action (GstAppSrc * appsrc, GstBuffer * buffer)
+  return gst_app_src_push_buffer_full (appsrc, buffer, FALSE);
+/**
  * gst_app_src_end_of_stream:
  * @appsrc: a #GstAppSrc
  *

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/