2000-12-29 05:38:06 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
2001-01-20 17:59:25 +00:00
|
|
|
* gstqueue.c:
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2000-05-21 21:58:20 +00:00
|
|
|
//#define DEBUG_ENABLED
|
2000-06-18 13:50:18 +00:00
|
|
|
//#define STATUS_ENABLED
|
|
|
|
#ifdef STATUS_ENABLED
|
2001-01-07 14:49:23 +00:00
|
|
|
#define STATUS(A) GST_DEBUG(0,A, gst_element_get_name(GST_ELEMENT(queue)))
|
2000-06-18 13:50:18 +00:00
|
|
|
#else
|
2001-01-20 17:59:25 +00:00
|
|
|
#define STATUS(A)
|
2000-06-18 13:50:18 +00:00
|
|
|
#endif
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-01-19 00:02:53 +00:00
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "gst_private.h"
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-01-19 00:02:53 +00:00
|
|
|
#include "gstqueue.h"
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
GstElementDetails gst_queue_details = {
|
|
|
|
"Queue",
|
|
|
|
"Connection",
|
|
|
|
"Simple data queue",
|
|
|
|
VERSION,
|
|
|
|
"Erik Walthinsen <omega@cse.ogi.edu>",
|
|
|
|
"(C) 1999",
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Queue signals and args */
|
|
|
|
enum {
|
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ARG_0,
|
|
|
|
ARG_LEVEL,
|
2000-02-13 15:20:49 +00:00
|
|
|
ARG_MAX_LEVEL,
|
2000-12-26 23:51:04 +00:00
|
|
|
ARG_BLOCK,
|
2000-01-30 09:03:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static void gst_queue_class_init (GstQueueClass *klass);
|
|
|
|
static void gst_queue_init (GstQueue *queue);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static void gst_queue_set_arg (GtkObject *object, GtkArg *arg, guint id);
|
|
|
|
static void gst_queue_get_arg (GtkObject *object, GtkArg *arg, guint id);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static gboolean gst_queue_handle_eos (GstPad *pad);
|
|
|
|
static void gst_queue_chain (GstPad *pad, GstBuffer *buf);
|
2000-12-21 01:27:27 +00:00
|
|
|
static GstBuffer * gst_queue_get (GstPad *pad);
|
2000-11-25 14:18:47 +00:00
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static void gst_queue_flush (GstQueue *queue);
|
2000-11-25 14:18:47 +00:00
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static GstElementStateReturn gst_queue_change_state (GstElement *element);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-12-29 02:28:04 +00:00
|
|
|
static GstElementClass *parent_class = NULL;
|
2000-02-27 23:18:38 +00:00
|
|
|
//static guint gst_queue_signals[LAST_SIGNAL] = { 0 };
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
GtkType
|
|
|
|
gst_queue_get_type(void) {
|
|
|
|
static GtkType queue_type = 0;
|
|
|
|
|
|
|
|
if (!queue_type) {
|
|
|
|
static const GtkTypeInfo queue_info = {
|
|
|
|
"GstQueue",
|
|
|
|
sizeof(GstQueue),
|
|
|
|
sizeof(GstQueueClass),
|
|
|
|
(GtkClassInitFunc)gst_queue_class_init,
|
|
|
|
(GtkObjectInitFunc)gst_queue_init,
|
|
|
|
(GtkArgSetFunc)gst_queue_set_arg,
|
|
|
|
(GtkArgGetFunc)gst_queue_get_arg,
|
|
|
|
(GtkClassInitFunc)NULL,
|
|
|
|
};
|
2000-12-29 02:28:04 +00:00
|
|
|
queue_type = gtk_type_unique (GST_TYPE_ELEMENT, &queue_info);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
return queue_type;
|
|
|
|
}
|
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static void
|
|
|
|
gst_queue_class_init (GstQueueClass *klass)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GtkObjectClass *gtkobject_class;
|
2000-10-30 21:02:08 +00:00
|
|
|
GstElementClass *gstelement_class;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
gtkobject_class = (GtkObjectClass*)klass;
|
2000-10-30 21:02:08 +00:00
|
|
|
gstelement_class = (GstElementClass*)klass;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-12-29 02:28:04 +00:00
|
|
|
parent_class = gtk_type_class (GST_TYPE_ELEMENT);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
gtk_object_add_arg_type ("GstQueue::level", GTK_TYPE_INT,
|
|
|
|
GTK_ARG_READABLE, ARG_LEVEL);
|
|
|
|
gtk_object_add_arg_type ("GstQueue::max_level", GTK_TYPE_INT,
|
|
|
|
GTK_ARG_READWRITE, ARG_MAX_LEVEL);
|
2000-12-26 23:51:04 +00:00
|
|
|
gtk_object_add_arg_type ("GstQueue::block", GTK_TYPE_BOOL,
|
|
|
|
GTK_ARG_READWRITE, ARG_BLOCK);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
gtkobject_class->set_arg = gst_queue_set_arg;
|
2000-01-30 09:03:00 +00:00
|
|
|
gtkobject_class->get_arg = gst_queue_get_arg;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
|
|
|
gstelement_class->change_state = gst_queue_change_state;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static void
|
|
|
|
gst_queue_init (GstQueue *queue)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2000-12-26 23:51:04 +00:00
|
|
|
// scheduling on this kind of element is, well, interesting
|
|
|
|
GST_FLAG_SET (queue, GST_ELEMENT_DECOUPLED);
|
2000-12-20 09:39:43 +00:00
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
queue->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
|
2000-12-20 09:39:43 +00:00
|
|
|
gst_pad_set_chain_function (queue->sinkpad, GST_DEBUG_FUNCPTR(gst_queue_chain));
|
2000-12-11 00:24:32 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (queue), queue->sinkpad);
|
2001-01-20 17:59:25 +00:00
|
|
|
gst_pad_set_eos_function (queue->sinkpad, gst_queue_handle_eos);
|
2000-09-24 14:29:49 +00:00
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
queue->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
2000-12-20 09:39:43 +00:00
|
|
|
gst_pad_set_get_function (queue->srcpad, GST_DEBUG_FUNCPTR(gst_queue_get));
|
2000-11-25 14:18:47 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (queue), queue->srcpad);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
queue->queue = NULL;
|
|
|
|
queue->level_buffers = 0;
|
2000-12-28 22:12:02 +00:00
|
|
|
queue->max_buffers = 100;
|
2000-12-26 23:51:04 +00:00
|
|
|
queue->block = TRUE;
|
2000-01-30 09:03:00 +00:00
|
|
|
queue->level_bytes = 0;
|
|
|
|
queue->size_buffers = 0;
|
|
|
|
queue->size_bytes = 0;
|
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
queue->emptycond = g_cond_new ();
|
|
|
|
queue->fullcond = g_cond_new ();
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static gboolean
|
|
|
|
gst_queue_handle_eos (GstPad *pad)
|
|
|
|
{
|
|
|
|
GstQueue *queue;
|
|
|
|
|
|
|
|
queue = GST_QUEUE(pad->parent);
|
|
|
|
|
|
|
|
GST_DEBUG (0,"queue: %s received eos\n", gst_element_get_name (GST_ELEMENT (queue)));
|
|
|
|
|
|
|
|
GST_LOCK (queue);
|
|
|
|
GST_DEBUG (0,"queue: %s has %d buffers left\n", gst_element_get_name (GST_ELEMENT (queue)),
|
|
|
|
queue->level_buffers);
|
|
|
|
|
|
|
|
GST_FLAG_SET (pad, GST_PAD_EOS);
|
|
|
|
|
|
|
|
g_cond_signal (queue->emptycond);
|
|
|
|
|
|
|
|
GST_UNLOCK (queue);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_queue_cleanup_buffers (gpointer data, const gpointer user_data)
|
2000-07-12 22:52:42 +00:00
|
|
|
{
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"queue: %s cleaning buffer %p\n", (gchar *)user_data, data);
|
2001-01-20 17:59:25 +00:00
|
|
|
|
2000-11-11 15:13:50 +00:00
|
|
|
gst_buffer_unref (GST_BUFFER (data));
|
2000-07-12 22:52:42 +00:00
|
|
|
}
|
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static void
|
|
|
|
gst_queue_flush (GstQueue *queue)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2001-01-20 17:59:25 +00:00
|
|
|
g_slist_foreach (queue->queue, gst_queue_cleanup_buffers,
|
|
|
|
(char *)gst_element_get_name (GST_ELEMENT (queue)));
|
2000-11-25 14:18:47 +00:00
|
|
|
g_slist_free (queue->queue);
|
2001-01-20 17:59:25 +00:00
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
queue->queue = NULL;
|
|
|
|
queue->level_buffers = 0;
|
2001-01-07 03:42:27 +00:00
|
|
|
queue->timeval = NULL;
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static void
|
|
|
|
gst_queue_chain (GstPad *pad, GstBuffer *buf)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GstQueue *queue;
|
|
|
|
gboolean tosignal = FALSE;
|
2000-11-11 15:13:50 +00:00
|
|
|
const guchar *name;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
g_return_if_fail (pad != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PAD (pad));
|
|
|
|
g_return_if_fail (buf != NULL);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
queue = GST_QUEUE (pad->parent);
|
|
|
|
name = gst_element_get_name (GST_ELEMENT (queue));
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
/* we have to lock the queue since we span threads */
|
2000-12-21 01:27:27 +00:00
|
|
|
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"queue: try have queue lock\n");
|
2000-11-25 14:18:47 +00:00
|
|
|
GST_LOCK (queue);
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"queue: %s adding buffer %p %ld\n", name, buf, pthread_self ());
|
|
|
|
GST_DEBUG (0,"queue: have queue lock\n");
|
2000-07-12 22:52:42 +00:00
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLUSH)) {
|
|
|
|
gst_queue_flush (queue);
|
2000-07-12 22:52:42 +00:00
|
|
|
}
|
|
|
|
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"queue: %s: chain %d %p\n", name, queue->level_buffers, buf);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-09-22 23:35:14 +00:00
|
|
|
while (queue->level_buffers >= queue->max_buffers) {
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"queue: %s waiting %d\n", name, queue->level_buffers);
|
2000-09-22 23:35:14 +00:00
|
|
|
STATUS("%s: O\n");
|
2001-01-07 14:49:23 +00:00
|
|
|
//g_cond_timed_wait (queue->fullcond, queue->fulllock, queue->timeval);
|
2001-01-14 14:43:57 +00:00
|
|
|
//FIXME need to signal other thread in case signals got lost?
|
|
|
|
g_cond_signal (queue->emptycond);
|
2001-01-07 14:49:23 +00:00
|
|
|
g_cond_wait (queue->fullcond, GST_OBJECT(queue)->lock);
|
2000-09-22 23:35:14 +00:00
|
|
|
STATUS("%s: O+\n");
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"queue: %s waiting done %d\n", name, queue->level_buffers);
|
2000-02-13 13:43:32 +00:00
|
|
|
}
|
|
|
|
|
2000-09-24 14:29:49 +00:00
|
|
|
/* put the buffer on the tail of the list */
|
2000-11-25 14:18:47 +00:00
|
|
|
queue->queue = g_slist_append (queue->queue, buf);
|
2000-12-20 09:39:43 +00:00
|
|
|
// STATUS("%s: +\n");
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"(%s:%s)+ ",GST_DEBUG_PAD_NAME(pad));
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
/* if we were empty, but aren't any more, signal a condition */
|
2000-09-22 23:35:14 +00:00
|
|
|
tosignal = (queue->level_buffers >= 0);
|
2000-05-21 21:58:20 +00:00
|
|
|
queue->level_buffers++;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
/* we can unlock now */
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"queue: %s chain %d end signal(%d,%p)\n", name, queue->level_buffers, tosignal, queue->emptycond);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
if (tosignal) {
|
2000-12-20 09:39:43 +00:00
|
|
|
// STATUS("%s: >\n");
|
2000-11-25 14:18:47 +00:00
|
|
|
g_cond_signal (queue->emptycond);
|
2000-12-20 09:39:43 +00:00
|
|
|
// STATUS("%s: >>\n");
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
2001-01-07 14:49:23 +00:00
|
|
|
GST_UNLOCK (queue);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2000-12-21 01:27:27 +00:00
|
|
|
static GstBuffer *
|
2001-01-20 17:59:25 +00:00
|
|
|
gst_queue_get (GstPad *pad)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
Another big set of changes. Connections are now also pullfunc based. gstqueue has been updated, I don't know of any ...
Original commit message from CVS:
Another big set of changes. Connections are now also pullfunc based.
gstqueue has been updated, I don't know of any other connections offhand.
There are still a few things that need doing, specifically the concept
of a source or connection with connections to multiple thread contexts is
not dealt with. This may force us to move the threadstate from the
element to the pad, maybe keeping the element's copy for simple cases.
Then the Bin would create a structure to pass to the cothreaded _wrappers
of any such elements, which would detail the pads that are to be dealt with
by this particular cothread context.
That will speed things up to, since we don't have to look through the list
of all pads for every Src or Connection element for every iteration, we can
simply step through the list provided by the plan. Special case might even
have a single pad pointer sitting there to trump the list, if there's only
one (the common case anyway).
Task 23098 is tracking these changes. The main task 22588 depends on that
subtask, as well as 22240, which is a consistency check on PAD_DISABLED.
2000-12-08 10:33:01 +00:00
|
|
|
GstQueue *queue = GST_QUEUE (gst_pad_get_parent(pad));
|
2000-01-30 09:03:00 +00:00
|
|
|
GstBuffer *buf = NULL;
|
2000-09-24 14:29:49 +00:00
|
|
|
GSList *front;
|
2000-11-11 15:13:50 +00:00
|
|
|
const guchar *name;
|
Another big set of changes. Connections are now also pullfunc based. gstqueue has been updated, I don't know of any ...
Original commit message from CVS:
Another big set of changes. Connections are now also pullfunc based.
gstqueue has been updated, I don't know of any other connections offhand.
There are still a few things that need doing, specifically the concept
of a source or connection with connections to multiple thread contexts is
not dealt with. This may force us to move the threadstate from the
element to the pad, maybe keeping the element's copy for simple cases.
Then the Bin would create a structure to pass to the cothreaded _wrappers
of any such elements, which would detail the pads that are to be dealt with
by this particular cothread context.
That will speed things up to, since we don't have to look through the list
of all pads for every Src or Connection element for every iteration, we can
simply step through the list provided by the plan. Special case might even
have a single pad pointer sitting there to trump the list, if there's only
one (the common case anyway).
Task 23098 is tracking these changes. The main task 22588 depends on that
subtask, as well as 22240, which is a consistency check on PAD_DISABLED.
2000-12-08 10:33:01 +00:00
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
name = gst_element_get_name (GST_ELEMENT (queue));
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
/* have to lock for thread-safety */
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"queue: %s try have queue lock\n", name);
|
2000-11-25 14:18:47 +00:00
|
|
|
GST_LOCK (queue);
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"queue: %s push %d %ld %p\n", name, queue->level_buffers, pthread_self (), queue->emptycond);
|
|
|
|
GST_DEBUG (0,"queue: %s have queue lock\n", name);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-12-26 23:51:04 +00:00
|
|
|
// we bail if there's nothing there
|
|
|
|
if (!queue->level_buffers && !queue->block) {
|
|
|
|
GST_UNLOCK(queue);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2000-07-12 22:52:42 +00:00
|
|
|
while (!queue->level_buffers) {
|
2000-12-21 01:27:27 +00:00
|
|
|
STATUS("queue: %s U released lock\n");
|
2001-01-07 14:49:23 +00:00
|
|
|
//g_cond_timed_wait (queue->emptycond, queue->emptylock, queue->timeval);
|
2001-01-20 17:59:25 +00:00
|
|
|
if (GST_FLAG_IS_SET (queue->sinkpad, GST_PAD_EOS)) {
|
|
|
|
gst_pad_set_eos (queue->srcpad);
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-01-14 14:43:57 +00:00
|
|
|
//FIXME need to signal other thread in case signals got lost?
|
|
|
|
g_cond_signal (queue->fullcond);
|
2001-01-07 14:49:23 +00:00
|
|
|
g_cond_wait (queue->emptycond, GST_OBJECT(queue)->lock);
|
2000-12-20 09:39:43 +00:00
|
|
|
// STATUS("queue: %s U- getting lock\n");
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
front = queue->queue;
|
|
|
|
buf = (GstBuffer *)(front->data);
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"retrieved buffer %p from queue\n",buf);
|
2000-11-25 14:18:47 +00:00
|
|
|
queue->queue = g_slist_remove_link (queue->queue, front);
|
|
|
|
g_slist_free (front);
|
2000-12-21 01:27:27 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
queue->level_buffers--;
|
2000-12-20 09:39:43 +00:00
|
|
|
// STATUS("%s: -\n");
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"(%s:%s)- ",GST_DEBUG_PAD_NAME(pad));
|
2000-02-13 13:43:32 +00:00
|
|
|
|
2001-01-07 14:49:23 +00:00
|
|
|
if (queue->level_buffers < queue->max_buffers) {
|
2000-12-20 09:39:43 +00:00
|
|
|
// STATUS("%s: < \n");
|
2000-11-25 14:18:47 +00:00
|
|
|
g_cond_signal (queue->fullcond);
|
2000-12-20 09:39:43 +00:00
|
|
|
// STATUS("%s: << \n");
|
2000-02-13 13:43:32 +00:00
|
|
|
}
|
2001-01-07 14:49:23 +00:00
|
|
|
GST_UNLOCK(queue);
|
2000-05-21 21:58:20 +00:00
|
|
|
|
2001-01-01 03:14:40 +00:00
|
|
|
// GST_DEBUG (0,"queue: %s pushing %d %p \n", name, queue->level_buffers, buf);
|
2000-12-21 01:27:27 +00:00
|
|
|
// gst_pad_push (queue->srcpad, buf);
|
2001-01-01 03:14:40 +00:00
|
|
|
// GST_DEBUG (0,"queue: %s pushing %d done \n", name, queue->level_buffers);
|
2000-02-13 13:43:32 +00:00
|
|
|
|
2000-12-21 01:27:27 +00:00
|
|
|
return buf;
|
2000-02-13 13:43:32 +00:00
|
|
|
/* unlock now */
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static GstElementStateReturn
|
|
|
|
gst_queue_change_state (GstElement *element)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2000-10-30 21:02:08 +00:00
|
|
|
GstQueue *queue;
|
2000-11-25 14:18:47 +00:00
|
|
|
g_return_val_if_fail (GST_IS_QUEUE (element), GST_STATE_FAILURE);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
queue = GST_QUEUE (element);
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"gstqueue: state pending %d\n", GST_STATE_PENDING (element));
|
2000-10-30 21:02:08 +00:00
|
|
|
|
|
|
|
/* if going down into NULL state, clear out buffers*/
|
2000-11-25 14:18:47 +00:00
|
|
|
if (GST_STATE_PENDING (element) == GST_STATE_READY) {
|
2000-10-30 21:02:08 +00:00
|
|
|
/* otherwise (READY or higher) we need to open the file */
|
2000-11-25 14:18:47 +00:00
|
|
|
gst_queue_flush (queue);
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* if we haven't failed already, give the parent class a chance to ;-) */
|
2000-11-25 14:18:47 +00:00
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
|
|
|
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
|
|
|
return GST_STATE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static void
|
|
|
|
gst_queue_set_arg (GtkObject *object, GtkArg *arg, guint id)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GstQueue *queue;
|
|
|
|
|
|
|
|
/* it's not null if we got it, but it might not be ours */
|
2000-11-25 14:18:47 +00:00
|
|
|
g_return_if_fail (GST_IS_QUEUE (object));
|
2001-01-20 17:59:25 +00:00
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
queue = GST_QUEUE (object);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
switch(id) {
|
2000-02-13 15:20:49 +00:00
|
|
|
case ARG_MAX_LEVEL:
|
2000-11-25 14:18:47 +00:00
|
|
|
queue->max_buffers = GTK_VALUE_INT (*arg);
|
2000-02-13 15:20:49 +00:00
|
|
|
break;
|
2000-12-26 23:51:04 +00:00
|
|
|
case ARG_BLOCK:
|
|
|
|
queue->block = GTK_VALUE_BOOL (*arg);
|
|
|
|
break;
|
2000-01-30 09:03:00 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static void
|
|
|
|
gst_queue_get_arg (GtkObject *object, GtkArg *arg, guint id)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GstQueue *queue;
|
|
|
|
|
|
|
|
/* it's not null if we got it, but it might not be ours */
|
2000-11-25 14:18:47 +00:00
|
|
|
g_return_if_fail (GST_IS_QUEUE (object));
|
2001-01-20 17:59:25 +00:00
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
queue = GST_QUEUE (object);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
switch (id) {
|
|
|
|
case ARG_LEVEL:
|
2000-11-25 14:18:47 +00:00
|
|
|
GTK_VALUE_INT (*arg) = queue->level_buffers;
|
2000-01-30 09:03:00 +00:00
|
|
|
break;
|
2000-02-13 15:20:49 +00:00
|
|
|
case ARG_MAX_LEVEL:
|
2000-11-25 14:18:47 +00:00
|
|
|
GTK_VALUE_INT (*arg) = queue->max_buffers;
|
2000-02-13 15:20:49 +00:00
|
|
|
break;
|
2000-12-26 23:51:04 +00:00
|
|
|
case ARG_BLOCK:
|
|
|
|
GTK_VALUE_BOOL (*arg) = queue->block;
|
|
|
|
break;
|
2000-01-30 09:03:00 +00:00
|
|
|
default:
|
|
|
|
arg->type = GTK_TYPE_INVALID;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|