From 6b355aa720a00409a4b49c2307d841979cea2e5d Mon Sep 17 00:00:00 2001 From: David Schleef Date: Sat, 3 Mar 2007 09:06:06 +0000 Subject: gst-libs/gst/app/gstappsrc.*: Hacking to address issues in 413418. Original commit message from CVS: * gst-libs/gst/app/gstappsrc.c: * gst-libs/gst/app/gstappsrc.h: Hacking to address issues in 413418. --- ChangeLog | 6 ++++ gst-libs/gst/app/gstappsrc.c | 66 ++++++++++++++++++++++++++++++++++++++++---- gst-libs/gst/app/gstappsrc.h | 3 ++ 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index d51ef293..7442cf23 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-03-03 David Schleef + + * gst-libs/gst/app/gstappsrc.c: + * gst-libs/gst/app/gstappsrc.h: + Hacking to address issues in 413418. + 2007-03-03 David Schleef * Makefile.am: diff --git a/gst-libs/gst/app/gstappsrc.c b/gst-libs/gst/app/gstappsrc.c index 1d5b45c6..d786424f 100644 --- a/gst-libs/gst/app/gstappsrc.c +++ b/gst-libs/gst/app/gstappsrc.c @@ -24,8 +24,6 @@ #include #include -#include -#include #include #include "gstappsrc.h" @@ -100,9 +98,22 @@ gst_app_src_dispose (GObject * obj) { GstAppSrc *appsrc = GST_APP_SRC (obj); - g_mutex_free (appsrc->mutex); - g_cond_free (appsrc->cond); - g_queue_free (appsrc->queue); + if (appsrc->caps) { + gst_caps_unref (appsrc->caps); + appsrc->caps = NULL; + } + if (appsrc->mutex) { + g_mutex_free (appsrc->mutex); + appsrc->mutex = NULL; + } + if (appsrc->cond) { + g_cond_free (appsrc->cond); + appsrc->cond = NULL; + } + if (appsrc->queue) { + g_queue_free (appsrc->queue); + appsrc->queue = NULL; + } } static void @@ -187,6 +198,10 @@ gst_app_src_create (GstPushSrc * psrc, GstBuffer ** buf) g_mutex_lock (appsrc->mutex); while (1) { + if (appsrc->unlock) { + ret = GST_FLOW_WRONG_STATE; + break; + } if (!g_queue_is_empty (appsrc->queue)) { *buf = g_queue_pop_head (appsrc->queue); @@ -216,9 +231,20 @@ gst_app_src_create (GstPushSrc * psrc, GstBuffer ** buf) /* external API */ +/** + * gst_app_src_push_buffer: + * @appsrc: + * @buffer: + * + * 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. + */ void gst_app_src_push_buffer (GstAppSrc * appsrc, GstBuffer * buffer) { + g_return_if_fail (appsrc); + g_return_if_fail (GST_IS_APP_SRC (appsrc)); + g_mutex_lock (appsrc->mutex); g_queue_push_tail (appsrc->queue, buffer); @@ -227,17 +253,37 @@ gst_app_src_push_buffer (GstAppSrc * appsrc, GstBuffer * buffer) g_mutex_unlock (appsrc->mutex); } +/** + * gst_app_src_set_caps: + * @appsrc: + * @caps: + * + * Set the capabilities on the appsrc element. This function takes + * ownership of the caps structure. + */ void gst_app_src_set_caps (GstAppSrc * appsrc, GstCaps * caps) { + g_return_if_fail (appsrc); + g_return_if_fail (GST_IS_APP_SRC (appsrc)); + gst_caps_replace (&appsrc->caps, caps); } +/** + * gst_app_src_flush: + * @appsrc: + * + * Flushes all queued buffers from the appsrc element. + */ void gst_app_src_flush (GstAppSrc * appsrc) { GstBuffer *buffer; + g_return_if_fail (appsrc); + g_return_if_fail (GST_IS_APP_SRC (appsrc)); + g_mutex_lock (appsrc->mutex); while ((buffer = g_queue_pop_head (appsrc->queue))) { @@ -249,9 +295,19 @@ gst_app_src_flush (GstAppSrc * appsrc) g_mutex_unlock (appsrc->mutex); } +/** + * gst_app_src_end_of_stream: + * @appsrc: + * + * Indicates to the appsrc element that the last buffer queued in the + * element is the last buffer of the stream. + */ void gst_app_src_end_of_stream (GstAppSrc * appsrc) { + g_return_if_fail (appsrc); + g_return_if_fail (GST_IS_APP_SRC (appsrc)); + g_mutex_lock (appsrc->mutex); appsrc->end_of_stream = TRUE; diff --git a/gst-libs/gst/app/gstappsrc.h b/gst-libs/gst/app/gstappsrc.h index 48990bf9..617a20e2 100644 --- a/gst-libs/gst/app/gstappsrc.h +++ b/gst-libs/gst/app/gstappsrc.h @@ -23,6 +23,8 @@ #include #include +G_BEGIN_DECLS + #define GST_TYPE_APP_SRC \ (gst_app_src_get_type()) #define GST_APP_SRC(obj) \ @@ -66,6 +68,7 @@ void gst_app_src_set_caps (GstAppSrc *appsrc, GstCaps *caps); void gst_app_src_flush (GstAppSrc *appsrc); void gst_app_src_end_of_stream (GstAppSrc *appsrc); +G_END_DECLS #endif -- cgit v1.2.1