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>
|
2003-04-17 09:19:34 +00:00
|
|
|
* 2003 Colin Walters <cwalters@gnome.org>
|
2005-03-21 17:34:02 +00:00
|
|
|
* 2005 Wim Taymans <wim@fluendo.com>
|
2000-12-29 05:38:06 +00:00
|
|
|
*
|
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
|
2012-11-03 20:44:48 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2000-01-30 09:03:00 +00:00
|
|
|
*/
|
2005-10-15 16:01:57 +00:00
|
|
|
|
2005-09-02 16:17:23 +00:00
|
|
|
/**
|
2005-12-01 12:29:34 +00:00
|
|
|
* SECTION:element-queue
|
2017-01-16 14:26:16 +00:00
|
|
|
* @title: queue
|
2005-09-02 16:17:23 +00:00
|
|
|
*
|
2006-12-19 11:04:49 +00:00
|
|
|
* Data is queued until one of the limits specified by the
|
|
|
|
* #GstQueue:max-size-buffers, #GstQueue:max-size-bytes and/or
|
|
|
|
* #GstQueue:max-size-time properties has been reached. Any attempt to push
|
|
|
|
* more buffers into the queue will block the pushing thread until more space
|
|
|
|
* becomes available.
|
|
|
|
*
|
2006-12-18 16:01:32 +00:00
|
|
|
* The queue will create a new thread on the source pad to decouple the
|
|
|
|
* processing on sink and source pad.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2006-12-18 16:01:32 +00:00
|
|
|
* You can query how many buffers are queued by reading the
|
2006-12-19 11:04:49 +00:00
|
|
|
* #GstQueue:current-level-buffers property. You can track changes
|
|
|
|
* by connecting to the notify::current-level-buffers signal (which
|
|
|
|
* like all signals will be emitted from the streaming thread). The same
|
|
|
|
* applies to the #GstQueue:current-level-time and
|
|
|
|
* #GstQueue:current-level-bytes properties.
|
|
|
|
*
|
|
|
|
* The default queue size limits are 200 buffers, 10MB of data, or
|
|
|
|
* one second worth of data, whichever is reached first.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2006-12-19 11:04:49 +00:00
|
|
|
* As said earlier, the queue blocks by default when one of the specified
|
|
|
|
* maximums (bytes, time, buffers) has been reached. You can set the
|
|
|
|
* #GstQueue:leaky property to specify that instead of blocking it should
|
|
|
|
* leak (drop) new or old buffers.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2006-12-19 11:04:49 +00:00
|
|
|
* The #GstQueue::underrun signal is emitted when the queue has less data than
|
|
|
|
* the specified minimum thresholds require (by default: when the queue is
|
|
|
|
* empty). The #GstQueue::overrun signal is emitted when the queue is filled
|
|
|
|
* up. Both signals are emitted from the context of the streaming thread.
|
2005-09-02 16:17:23 +00:00
|
|
|
*/
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2005-11-29 19:47:00 +00:00
|
|
|
#include "gst/gst_private.h"
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2005-11-29 19:47:00 +00:00
|
|
|
#include <gst/gst.h>
|
2001-01-19 00:02:53 +00:00
|
|
|
#include "gstqueue.h"
|
2005-11-29 19:47:00 +00:00
|
|
|
|
|
|
|
#include "../../gst/gst-i18n-lib.h"
|
2011-12-04 13:35:38 +00:00
|
|
|
#include "../../gst/glib-compat-private.h"
|
2000-01-30 09:03:00 +00:00
|
|
|
|
gst/: s/gst_pad_new/&_from_template/ register pad templates in the base_init function add static pad template definit...
Original commit message from CVS:
* gst/autoplug/gstspideridentity.c:
(gst_spider_identity_request_new_pad):
* gst/elements/gstaggregator.c: (gst_aggregator_base_init),
(gst_aggregator_init):
* gst/elements/gstfakesink.c: (gst_fakesink_base_init),
(gst_fakesink_init):
* gst/elements/gstfakesrc.c: (gst_fakesrc_base_init),
(gst_fakesrc_init):
* gst/elements/gstfdsink.c: (gst_fdsink_base_init),
(gst_fdsink_init):
* gst/elements/gstfdsrc.c: (gst_fdsrc_base_init), (gst_fdsrc_init):
* gst/elements/gstfilesink.c: (gst_filesink_base_init),
(gst_filesink_init):
* gst/elements/gstfilesrc.c: (gst_filesrc_base_init),
(gst_filesrc_init):
* gst/elements/gstidentity.c: (gst_identity_base_init),
(gst_identity_init):
* gst/elements/gstmultifilesrc.c: (gst_multifilesrc_base_init),
(gst_multifilesrc_init):
* gst/elements/gstpipefilter.c: (gst_pipefilter_base_init),
(gst_pipefilter_init):
* gst/elements/gststatistics.c: (gst_statistics_base_init),
(gst_statistics_init):
* gst/elements/gsttee.c: (gst_tee_base_init), (gst_tee_init):
* gst/gstqueue.c: (gst_queue_base_init), (gst_queue_init):
s/gst_pad_new/&_from_template/
register pad templates in the base_init function
add static pad template definitions
2004-08-17 14:11:23 +00:00
|
|
|
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
|
2005-11-30 09:59:04 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (queue_debug);
|
|
|
|
#define GST_CAT_DEFAULT (queue_debug)
|
gst/elements/gstfilesrc.c: compute mapsize correctly
Original commit message from CVS:
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
compute mapsize correctly
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
use correct datatypes when calling a varargs function
* gst/elements/gsttypefindelement.c: (stop_typefinding):
push a DISCONT event as first thing
* gst/gst_private.h:
* gst/gstinfo.c: (_gst_debug_init):
remove GST_DATAFLOW debugging category
* gst/gstbin.c: (gst_bin_iterate):
use GST_SCHEDULING category
* gst/gstpad.c: (gst_pad_get_type), (_invent_event),
(gst_pad_push), (gst_pad_pull), (gst_pad_call_chain_function),
(gst_pad_call_get_function):
add GST_DATAFLOW to easily track flow of buffers or events.
* gst/gstqueue.c: (gst_queue_get_type),
(gst_queue_handle_pending_events), (gst_queue_chain),
(gst_queue_get), (gst_queue_handle_src_event):
use own static debugging category GST_DATAFLOW for dataflow,
use DEBUG category for showing which path events go, use LOG
category for buffers.
2004-05-11 16:20:41 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (queue_dataflow);
|
2005-01-08 18:10:50 +00:00
|
|
|
|
2006-01-19 13:30:31 +00:00
|
|
|
#define STATUS(queue, pad, msg) \
|
2005-01-08 18:10:50 +00:00
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue, \
|
2005-12-06 19:29:15 +00:00
|
|
|
"(%s:%s) " msg ": %u of %u-%u buffers, %u of %u-%u " \
|
|
|
|
"bytes, %" G_GUINT64_FORMAT " of %" G_GUINT64_FORMAT \
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
"-%" G_GUINT64_FORMAT " ns, %u items", \
|
2005-12-06 19:29:15 +00:00
|
|
|
GST_DEBUG_PAD_NAME (pad), \
|
|
|
|
queue->cur_level.buffers, \
|
|
|
|
queue->min_threshold.buffers, \
|
|
|
|
queue->max_size.buffers, \
|
|
|
|
queue->cur_level.bytes, \
|
|
|
|
queue->min_threshold.bytes, \
|
|
|
|
queue->max_size.bytes, \
|
|
|
|
queue->cur_level.time, \
|
|
|
|
queue->min_threshold.time, \
|
|
|
|
queue->max_size.time, \
|
2012-10-22 08:13:20 +00:00
|
|
|
gst_queue_array_get_length (queue->queue))
|
gst/elements/gstfilesrc.c: compute mapsize correctly
Original commit message from CVS:
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
compute mapsize correctly
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
use correct datatypes when calling a varargs function
* gst/elements/gsttypefindelement.c: (stop_typefinding):
push a DISCONT event as first thing
* gst/gst_private.h:
* gst/gstinfo.c: (_gst_debug_init):
remove GST_DATAFLOW debugging category
* gst/gstbin.c: (gst_bin_iterate):
use GST_SCHEDULING category
* gst/gstpad.c: (gst_pad_get_type), (_invent_event),
(gst_pad_push), (gst_pad_pull), (gst_pad_call_chain_function),
(gst_pad_call_get_function):
add GST_DATAFLOW to easily track flow of buffers or events.
* gst/gstqueue.c: (gst_queue_get_type),
(gst_queue_handle_pending_events), (gst_queue_chain),
(gst_queue_get), (gst_queue_handle_src_event):
use own static debugging category GST_DATAFLOW for dataflow,
use DEBUG category for showing which path events go, use LOG
category for buffers.
2004-05-11 16:20:41 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
/* Queue signals and args */
|
2004-03-13 15:27:01 +00:00
|
|
|
enum
|
|
|
|
{
|
2003-12-13 17:12:46 +00:00
|
|
|
SIGNAL_UNDERRUN,
|
|
|
|
SIGNAL_RUNNING,
|
|
|
|
SIGNAL_OVERRUN,
|
2007-05-10 15:21:20 +00:00
|
|
|
SIGNAL_PUSHING,
|
2000-01-30 09:03:00 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
enum
|
|
|
|
{
|
2010-08-27 07:22:27 +00:00
|
|
|
PROP_0,
|
2003-12-13 17:12:46 +00:00
|
|
|
/* FIXME: don't we have another way of doing this
|
|
|
|
* "Gstreamer format" (frame/byte/time) queries? */
|
2010-08-27 07:22:27 +00:00
|
|
|
PROP_CUR_LEVEL_BUFFERS,
|
|
|
|
PROP_CUR_LEVEL_BYTES,
|
|
|
|
PROP_CUR_LEVEL_TIME,
|
|
|
|
PROP_MAX_SIZE_BUFFERS,
|
|
|
|
PROP_MAX_SIZE_BYTES,
|
|
|
|
PROP_MAX_SIZE_TIME,
|
|
|
|
PROP_MIN_THRESHOLD_BUFFERS,
|
|
|
|
PROP_MIN_THRESHOLD_BYTES,
|
|
|
|
PROP_MIN_THRESHOLD_TIME,
|
|
|
|
PROP_LEAKY,
|
2012-10-31 19:33:30 +00:00
|
|
|
PROP_SILENT,
|
|
|
|
PROP_FLUSH_ON_EOS
|
2000-01-30 09:03:00 +00:00
|
|
|
};
|
|
|
|
|
2006-12-19 11:04:49 +00:00
|
|
|
/* default property values */
|
|
|
|
#define DEFAULT_MAX_SIZE_BUFFERS 200 /* 200 buffers */
|
|
|
|
#define DEFAULT_MAX_SIZE_BYTES (10 * 1024 * 1024) /* 10 MB */
|
|
|
|
#define DEFAULT_MAX_SIZE_TIME GST_SECOND /* 1 second */
|
|
|
|
|
2005-12-06 19:29:15 +00:00
|
|
|
#define GST_QUEUE_MUTEX_LOCK(q) G_STMT_START { \
|
2012-01-19 08:27:04 +00:00
|
|
|
g_mutex_lock (&q->qlock); \
|
2004-07-09 11:23:55 +00:00
|
|
|
} G_STMT_END
|
|
|
|
|
2005-12-06 19:29:15 +00:00
|
|
|
#define GST_QUEUE_MUTEX_LOCK_CHECK(q,label) G_STMT_START { \
|
|
|
|
GST_QUEUE_MUTEX_LOCK (q); \
|
|
|
|
if (q->srcresult != GST_FLOW_OK) \
|
|
|
|
goto label; \
|
gst/base/gstbasesrc.*: Add a gboolean to decide when to push out a discont.
Original commit message from CVS:
* gst/base/gstbasesrc.c: (gst_base_src_init),
(gst_base_src_do_seek), (gst_base_src_loop), (gst_base_src_start):
* gst/base/gstbasesrc.h:
Add a gboolean to decide when to push out a discont.
* gst/gstqueue.c: (gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_loop), (gst_queue_handle_src_query),
(gst_queue_sink_activate_push), (gst_queue_src_activate_push),
(gst_queue_set_property), (gst_queue_get_property):
Some cleanups.
* tests/threadstate/threadstate1.c: (main):
Make a thread test compile and run... very silly..
2005-07-20 10:58:10 +00:00
|
|
|
} G_STMT_END
|
|
|
|
|
2005-12-06 19:29:15 +00:00
|
|
|
#define GST_QUEUE_MUTEX_UNLOCK(q) G_STMT_START { \
|
2012-01-19 08:27:04 +00:00
|
|
|
g_mutex_unlock (&q->qlock); \
|
2004-07-09 11:23:55 +00:00
|
|
|
} G_STMT_END
|
|
|
|
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
#define GST_QUEUE_WAIT_DEL_CHECK(q, label) G_STMT_START { \
|
2007-09-28 10:15:23 +00:00
|
|
|
STATUS (q, q->sinkpad, "wait for DEL"); \
|
2010-10-12 16:48:10 +00:00
|
|
|
q->waiting_del = TRUE; \
|
2012-01-19 08:27:04 +00:00
|
|
|
g_cond_wait (&q->item_del, &q->qlock); \
|
2010-10-12 16:48:10 +00:00
|
|
|
q->waiting_del = FALSE; \
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
if (q->srcresult != GST_FLOW_OK) { \
|
2007-09-28 10:15:23 +00:00
|
|
|
STATUS (q, q->srcpad, "received DEL wakeup"); \
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
goto label; \
|
|
|
|
} \
|
2007-09-28 10:15:23 +00:00
|
|
|
STATUS (q, q->sinkpad, "received DEL"); \
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
#define GST_QUEUE_WAIT_ADD_CHECK(q, label) G_STMT_START { \
|
2007-09-28 10:15:23 +00:00
|
|
|
STATUS (q, q->srcpad, "wait for ADD"); \
|
2010-10-12 16:48:10 +00:00
|
|
|
q->waiting_add = TRUE; \
|
2012-01-19 08:27:04 +00:00
|
|
|
g_cond_wait (&q->item_add, &q->qlock); \
|
2010-10-12 16:48:10 +00:00
|
|
|
q->waiting_add = FALSE; \
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
if (q->srcresult != GST_FLOW_OK) { \
|
2007-09-28 10:15:23 +00:00
|
|
|
STATUS (q, q->srcpad, "received ADD wakeup"); \
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
goto label; \
|
|
|
|
} \
|
2007-09-28 10:15:23 +00:00
|
|
|
STATUS (q, q->srcpad, "received ADD"); \
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
#define GST_QUEUE_SIGNAL_DEL(q) G_STMT_START { \
|
2010-10-12 16:48:10 +00:00
|
|
|
if (q->waiting_del) { \
|
|
|
|
STATUS (q, q->srcpad, "signal DEL"); \
|
2012-01-19 08:27:04 +00:00
|
|
|
g_cond_signal (&q->item_del); \
|
2010-10-12 16:48:10 +00:00
|
|
|
} \
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
#define GST_QUEUE_SIGNAL_ADD(q) G_STMT_START { \
|
2010-10-12 16:48:10 +00:00
|
|
|
if (q->waiting_add) { \
|
|
|
|
STATUS (q, q->sinkpad, "signal ADD"); \
|
2012-01-19 08:27:04 +00:00
|
|
|
g_cond_signal (&q->item_add); \
|
2010-10-12 16:48:10 +00:00
|
|
|
} \
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
} G_STMT_END
|
|
|
|
|
2011-04-18 16:07:06 +00:00
|
|
|
#define _do_init \
|
2007-05-10 12:40:12 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (queue_debug, "queue", 0, "queue element"); \
|
|
|
|
GST_DEBUG_CATEGORY_INIT (queue_dataflow, "queue_dataflow", 0, \
|
2007-11-26 13:16:00 +00:00
|
|
|
"dataflow inside the queue element");
|
2011-04-18 16:07:06 +00:00
|
|
|
#define gst_queue_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GstQueue, gst_queue, GST_TYPE_ELEMENT, _do_init);
|
2004-07-09 11:23:55 +00:00
|
|
|
|
|
|
|
static void gst_queue_finalize (GObject * object);
|
2004-03-13 15:27:01 +00:00
|
|
|
static void gst_queue_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_queue_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
|
|
|
|
2011-11-17 11:40:45 +00:00
|
|
|
static GstFlowReturn gst_queue_chain (GstPad * pad, GstObject * parent,
|
|
|
|
GstBuffer * buffer);
|
2015-02-17 09:44:40 +00:00
|
|
|
static GstFlowReturn gst_queue_chain_list (GstPad * pad, GstObject * parent,
|
|
|
|
GstBufferList * buffer_list);
|
libs/gst/base/gstdataqueue.*: Various cleanups.
Original commit message from CVS:
* libs/gst/base/gstdataqueue.c: (gst_data_queue_cleanup),
(gst_data_queue_finalize), (gst_data_queue_locked_is_empty),
(gst_data_queue_set_flushing), (gst_data_queue_push),
(gst_data_queue_pop), (gst_data_queue_drop_head),
(gst_data_queue_limits_changed), (gst_data_queue_get_level):
* libs/gst/base/gstdataqueue.h:
Various cleanups.
Added methods to get the current levels and to inform the queue that the
'full' limits changed.
* plugins/elements/gstmultiqueue.c: (gst_multi_queue_init),
(gst_multi_queue_finalize), (gst_multi_queue_set_property),
(gst_single_queue_flush), (update_time_level), (apply_segment),
(apply_buffer), (gst_single_queue_push_one),
(gst_multi_queue_item_steal_object),
(gst_multi_queue_item_destroy), (gst_multi_queue_item_new),
(gst_multi_queue_loop), (gst_multi_queue_chain),
(gst_multi_queue_sink_activate_push), (gst_multi_queue_sink_event),
(gst_multi_queue_getcaps), (gst_multi_queue_src_activate_push),
(gst_multi_queue_src_query), (single_queue_overrun_cb),
(single_queue_underrun_cb), (single_queue_check_full),
(gst_single_queue_new):
Keep track of time in the queue by measuring the difference between
running_time on input and output. This gives more accurate results and
can compensate for segments correctly.
Make a queue by default only 5 buffers deep. We will now increase the
buffer size depending on the filledness of the other queues.
Factor out commong flush code.
Make sure we don't add additional refcounts to buffers when we can avoid
it.
Propagate GstFlowReturn differently.
Use GSlice for intermediate GstMultiQueueItems.
Keep track of EOS.
Resize queues on over and underruns based on filled level of other
queues.
When checking if the queue is filled, prefer to measure in time if we
can and fall back to bytes when no time is known.
* plugins/elements/gstqueue.c:
Fix return value.
2007-06-15 11:00:32 +00:00
|
|
|
static GstFlowReturn gst_queue_push_one (GstQueue * queue);
|
2005-03-21 17:34:02 +00:00
|
|
|
static void gst_queue_loop (GstPad * pad);
|
|
|
|
|
2015-11-12 16:15:37 +00:00
|
|
|
static GstFlowReturn gst_queue_handle_sink_event (GstPad * pad,
|
|
|
|
GstObject * parent, GstEvent * event);
|
2011-11-16 16:22:56 +00:00
|
|
|
static gboolean gst_queue_handle_sink_query (GstPad * pad, GstObject * parent,
|
|
|
|
GstQuery * query);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2011-11-17 11:40:45 +00:00
|
|
|
static gboolean gst_queue_handle_src_event (GstPad * pad, GstObject * parent,
|
|
|
|
GstEvent * event);
|
2011-11-16 16:22:56 +00:00
|
|
|
static gboolean gst_queue_handle_src_query (GstPad * pad, GstObject * parent,
|
|
|
|
GstQuery * query);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2013-05-27 11:01:43 +00:00
|
|
|
static void gst_queue_locked_flush (GstQueue * queue, gboolean full);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2011-11-21 12:29:05 +00:00
|
|
|
static gboolean gst_queue_src_activate_mode (GstPad * pad, GstObject * parent,
|
|
|
|
GstPadMode mode, gboolean active);
|
|
|
|
static gboolean gst_queue_sink_activate_mode (GstPad * pad, GstObject * parent,
|
|
|
|
GstPadMode mode, gboolean active);
|
2000-11-25 14:18:47 +00:00
|
|
|
|
2006-01-19 13:30:31 +00:00
|
|
|
static gboolean gst_queue_is_empty (GstQueue * queue);
|
|
|
|
static gboolean gst_queue_is_filled (GstQueue * queue);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2013-05-27 13:59:07 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GstMiniObject *item;
|
2013-11-11 12:27:27 +00:00
|
|
|
gsize size;
|
2015-05-30 13:27:05 +00:00
|
|
|
gboolean is_query;
|
2013-05-27 13:59:07 +00:00
|
|
|
} GstQueueItem;
|
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
#define GST_TYPE_QUEUE_LEAKY (queue_leaky_get_type ())
|
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
static GType
|
2003-12-13 17:12:46 +00:00
|
|
|
queue_leaky_get_type (void)
|
|
|
|
{
|
2001-06-25 01:20:11 +00:00
|
|
|
static GType queue_leaky_type = 0;
|
2006-05-09 17:58:35 +00:00
|
|
|
static const GEnumValue queue_leaky[] = {
|
2005-11-22 15:52:03 +00:00
|
|
|
{GST_QUEUE_NO_LEAK, "Not Leaky", "no"},
|
2006-12-18 16:01:32 +00:00
|
|
|
{GST_QUEUE_LEAK_UPSTREAM, "Leaky on upstream (new buffers)", "upstream"},
|
|
|
|
{GST_QUEUE_LEAK_DOWNSTREAM, "Leaky on downstream (old buffers)",
|
2006-12-19 11:04:49 +00:00
|
|
|
"downstream"},
|
2004-03-13 15:27:01 +00:00
|
|
|
{0, NULL, NULL},
|
2001-05-25 21:00:07 +00:00
|
|
|
};
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
if (!queue_leaky_type) {
|
2004-03-13 15:27:01 +00:00
|
|
|
queue_leaky_type = g_enum_register_static ("GstQueueLeaky", queue_leaky);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
return queue_leaky_type;
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2003-04-17 09:19:34 +00:00
|
|
|
static guint gst_queue_signals[LAST_SIGNAL] = { 0 };
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_queue_class_init (GstQueueClass * klass)
|
2003-10-31 19:32:47 +00:00
|
|
|
{
|
2003-12-13 17:12:46 +00:00
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
2011-04-18 16:07:06 +00:00
|
|
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2009-10-28 00:29:30 +00:00
|
|
|
gobject_class->set_property = gst_queue_set_property;
|
|
|
|
gobject_class->get_property = gst_queue_get_property;
|
2005-03-08 17:42:29 +00:00
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
/* signals */
|
2005-08-15 16:57:34 +00:00
|
|
|
/**
|
|
|
|
* GstQueue::underrun:
|
|
|
|
* @queue: the queue instance
|
|
|
|
*
|
|
|
|
* Reports that the buffer became empty (underrun).
|
|
|
|
* A buffer is empty if the total amount of data inside it (num-buffers, time,
|
2007-03-14 15:17:09 +00:00
|
|
|
* size) is lower than the boundary values which can be set through the
|
|
|
|
* GObject properties.
|
2005-08-15 16:57:34 +00:00
|
|
|
*/
|
2003-12-13 17:12:46 +00:00
|
|
|
gst_queue_signals[SIGNAL_UNDERRUN] =
|
2004-03-13 15:27:01 +00:00
|
|
|
g_signal_new ("underrun", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GstQueueClass, underrun), NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2005-08-15 16:57:34 +00:00
|
|
|
/**
|
|
|
|
* GstQueue::running:
|
|
|
|
* @queue: the queue instance
|
|
|
|
*
|
|
|
|
* Reports that enough (min-threshold) data is in the queue. Use this signal
|
2007-03-14 15:17:09 +00:00
|
|
|
* together with the underrun signal to pause the pipeline on underrun and
|
|
|
|
* wait for the queue to fill-up before resume playback.
|
2005-08-15 16:57:34 +00:00
|
|
|
*/
|
2003-12-13 17:12:46 +00:00
|
|
|
gst_queue_signals[SIGNAL_RUNNING] =
|
2004-03-13 15:27:01 +00:00
|
|
|
g_signal_new ("running", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GstQueueClass, running), NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2005-08-15 16:57:34 +00:00
|
|
|
/**
|
|
|
|
* GstQueue::overrun:
|
|
|
|
* @queue: the queue instance
|
|
|
|
*
|
|
|
|
* Reports that the buffer became full (overrun).
|
|
|
|
* A buffer is full if the total amount of data inside it (num-buffers, time,
|
2007-03-14 15:17:09 +00:00
|
|
|
* size) is higher than the boundary values which can be set through the
|
|
|
|
* GObject properties.
|
2005-08-15 16:57:34 +00:00
|
|
|
*/
|
2003-12-13 17:12:46 +00:00
|
|
|
gst_queue_signals[SIGNAL_OVERRUN] =
|
2004-03-13 15:27:01 +00:00
|
|
|
g_signal_new ("overrun", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GstQueueClass, overrun), NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2007-05-10 15:21:20 +00:00
|
|
|
/**
|
|
|
|
* GstQueue::pushing:
|
|
|
|
* @queue: the queue instance
|
|
|
|
*
|
|
|
|
* Reports when the queue has enough data to start pushing data again on the
|
|
|
|
* source pad.
|
|
|
|
*/
|
|
|
|
gst_queue_signals[SIGNAL_PUSHING] =
|
|
|
|
g_signal_new ("pushing", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GstQueueClass, pushing), NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2002-01-13 22:22:42 +00:00
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
/* properties */
|
2010-08-27 07:22:27 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_CUR_LEVEL_BYTES,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_uint ("current-level-bytes", "Current level (kB)",
|
2004-03-15 19:27:17 +00:00
|
|
|
"Current amount of data in the queue (bytes)",
|
2008-03-22 14:56:17 +00:00
|
|
|
0, G_MAXUINT, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
2010-08-27 07:22:27 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_CUR_LEVEL_BUFFERS,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_uint ("current-level-buffers", "Current level (buffers)",
|
2004-03-15 19:27:17 +00:00
|
|
|
"Current number of buffers in the queue",
|
2008-03-22 14:56:17 +00:00
|
|
|
0, G_MAXUINT, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
2010-08-27 07:22:27 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_CUR_LEVEL_TIME,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_uint64 ("current-level-time", "Current level (ns)",
|
2004-03-15 19:27:17 +00:00
|
|
|
"Current amount of data in the queue (in ns)",
|
2008-03-22 14:56:17 +00:00
|
|
|
0, G_MAXUINT64, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2010-08-27 07:22:27 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_MAX_SIZE_BYTES,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_uint ("max-size-bytes", "Max. size (kB)",
|
2004-03-15 19:27:17 +00:00
|
|
|
"Max. amount of data in the queue (bytes, 0=disable)",
|
2008-03-22 14:56:17 +00:00
|
|
|
0, G_MAXUINT, DEFAULT_MAX_SIZE_BYTES,
|
2014-09-13 19:12:52 +00:00
|
|
|
G_PARAM_READWRITE | GST_PARAM_MUTABLE_PLAYING |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2010-08-27 07:22:27 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_MAX_SIZE_BUFFERS,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_uint ("max-size-buffers", "Max. size (buffers)",
|
2008-03-22 14:56:17 +00:00
|
|
|
"Max. number of buffers in the queue (0=disable)", 0, G_MAXUINT,
|
|
|
|
DEFAULT_MAX_SIZE_BUFFERS,
|
2014-09-13 19:12:52 +00:00
|
|
|
G_PARAM_READWRITE | GST_PARAM_MUTABLE_PLAYING |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2010-08-27 07:22:27 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_MAX_SIZE_TIME,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_uint64 ("max-size-time", "Max. size (ns)",
|
2008-03-22 14:56:17 +00:00
|
|
|
"Max. amount of data in the queue (in ns, 0=disable)", 0, G_MAXUINT64,
|
2014-09-13 19:12:52 +00:00
|
|
|
DEFAULT_MAX_SIZE_TIME,
|
|
|
|
G_PARAM_READWRITE | GST_PARAM_MUTABLE_PLAYING |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2010-08-27 07:22:27 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_MIN_THRESHOLD_BYTES,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_uint ("min-threshold-bytes", "Min. threshold (kB)",
|
2004-03-15 19:27:17 +00:00
|
|
|
"Min. amount of data in the queue to allow reading (bytes, 0=disable)",
|
2014-09-13 19:12:52 +00:00
|
|
|
0, G_MAXUINT, 0,
|
|
|
|
G_PARAM_READWRITE | GST_PARAM_MUTABLE_PLAYING |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2010-08-27 07:22:27 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_MIN_THRESHOLD_BUFFERS,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_uint ("min-threshold-buffers", "Min. threshold (buffers)",
|
2014-09-13 19:12:52 +00:00
|
|
|
"Min. number of buffers in the queue to allow reading (0=disable)", 0,
|
|
|
|
G_MAXUINT, 0,
|
|
|
|
G_PARAM_READWRITE | GST_PARAM_MUTABLE_PLAYING |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2010-08-27 07:22:27 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_MIN_THRESHOLD_TIME,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_uint64 ("min-threshold-time", "Min. threshold (ns)",
|
2004-03-15 19:27:17 +00:00
|
|
|
"Min. amount of data in the queue to allow reading (in ns, 0=disable)",
|
2014-09-13 19:12:52 +00:00
|
|
|
0, G_MAXUINT64, 0,
|
|
|
|
G_PARAM_READWRITE | GST_PARAM_MUTABLE_PLAYING |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2010-08-27 07:22:27 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_LEAKY,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_enum ("leaky", "Leaky",
|
2004-03-15 19:27:17 +00:00
|
|
|
"Where the queue leaks, if at all",
|
2008-03-22 14:56:17 +00:00
|
|
|
GST_TYPE_QUEUE_LEAKY, GST_QUEUE_NO_LEAK,
|
2014-09-13 19:12:52 +00:00
|
|
|
G_PARAM_READWRITE | GST_PARAM_MUTABLE_PLAYING |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2010-08-27 12:35:49 +00:00
|
|
|
/**
|
|
|
|
* GstQueue:silent
|
|
|
|
*
|
|
|
|
* Don't emit queue signals. Makes queues more lightweight if no signals are
|
|
|
|
* needed.
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class, PROP_SILENT,
|
|
|
|
g_param_spec_boolean ("silent", "Silent",
|
|
|
|
"Don't emit queue signals", FALSE,
|
2014-09-13 19:12:52 +00:00
|
|
|
G_PARAM_READWRITE | GST_PARAM_MUTABLE_PLAYING |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2010-08-27 12:35:49 +00:00
|
|
|
|
2012-10-31 19:33:30 +00:00
|
|
|
/**
|
|
|
|
* GstQueue:flush-on-eos
|
|
|
|
*
|
|
|
|
* Discard all data in the queue when an EOS event is received, and pass
|
|
|
|
* on the EOS event as soon as possible (instead of waiting until all
|
|
|
|
* buffers in the queue have been processed, which is the default behaviour).
|
|
|
|
*
|
|
|
|
* Flushing the queue on EOS might be useful when capturing and encoding
|
|
|
|
* from a live source, to finish up the recording quickly in cases when
|
|
|
|
* the encoder is slow. Note that this might mean some data from the end of
|
2013-12-07 14:38:19 +00:00
|
|
|
* the recording data might be lost though (never more than the configured
|
2012-10-31 19:33:30 +00:00
|
|
|
* max. sizes though).
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class, PROP_FLUSH_ON_EOS,
|
|
|
|
g_param_spec_boolean ("flush-on-eos", "Flush on EOS",
|
|
|
|
"Discard all data in the queue when an EOS event is received", FALSE,
|
2014-09-13 19:12:52 +00:00
|
|
|
G_PARAM_READWRITE | GST_PARAM_MUTABLE_PLAYING |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2012-10-31 19:33:30 +00:00
|
|
|
|
2009-10-28 00:29:30 +00:00
|
|
|
gobject_class->finalize = gst_queue_finalize;
|
2009-12-01 18:29:25 +00:00
|
|
|
|
2012-04-09 12:05:07 +00:00
|
|
|
gst_element_class_set_static_metadata (gstelement_class,
|
2011-04-18 16:07:06 +00:00
|
|
|
"Queue",
|
|
|
|
"Generic", "Simple data queue", "Erik Walthinsen <omega@cse.ogi.edu>");
|
2016-02-27 15:36:28 +00:00
|
|
|
gst_element_class_add_static_pad_template (gstelement_class, &srctemplate);
|
|
|
|
gst_element_class_add_static_pad_template (gstelement_class, &sinktemplate);
|
2011-04-18 16:07:06 +00:00
|
|
|
|
2009-12-01 18:29:25 +00:00
|
|
|
/* Registering debug symbols for function pointers */
|
2011-11-21 12:29:05 +00:00
|
|
|
GST_DEBUG_REGISTER_FUNCPTR (gst_queue_src_activate_mode);
|
2011-11-15 10:20:48 +00:00
|
|
|
GST_DEBUG_REGISTER_FUNCPTR (gst_queue_handle_sink_event);
|
|
|
|
GST_DEBUG_REGISTER_FUNCPTR (gst_queue_handle_sink_query);
|
2009-12-01 18:29:25 +00:00
|
|
|
GST_DEBUG_REGISTER_FUNCPTR (gst_queue_handle_src_event);
|
|
|
|
GST_DEBUG_REGISTER_FUNCPTR (gst_queue_handle_src_query);
|
2011-11-15 10:20:48 +00:00
|
|
|
GST_DEBUG_REGISTER_FUNCPTR (gst_queue_chain);
|
2015-02-17 09:44:40 +00:00
|
|
|
GST_DEBUG_REGISTER_FUNCPTR (gst_queue_chain_list);
|
2002-01-13 22:22:42 +00:00
|
|
|
}
|
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static void
|
2011-04-18 16:07:06 +00:00
|
|
|
gst_queue_init (GstQueue * queue)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2005-11-16 17:18:34 +00:00
|
|
|
queue->sinkpad = gst_pad_new_from_static_template (&sinktemplate, "sink");
|
2005-11-15 19:31:05 +00:00
|
|
|
|
2009-12-01 18:29:25 +00:00
|
|
|
gst_pad_set_chain_function (queue->sinkpad, gst_queue_chain);
|
2015-02-17 09:44:40 +00:00
|
|
|
gst_pad_set_chain_list_function (queue->sinkpad, gst_queue_chain_list);
|
2011-11-21 12:29:05 +00:00
|
|
|
gst_pad_set_activatemode_function (queue->sinkpad,
|
|
|
|
gst_queue_sink_activate_mode);
|
2015-11-12 16:15:37 +00:00
|
|
|
gst_pad_set_event_full_function (queue->sinkpad, gst_queue_handle_sink_event);
|
2011-11-09 16:36:00 +00:00
|
|
|
gst_pad_set_query_function (queue->sinkpad, gst_queue_handle_sink_query);
|
2011-11-29 10:47:34 +00:00
|
|
|
GST_PAD_SET_PROXY_CAPS (queue->sinkpad);
|
2005-03-21 17:34:02 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (queue), queue->sinkpad);
|
2000-09-24 14:29:49 +00:00
|
|
|
|
2005-11-16 17:18:34 +00:00
|
|
|
queue->srcpad = gst_pad_new_from_static_template (&srctemplate, "src");
|
2005-11-15 19:31:05 +00:00
|
|
|
|
2011-11-21 12:29:05 +00:00
|
|
|
gst_pad_set_activatemode_function (queue->srcpad,
|
|
|
|
gst_queue_src_activate_mode);
|
2009-12-01 18:29:25 +00:00
|
|
|
gst_pad_set_event_function (queue->srcpad, gst_queue_handle_src_event);
|
|
|
|
gst_pad_set_query_function (queue->srcpad, gst_queue_handle_src_query);
|
2011-11-29 10:47:34 +00:00
|
|
|
GST_PAD_SET_PROXY_CAPS (queue->srcpad);
|
2005-03-21 17:34:02 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (queue), queue->srcpad);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
GST_QUEUE_CLEAR_LEVEL (queue->cur_level);
|
2006-12-19 11:04:49 +00:00
|
|
|
queue->max_size.buffers = DEFAULT_MAX_SIZE_BUFFERS;
|
|
|
|
queue->max_size.bytes = DEFAULT_MAX_SIZE_BYTES;
|
|
|
|
queue->max_size.time = DEFAULT_MAX_SIZE_TIME;
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
GST_QUEUE_CLEAR_LEVEL (queue->min_threshold);
|
|
|
|
GST_QUEUE_CLEAR_LEVEL (queue->orig_min_threshold);
|
|
|
|
gst_segment_init (&queue->sink_segment, GST_FORMAT_TIME);
|
|
|
|
gst_segment_init (&queue->src_segment, GST_FORMAT_TIME);
|
2008-02-20 15:44:33 +00:00
|
|
|
queue->head_needs_discont = queue->tail_needs_discont = FALSE;
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2001-12-29 03:02:14 +00:00
|
|
|
queue->leaky = GST_QUEUE_NO_LEAK;
|
2012-02-08 14:16:46 +00:00
|
|
|
queue->srcresult = GST_FLOW_FLUSHING;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2012-01-19 08:27:04 +00:00
|
|
|
g_mutex_init (&queue->qlock);
|
|
|
|
g_cond_init (&queue->item_add);
|
|
|
|
g_cond_init (&queue->item_del);
|
2013-05-27 13:59:07 +00:00
|
|
|
g_cond_init (&queue->query_handled);
|
2011-11-03 23:08:52 +00:00
|
|
|
|
2015-05-30 13:27:05 +00:00
|
|
|
queue->queue =
|
|
|
|
gst_queue_array_new_for_struct (sizeof (GstQueueItem),
|
|
|
|
DEFAULT_MAX_SIZE_BUFFERS * 3 / 2);
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2016-03-02 16:47:33 +00:00
|
|
|
queue->sinktime = GST_CLOCK_STIME_NONE;
|
|
|
|
queue->srctime = GST_CLOCK_STIME_NONE;
|
2009-09-28 13:20:06 +00:00
|
|
|
|
|
|
|
queue->sink_tainted = TRUE;
|
|
|
|
queue->src_tainted = TRUE;
|
|
|
|
|
2010-10-11 08:27:52 +00:00
|
|
|
queue->newseg_applied_to_src = FALSE;
|
|
|
|
|
2005-11-30 09:59:04 +00:00
|
|
|
GST_DEBUG_OBJECT (queue,
|
2004-03-13 15:27:01 +00:00
|
|
|
"initialized queue's not_empty & not_full conditions");
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2004-07-09 11:23:55 +00:00
|
|
|
/* called only once, as opposed to dispose */
|
2001-12-22 21:18:17 +00:00
|
|
|
static void
|
2004-07-09 11:23:55 +00:00
|
|
|
gst_queue_finalize (GObject * object)
|
2001-12-22 21:18:17 +00:00
|
|
|
{
|
|
|
|
GstQueue *queue = GST_QUEUE (object);
|
2015-05-30 13:27:05 +00:00
|
|
|
GstQueueItem *qitem;
|
2001-12-22 21:18:17 +00:00
|
|
|
|
2004-07-09 11:23:55 +00:00
|
|
|
GST_DEBUG_OBJECT (queue, "finalizing queue");
|
2003-03-27 03:16:08 +00:00
|
|
|
|
2015-05-30 13:27:05 +00:00
|
|
|
while ((qitem = gst_queue_array_pop_head_struct (queue->queue))) {
|
2012-07-14 19:26:04 +00:00
|
|
|
/* FIXME: if it's a query, shouldn't we unref that too? */
|
2013-05-27 13:59:07 +00:00
|
|
|
if (!qitem->is_query)
|
|
|
|
gst_mini_object_unref (qitem->item);
|
2012-03-29 15:43:17 +00:00
|
|
|
}
|
2012-10-22 08:13:20 +00:00
|
|
|
gst_queue_array_free (queue->queue);
|
2011-11-03 23:08:52 +00:00
|
|
|
|
2012-01-19 08:27:04 +00:00
|
|
|
g_mutex_clear (&queue->qlock);
|
|
|
|
g_cond_clear (&queue->item_add);
|
|
|
|
g_cond_clear (&queue->item_del);
|
2013-05-27 13:59:07 +00:00
|
|
|
g_cond_clear (&queue->query_handled);
|
2001-12-22 21:18:17 +00:00
|
|
|
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-12-22 21:18:17 +00:00
|
|
|
}
|
|
|
|
|
2016-03-02 16:47:33 +00:00
|
|
|
/* Convenience function */
|
|
|
|
static inline GstClockTimeDiff
|
|
|
|
my_segment_to_running_time (GstSegment * segment, GstClockTime val)
|
|
|
|
{
|
|
|
|
GstClockTimeDiff res = GST_CLOCK_STIME_NONE;
|
|
|
|
|
|
|
|
if (GST_CLOCK_TIME_IS_VALID (val)) {
|
|
|
|
gboolean sign =
|
|
|
|
gst_segment_to_running_time_full (segment, GST_FORMAT_TIME, val, &val);
|
|
|
|
if (sign > 0)
|
|
|
|
res = val;
|
|
|
|
else if (sign < 0)
|
|
|
|
res = -val;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
/* calculate the diff between running time on the sink and src of the queue.
|
|
|
|
* This is the total amount of time in the queue. */
|
2007-05-10 15:21:20 +00:00
|
|
|
static void
|
|
|
|
update_time_level (GstQueue * queue)
|
|
|
|
{
|
|
|
|
gint64 sink_time, src_time;
|
|
|
|
|
2009-09-28 13:20:06 +00:00
|
|
|
if (queue->sink_tainted) {
|
2011-07-05 14:20:03 +00:00
|
|
|
GST_LOG_OBJECT (queue, "update sink time");
|
2009-09-28 13:20:06 +00:00
|
|
|
queue->sinktime =
|
2016-03-02 16:47:33 +00:00
|
|
|
my_segment_to_running_time (&queue->sink_segment,
|
2011-05-13 16:07:24 +00:00
|
|
|
queue->sink_segment.position);
|
2009-09-28 13:20:06 +00:00
|
|
|
queue->sink_tainted = FALSE;
|
|
|
|
}
|
|
|
|
sink_time = queue->sinktime;
|
2007-05-10 15:21:20 +00:00
|
|
|
|
2009-09-28 13:20:06 +00:00
|
|
|
if (queue->src_tainted) {
|
2011-07-05 14:20:03 +00:00
|
|
|
GST_LOG_OBJECT (queue, "update src time");
|
2009-09-28 13:20:06 +00:00
|
|
|
queue->srctime =
|
2016-03-02 16:47:33 +00:00
|
|
|
my_segment_to_running_time (&queue->src_segment,
|
2011-05-13 16:07:24 +00:00
|
|
|
queue->src_segment.position);
|
2009-09-28 13:20:06 +00:00
|
|
|
queue->src_tainted = FALSE;
|
|
|
|
}
|
|
|
|
src_time = queue->srctime;
|
2007-05-10 15:21:20 +00:00
|
|
|
|
2016-03-02 16:47:33 +00:00
|
|
|
GST_LOG_OBJECT (queue, "sink %" GST_STIME_FORMAT ", src %" GST_STIME_FORMAT,
|
|
|
|
GST_STIME_ARGS (sink_time), GST_STIME_ARGS (src_time));
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
|
2017-11-23 14:28:39 +00:00
|
|
|
if (GST_CLOCK_STIME_IS_VALID (src_time)
|
|
|
|
&& GST_CLOCK_STIME_IS_VALID (sink_time) && sink_time >= src_time)
|
2007-05-10 15:21:20 +00:00
|
|
|
queue->cur_level.time = sink_time - src_time;
|
|
|
|
else
|
|
|
|
queue->cur_level.time = 0;
|
|
|
|
}
|
|
|
|
|
2011-05-13 16:07:24 +00:00
|
|
|
/* take a SEGMENT event and apply the values to segment, updating the time
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
* level of queue. */
|
|
|
|
static void
|
2009-09-28 13:20:06 +00:00
|
|
|
apply_segment (GstQueue * queue, GstEvent * event, GstSegment * segment,
|
|
|
|
gboolean sink)
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
{
|
2011-05-18 14:56:13 +00:00
|
|
|
gst_event_copy_segment (event, segment);
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
|
|
|
|
/* now configure the values, we use these to track timestamps on the
|
|
|
|
* sinkpad. */
|
2011-05-13 16:07:24 +00:00
|
|
|
if (segment->format != GST_FORMAT_TIME) {
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
/* non-time format, pretent the current time segment is closed with a
|
|
|
|
* 0 start and unknown stop time. */
|
2011-05-13 16:07:24 +00:00
|
|
|
segment->format = GST_FORMAT_TIME;
|
|
|
|
segment->start = 0;
|
|
|
|
segment->stop = -1;
|
|
|
|
segment->time = 0;
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
}
|
2009-09-28 13:20:06 +00:00
|
|
|
if (sink)
|
|
|
|
queue->sink_tainted = TRUE;
|
|
|
|
else
|
|
|
|
queue->src_tainted = TRUE;
|
|
|
|
|
2011-05-13 16:07:24 +00:00
|
|
|
GST_DEBUG_OBJECT (queue, "configured SEGMENT %" GST_SEGMENT_FORMAT, segment);
|
2007-05-21 12:05:14 +00:00
|
|
|
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
/* segment can update the time level of the queue */
|
|
|
|
update_time_level (queue);
|
|
|
|
}
|
|
|
|
|
2014-10-02 08:00:32 +00:00
|
|
|
static void
|
|
|
|
apply_gap (GstQueue * queue, GstEvent * event,
|
|
|
|
GstSegment * segment, gboolean is_sink)
|
|
|
|
{
|
|
|
|
GstClockTime timestamp;
|
|
|
|
GstClockTime duration;
|
|
|
|
|
|
|
|
gst_event_parse_gap (event, ×tamp, &duration);
|
|
|
|
|
|
|
|
if (GST_CLOCK_TIME_IS_VALID (timestamp)) {
|
|
|
|
|
|
|
|
if (GST_CLOCK_TIME_IS_VALID (duration)) {
|
|
|
|
timestamp += duration;
|
|
|
|
}
|
|
|
|
|
|
|
|
segment->position = timestamp;
|
|
|
|
|
|
|
|
if (is_sink)
|
|
|
|
queue->sink_tainted = TRUE;
|
|
|
|
else
|
|
|
|
queue->src_tainted = TRUE;
|
|
|
|
|
|
|
|
/* calc diff with other end */
|
|
|
|
update_time_level (queue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
/* take a buffer and update segment, updating the time level of the queue. */
|
|
|
|
static void
|
2007-09-17 06:01:53 +00:00
|
|
|
apply_buffer (GstQueue * queue, GstBuffer * buffer, GstSegment * segment,
|
2015-02-18 09:05:19 +00:00
|
|
|
gboolean sink)
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
{
|
|
|
|
GstClockTime duration, timestamp;
|
|
|
|
|
2015-10-27 07:48:07 +00:00
|
|
|
timestamp = GST_BUFFER_DTS_OR_PTS (buffer);
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
duration = GST_BUFFER_DURATION (buffer);
|
|
|
|
|
2009-08-28 15:49:11 +00:00
|
|
|
/* if no timestamp is set, assume it's continuous with the previous
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
* time */
|
|
|
|
if (timestamp == GST_CLOCK_TIME_NONE)
|
2011-05-13 16:07:24 +00:00
|
|
|
timestamp = segment->position;
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
|
|
|
|
/* add duration */
|
2015-02-18 09:05:19 +00:00
|
|
|
if (duration != GST_CLOCK_TIME_NONE)
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
timestamp += duration;
|
|
|
|
|
2016-03-02 16:47:33 +00:00
|
|
|
GST_LOG_OBJECT (queue, "%s position updated to %" GST_TIME_FORMAT,
|
|
|
|
segment == &queue->sink_segment ? "sink" : "src",
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
GST_TIME_ARGS (timestamp));
|
|
|
|
|
2011-05-13 16:07:24 +00:00
|
|
|
segment->position = timestamp;
|
2009-09-28 13:20:06 +00:00
|
|
|
if (sink)
|
|
|
|
queue->sink_tainted = TRUE;
|
|
|
|
else
|
|
|
|
queue->src_tainted = TRUE;
|
|
|
|
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
|
|
|
|
/* calc diff with other end */
|
|
|
|
update_time_level (queue);
|
|
|
|
}
|
|
|
|
|
2015-02-17 09:44:40 +00:00
|
|
|
static gboolean
|
|
|
|
buffer_list_apply_time (GstBuffer ** buf, guint idx, gpointer user_data)
|
|
|
|
{
|
2015-02-18 09:05:19 +00:00
|
|
|
GstClockTime *timestamp = user_data;
|
2015-10-27 07:48:07 +00:00
|
|
|
GstClockTime btime;
|
2015-02-17 09:44:40 +00:00
|
|
|
|
2015-10-27 07:48:07 +00:00
|
|
|
GST_TRACE ("buffer %u has pts %" GST_TIME_FORMAT " dts %" GST_TIME_FORMAT
|
|
|
|
" duration %" GST_TIME_FORMAT, idx, GST_TIME_ARGS (GST_BUFFER_DTS (*buf)),
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_PTS (*buf)),
|
2015-02-17 09:44:40 +00:00
|
|
|
GST_TIME_ARGS (GST_BUFFER_DURATION (*buf)));
|
|
|
|
|
2015-10-27 07:48:07 +00:00
|
|
|
btime = GST_BUFFER_DTS_OR_PTS (*buf);
|
|
|
|
if (GST_CLOCK_TIME_IS_VALID (btime))
|
|
|
|
*timestamp = btime;
|
2015-02-17 09:44:40 +00:00
|
|
|
|
2015-02-18 09:05:19 +00:00
|
|
|
if (GST_BUFFER_DURATION_IS_VALID (*buf))
|
|
|
|
*timestamp += GST_BUFFER_DURATION (*buf);
|
2015-02-17 09:44:40 +00:00
|
|
|
|
2015-02-18 09:05:19 +00:00
|
|
|
GST_TRACE ("ts now %" GST_TIME_FORMAT, GST_TIME_ARGS (*timestamp));
|
2015-02-17 09:44:40 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* take a buffer list and update segment, updating the time level of the queue */
|
|
|
|
static void
|
|
|
|
apply_buffer_list (GstQueue * queue, GstBufferList * buffer_list,
|
2015-02-18 09:05:19 +00:00
|
|
|
GstSegment * segment, gboolean sink)
|
2015-02-17 09:44:40 +00:00
|
|
|
{
|
2015-02-18 09:05:19 +00:00
|
|
|
GstClockTime timestamp;
|
2015-02-17 09:44:40 +00:00
|
|
|
|
|
|
|
/* if no timestamp is set, assume it's continuous with the previous time */
|
2015-02-18 09:05:19 +00:00
|
|
|
timestamp = segment->position;
|
2015-02-17 09:44:40 +00:00
|
|
|
|
2015-02-18 09:05:19 +00:00
|
|
|
gst_buffer_list_foreach (buffer_list, buffer_list_apply_time, ×tamp);
|
2015-02-17 09:44:40 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (queue, "position updated to %" GST_TIME_FORMAT,
|
2015-02-18 09:05:19 +00:00
|
|
|
GST_TIME_ARGS (timestamp));
|
2015-02-17 09:44:40 +00:00
|
|
|
|
2015-02-18 09:05:19 +00:00
|
|
|
segment->position = timestamp;
|
2015-02-17 09:44:40 +00:00
|
|
|
|
|
|
|
if (sink)
|
|
|
|
queue->sink_tainted = TRUE;
|
|
|
|
else
|
|
|
|
queue->src_tainted = TRUE;
|
|
|
|
|
|
|
|
/* calc diff with other end */
|
|
|
|
update_time_level (queue);
|
|
|
|
}
|
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static void
|
2013-05-27 11:01:43 +00:00
|
|
|
gst_queue_locked_flush (GstQueue * queue, gboolean full)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2015-05-30 13:27:05 +00:00
|
|
|
GstQueueItem *qitem;
|
2013-05-27 13:59:07 +00:00
|
|
|
|
2015-05-30 13:27:05 +00:00
|
|
|
while ((qitem = gst_queue_array_pop_head_struct (queue->queue))) {
|
2005-10-24 09:13:27 +00:00
|
|
|
/* Then lose another reference because we are supposed to destroy that
|
2004-02-09 09:11:50 +00:00
|
|
|
data when flushing */
|
2013-05-27 14:38:18 +00:00
|
|
|
if (!full && !qitem->is_query && GST_IS_EVENT (qitem->item)
|
|
|
|
&& GST_EVENT_IS_STICKY (qitem->item)
|
2013-05-27 13:59:07 +00:00
|
|
|
&& GST_EVENT_TYPE (qitem->item) != GST_EVENT_SEGMENT
|
|
|
|
&& GST_EVENT_TYPE (qitem->item) != GST_EVENT_EOS) {
|
|
|
|
gst_pad_store_sticky_event (queue->srcpad, GST_EVENT_CAST (qitem->item));
|
2013-05-27 11:01:43 +00:00
|
|
|
}
|
2013-05-27 13:59:07 +00:00
|
|
|
if (!qitem->is_query)
|
|
|
|
gst_mini_object_unref (qitem->item);
|
2015-05-30 13:27:05 +00:00
|
|
|
memset (qitem, 0, sizeof (GstQueueItem));
|
2002-07-08 19:22:02 +00:00
|
|
|
}
|
2013-05-24 16:47:24 +00:00
|
|
|
queue->last_query = FALSE;
|
2013-05-27 13:59:07 +00:00
|
|
|
g_cond_signal (&queue->query_handled);
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
GST_QUEUE_CLEAR_LEVEL (queue->cur_level);
|
plugins/elements/gstqueue.*: In queue, when EOS is received, if minimum threshold > max_size - current_level, there i...
Original commit message from CVS:
Patch by Tommi Myöhänen <ext-tommi dot myohanen at nokia dot com>
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_locked_flush), (gst_queue_handle_sink_event),
(gst_queue_set_property):
* plugins/elements/gstqueue.h:
In queue, when EOS is received, if minimum threshold > max_size -
current_level, there is chance that queue blocks forever in conditional item
del wait. This is because the queue is not emptied completely due to minimum
threshold.
Here is another approach. Instead of setting cur_levels to max in EOS, just
zero all minimum threshold levels. This should make sure that queue gives out
all data. When going to READY (stop) state, just reset the original minimum
threshold levels.
Fixes #336336.
2006-03-29 11:02:33 +00:00
|
|
|
queue->min_threshold.buffers = queue->orig_min_threshold.buffers;
|
|
|
|
queue->min_threshold.bytes = queue->orig_min_threshold.bytes;
|
|
|
|
queue->min_threshold.time = queue->orig_min_threshold.time;
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
gst_segment_init (&queue->sink_segment, GST_FORMAT_TIME);
|
|
|
|
gst_segment_init (&queue->src_segment, GST_FORMAT_TIME);
|
2008-02-20 15:44:33 +00:00
|
|
|
queue->head_needs_discont = queue->tail_needs_discont = FALSE;
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2016-03-02 16:47:33 +00:00
|
|
|
queue->sinktime = queue->srctime = GST_CLOCK_STIME_NONE;
|
2009-09-28 13:20:06 +00:00
|
|
|
queue->sink_tainted = queue->src_tainted = TRUE;
|
|
|
|
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
/* we deleted a lot of something */
|
|
|
|
GST_QUEUE_SIGNAL_DEL (queue);
|
|
|
|
}
|
|
|
|
|
2007-09-14 20:24:22 +00:00
|
|
|
/* enqueue an item an update the level stats, with QUEUE_LOCK */
|
2009-09-28 13:41:52 +00:00
|
|
|
static inline void
|
2009-10-08 07:47:44 +00:00
|
|
|
gst_queue_locked_enqueue_buffer (GstQueue * queue, gpointer item)
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
{
|
2015-05-30 13:27:05 +00:00
|
|
|
GstQueueItem qitem;
|
2009-10-08 07:47:44 +00:00
|
|
|
GstBuffer *buffer = GST_BUFFER_CAST (item);
|
2013-11-11 12:27:27 +00:00
|
|
|
gsize bsize = gst_buffer_get_size (buffer);
|
2009-10-08 07:47:44 +00:00
|
|
|
|
|
|
|
/* add buffer to the statistics */
|
|
|
|
queue->cur_level.buffers++;
|
2013-11-11 12:27:27 +00:00
|
|
|
queue->cur_level.bytes += bsize;
|
2015-02-18 09:05:19 +00:00
|
|
|
apply_buffer (queue, buffer, &queue->sink_segment, TRUE);
|
2009-10-08 07:47:44 +00:00
|
|
|
|
2015-05-30 13:27:05 +00:00
|
|
|
qitem.item = item;
|
|
|
|
qitem.is_query = FALSE;
|
|
|
|
qitem.size = bsize;
|
|
|
|
gst_queue_array_push_tail_struct (queue->queue, &qitem);
|
2009-10-08 07:47:44 +00:00
|
|
|
GST_QUEUE_SIGNAL_ADD (queue);
|
|
|
|
}
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
|
2015-02-17 09:44:40 +00:00
|
|
|
static inline void
|
|
|
|
gst_queue_locked_enqueue_buffer_list (GstQueue * queue, gpointer item)
|
|
|
|
{
|
2015-05-30 13:27:05 +00:00
|
|
|
GstQueueItem qitem;
|
2015-02-17 09:44:40 +00:00
|
|
|
GstBufferList *buffer_list = GST_BUFFER_LIST_CAST (item);
|
2017-08-31 12:05:57 +00:00
|
|
|
gsize bsize;
|
2015-02-17 09:44:40 +00:00
|
|
|
|
2017-08-31 12:05:57 +00:00
|
|
|
bsize = gst_buffer_list_calculate_size (buffer_list);
|
2015-02-17 09:44:40 +00:00
|
|
|
|
|
|
|
/* add buffer to the statistics */
|
|
|
|
queue->cur_level.buffers += gst_buffer_list_length (buffer_list);
|
|
|
|
queue->cur_level.bytes += bsize;
|
2015-02-18 09:05:19 +00:00
|
|
|
apply_buffer_list (queue, buffer_list, &queue->sink_segment, TRUE);
|
2015-02-17 09:44:40 +00:00
|
|
|
|
2015-05-30 13:27:05 +00:00
|
|
|
qitem.item = item;
|
|
|
|
qitem.is_query = FALSE;
|
|
|
|
qitem.size = bsize;
|
|
|
|
gst_queue_array_push_tail_struct (queue->queue, &qitem);
|
2015-02-17 09:44:40 +00:00
|
|
|
GST_QUEUE_SIGNAL_ADD (queue);
|
|
|
|
}
|
|
|
|
|
2009-10-08 07:47:44 +00:00
|
|
|
static inline void
|
|
|
|
gst_queue_locked_enqueue_event (GstQueue * queue, gpointer item)
|
|
|
|
{
|
2015-05-30 13:27:05 +00:00
|
|
|
GstQueueItem qitem;
|
2009-10-08 07:47:44 +00:00
|
|
|
GstEvent *event = GST_EVENT_CAST (item);
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
|
2009-10-08 07:47:44 +00:00
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_EOS:
|
2012-10-31 19:33:30 +00:00
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue, "got EOS from upstream");
|
2009-10-08 07:47:44 +00:00
|
|
|
/* Zero the thresholds, this makes sure the queue is completely
|
|
|
|
* filled and we can read all data from the queue. */
|
2012-10-31 19:33:30 +00:00
|
|
|
if (queue->flush_on_eos)
|
2013-05-27 11:01:43 +00:00
|
|
|
gst_queue_locked_flush (queue, FALSE);
|
2012-10-31 19:33:30 +00:00
|
|
|
else
|
|
|
|
GST_QUEUE_CLEAR_LEVEL (queue->min_threshold);
|
2009-10-08 07:47:44 +00:00
|
|
|
/* mark the queue as EOS. This prevents us from accepting more data. */
|
|
|
|
queue->eos = TRUE;
|
|
|
|
break;
|
2011-05-13 16:07:24 +00:00
|
|
|
case GST_EVENT_SEGMENT:
|
2009-10-08 07:47:44 +00:00
|
|
|
apply_segment (queue, event, &queue->sink_segment, TRUE);
|
2010-10-11 08:27:52 +00:00
|
|
|
/* if the queue is empty, apply sink segment on the source */
|
2012-10-22 08:13:20 +00:00
|
|
|
if (gst_queue_array_is_empty (queue->queue)) {
|
2010-10-11 14:45:16 +00:00
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue, "Apply segment on srcpad");
|
2010-10-11 08:27:52 +00:00
|
|
|
apply_segment (queue, event, &queue->src_segment, FALSE);
|
|
|
|
queue->newseg_applied_to_src = TRUE;
|
|
|
|
}
|
2011-10-10 09:33:51 +00:00
|
|
|
/* a new segment allows us to accept more buffers if we got EOS
|
2009-10-08 07:47:44 +00:00
|
|
|
* from downstream */
|
|
|
|
queue->unexpected = FALSE;
|
2014-10-02 11:55:22 +00:00
|
|
|
break;
|
2014-10-02 08:00:32 +00:00
|
|
|
case GST_EVENT_GAP:
|
|
|
|
apply_gap (queue, event, &queue->sink_segment, TRUE);
|
2009-10-08 07:47:44 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
}
|
|
|
|
|
2015-05-30 13:27:05 +00:00
|
|
|
qitem.item = item;
|
|
|
|
qitem.is_query = FALSE;
|
|
|
|
qitem.size = 0;
|
|
|
|
gst_queue_array_push_tail_struct (queue->queue, &qitem);
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
GST_QUEUE_SIGNAL_ADD (queue);
|
|
|
|
}
|
|
|
|
|
2007-09-17 06:01:53 +00:00
|
|
|
/* dequeue an item from the queue and update level stats, with QUEUE_LOCK */
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
static GstMiniObject *
|
2012-03-14 14:42:33 +00:00
|
|
|
gst_queue_locked_dequeue (GstQueue * queue)
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
{
|
2013-05-27 13:59:07 +00:00
|
|
|
GstQueueItem *qitem;
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
GstMiniObject *item;
|
2013-11-11 12:27:27 +00:00
|
|
|
gsize bufsize;
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
|
2015-05-30 13:27:05 +00:00
|
|
|
qitem = gst_queue_array_pop_head_struct (queue->queue);
|
2013-05-27 13:59:07 +00:00
|
|
|
if (qitem == NULL)
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
goto no_item;
|
|
|
|
|
2013-05-27 13:59:07 +00:00
|
|
|
item = qitem->item;
|
2013-11-11 12:27:27 +00:00
|
|
|
bufsize = qitem->size;
|
2013-05-27 13:59:07 +00:00
|
|
|
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
if (GST_IS_BUFFER (item)) {
|
|
|
|
GstBuffer *buffer = GST_BUFFER_CAST (item);
|
|
|
|
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
|
|
|
"retrieved buffer %p from queue", buffer);
|
|
|
|
|
|
|
|
queue->cur_level.buffers--;
|
2013-11-11 12:27:27 +00:00
|
|
|
queue->cur_level.bytes -= bufsize;
|
2015-02-18 09:05:19 +00:00
|
|
|
apply_buffer (queue, buffer, &queue->src_segment, FALSE);
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
|
2007-09-17 06:01:53 +00:00
|
|
|
/* if the queue is empty now, update the other side */
|
2007-10-02 09:21:48 +00:00
|
|
|
if (queue->cur_level.buffers == 0)
|
|
|
|
queue->cur_level.time = 0;
|
2015-02-17 09:44:40 +00:00
|
|
|
} else if (GST_IS_BUFFER_LIST (item)) {
|
|
|
|
GstBufferList *buffer_list = GST_BUFFER_LIST_CAST (item);
|
|
|
|
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
|
|
|
"retrieved buffer list %p from queue", buffer_list);
|
2009-10-08 07:47:44 +00:00
|
|
|
|
2015-02-17 09:44:40 +00:00
|
|
|
queue->cur_level.buffers -= gst_buffer_list_length (buffer_list);
|
|
|
|
queue->cur_level.bytes -= bufsize;
|
2015-02-18 09:05:19 +00:00
|
|
|
apply_buffer_list (queue, buffer_list, &queue->src_segment, FALSE);
|
2015-02-17 09:44:40 +00:00
|
|
|
|
|
|
|
/* if the queue is empty now, update the other side */
|
|
|
|
if (queue->cur_level.buffers == 0)
|
|
|
|
queue->cur_level.time = 0;
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
} else if (GST_IS_EVENT (item)) {
|
|
|
|
GstEvent *event = GST_EVENT_CAST (item);
|
|
|
|
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
|
|
|
"retrieved event %p from queue", event);
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_EOS:
|
|
|
|
/* queue is empty now that we dequeued the EOS */
|
|
|
|
GST_QUEUE_CLEAR_LEVEL (queue->cur_level);
|
|
|
|
break;
|
2011-05-13 16:07:24 +00:00
|
|
|
case GST_EVENT_SEGMENT:
|
2010-10-11 08:27:52 +00:00
|
|
|
/* apply newsegment if it has not already been applied */
|
|
|
|
if (G_LIKELY (!queue->newseg_applied_to_src)) {
|
|
|
|
apply_segment (queue, event, &queue->src_segment, FALSE);
|
|
|
|
} else {
|
|
|
|
queue->newseg_applied_to_src = FALSE;
|
|
|
|
}
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
break;
|
2014-10-02 08:00:32 +00:00
|
|
|
case GST_EVENT_GAP:
|
|
|
|
apply_gap (queue, event, &queue->src_segment, FALSE);
|
|
|
|
break;
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2012-03-14 14:42:33 +00:00
|
|
|
} else if (GST_IS_QUERY (item)) {
|
|
|
|
GstQuery *query = GST_QUERY_CAST (item);
|
2009-10-08 07:47:44 +00:00
|
|
|
|
2012-03-14 14:42:33 +00:00
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
|
|
|
"retrieved query %p from queue", query);
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
} else {
|
|
|
|
g_warning
|
|
|
|
("Unexpected item %p dequeued from queue %s (refcounting problem?)",
|
|
|
|
item, GST_OBJECT_NAME (queue));
|
|
|
|
item = NULL;
|
|
|
|
}
|
|
|
|
GST_QUEUE_SIGNAL_DEL (queue);
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
no_item:
|
|
|
|
{
|
2007-09-28 10:22:40 +00:00
|
|
|
GST_CAT_DEBUG_OBJECT (queue_dataflow, queue, "the queue is empty");
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
2015-11-12 16:15:37 +00:00
|
|
|
static GstFlowReturn
|
2011-11-17 11:40:45 +00:00
|
|
|
gst_queue_handle_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
2003-12-14 13:14:35 +00:00
|
|
|
{
|
2013-12-11 13:42:34 +00:00
|
|
|
gboolean ret = TRUE;
|
2005-03-21 17:34:02 +00:00
|
|
|
GstQueue *queue;
|
|
|
|
|
2011-11-17 11:40:45 +00:00
|
|
|
queue = GST_QUEUE (parent);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2017-08-11 08:12:09 +00:00
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue, "Received event '%s'",
|
|
|
|
GST_EVENT_TYPE_NAME (event));
|
|
|
|
|
2015-12-14 10:16:50 +00:00
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
Some docs updates
Original commit message from CVS:
* CHANGES-0.9:
* docs/design/part-TODO.txt:
* docs/design/part-events.txt:
Some docs updates
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_push), (gst_base_sink_activate_pull):
* gst/base/gstbasesrc.c: (gst_base_src_send_discont),
(gst_base_src_do_seek), (gst_base_src_event_handler),
(gst_base_src_loop):
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),
(gst_base_transform_configure_caps), (gst_base_transform_setcaps),
(gst_base_transform_get_size), (gst_base_transform_buffer_alloc),
(gst_base_transform_event), (gst_base_transform_handle_buffer),
(gst_base_transform_set_passthrough),
(gst_base_transform_is_passthrough):
* gst/elements/gstfakesink.c: (gst_fake_sink_event):
* gst/elements/gstfilesink.c: (gst_file_sink_event):
Event updates.
* gst/gstbuffer.h:
Use faster casts.
* gst/gstelement.c: (gst_element_seek):
* gst/gstelement.h:
Update gst_element_seek.
* gst/gstevent.c: (gst_event_finalize), (_gst_event_copy),
(gst_event_new), (gst_event_new_custom), (gst_event_get_structure),
(gst_event_new_flush_start), (gst_event_new_flush_stop),
(gst_event_new_eos), (gst_event_new_newsegment),
(gst_event_parse_newsegment), (gst_event_new_tag),
(gst_event_parse_tag), (gst_event_new_filler), (gst_event_new_qos),
(gst_event_parse_qos), (gst_event_new_seek),
(gst_event_parse_seek), (gst_event_new_navigation):
* gst/gstevent.h:
Make GstEvent use GstStructure. Add parsing code, make sure the
API is sufficiently generic.
Mark possible directions of events and serialization.
* gst/gstmessage.c: (gst_message_init), (gst_message_finalize),
(_gst_message_copy), (gst_message_new_segment_start),
(gst_message_new_segment_done), (gst_message_new_custom),
(gst_message_parse_segment_start),
(gst_message_parse_segment_done):
Small cleanups.
* gst/gstpad.c: (gst_pad_get_caps_unlocked), (gst_pad_accept_caps),
(gst_pad_set_caps), (gst_pad_send_event):
Update for new events.
Catch events sent in wrong directions.
* gst/gstqueue.c: (gst_queue_link_src),
(gst_queue_handle_sink_event), (gst_queue_chain), (gst_queue_loop),
(gst_queue_handle_src_query):
Event updates.
* gst/gsttag.c:
* gst/gsttag.h:
Remove event code from this file.
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_event),
(gst_dp_event_from_packet):
Event updates.
2005-07-27 18:33:03 +00:00
|
|
|
case GST_EVENT_FLUSH_START:
|
2005-10-24 15:41:48 +00:00
|
|
|
/* forward event */
|
2013-12-11 13:42:34 +00:00
|
|
|
ret = gst_pad_push_event (queue->srcpad, event);
|
gst/base/gstbasesrc.*: Add a gboolean to decide when to push out a discont.
Original commit message from CVS:
* gst/base/gstbasesrc.c: (gst_base_src_init),
(gst_base_src_do_seek), (gst_base_src_loop), (gst_base_src_start):
* gst/base/gstbasesrc.h:
Add a gboolean to decide when to push out a discont.
* gst/gstqueue.c: (gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_loop), (gst_queue_handle_src_query),
(gst_queue_sink_activate_push), (gst_queue_src_activate_push),
(gst_queue_set_property), (gst_queue_get_property):
Some cleanups.
* tests/threadstate/threadstate1.c: (main):
Make a thread test compile and run... very silly..
2005-07-20 10:58:10 +00:00
|
|
|
|
Some docs updates
Original commit message from CVS:
* CHANGES-0.9:
* docs/design/part-TODO.txt:
* docs/design/part-events.txt:
Some docs updates
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_push), (gst_base_sink_activate_pull):
* gst/base/gstbasesrc.c: (gst_base_src_send_discont),
(gst_base_src_do_seek), (gst_base_src_event_handler),
(gst_base_src_loop):
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),
(gst_base_transform_configure_caps), (gst_base_transform_setcaps),
(gst_base_transform_get_size), (gst_base_transform_buffer_alloc),
(gst_base_transform_event), (gst_base_transform_handle_buffer),
(gst_base_transform_set_passthrough),
(gst_base_transform_is_passthrough):
* gst/elements/gstfakesink.c: (gst_fake_sink_event):
* gst/elements/gstfilesink.c: (gst_file_sink_event):
Event updates.
* gst/gstbuffer.h:
Use faster casts.
* gst/gstelement.c: (gst_element_seek):
* gst/gstelement.h:
Update gst_element_seek.
* gst/gstevent.c: (gst_event_finalize), (_gst_event_copy),
(gst_event_new), (gst_event_new_custom), (gst_event_get_structure),
(gst_event_new_flush_start), (gst_event_new_flush_stop),
(gst_event_new_eos), (gst_event_new_newsegment),
(gst_event_parse_newsegment), (gst_event_new_tag),
(gst_event_parse_tag), (gst_event_new_filler), (gst_event_new_qos),
(gst_event_parse_qos), (gst_event_new_seek),
(gst_event_parse_seek), (gst_event_new_navigation):
* gst/gstevent.h:
Make GstEvent use GstStructure. Add parsing code, make sure the
API is sufficiently generic.
Mark possible directions of events and serialization.
* gst/gstmessage.c: (gst_message_init), (gst_message_finalize),
(_gst_message_copy), (gst_message_new_segment_start),
(gst_message_new_segment_done), (gst_message_new_custom),
(gst_message_parse_segment_start),
(gst_message_parse_segment_done):
Small cleanups.
* gst/gstpad.c: (gst_pad_get_caps_unlocked), (gst_pad_accept_caps),
(gst_pad_set_caps), (gst_pad_send_event):
Update for new events.
Catch events sent in wrong directions.
* gst/gstqueue.c: (gst_queue_link_src),
(gst_queue_handle_sink_event), (gst_queue_chain), (gst_queue_loop),
(gst_queue_handle_src_query):
Event updates.
* gst/gsttag.c:
* gst/gsttag.h:
Remove event code from this file.
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_event),
(gst_dp_event_from_packet):
Event updates.
2005-07-27 18:33:03 +00:00
|
|
|
/* now unblock the chain function */
|
|
|
|
GST_QUEUE_MUTEX_LOCK (queue);
|
2012-02-08 14:16:46 +00:00
|
|
|
queue->srcresult = GST_FLOW_FLUSHING;
|
2005-08-23 18:17:01 +00:00
|
|
|
/* unblock the loop and chain functions */
|
2007-09-28 10:15:23 +00:00
|
|
|
GST_QUEUE_SIGNAL_ADD (queue);
|
|
|
|
GST_QUEUE_SIGNAL_DEL (queue);
|
Some docs updates
Original commit message from CVS:
* CHANGES-0.9:
* docs/design/part-TODO.txt:
* docs/design/part-events.txt:
Some docs updates
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_push), (gst_base_sink_activate_pull):
* gst/base/gstbasesrc.c: (gst_base_src_send_discont),
(gst_base_src_do_seek), (gst_base_src_event_handler),
(gst_base_src_loop):
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),
(gst_base_transform_configure_caps), (gst_base_transform_setcaps),
(gst_base_transform_get_size), (gst_base_transform_buffer_alloc),
(gst_base_transform_event), (gst_base_transform_handle_buffer),
(gst_base_transform_set_passthrough),
(gst_base_transform_is_passthrough):
* gst/elements/gstfakesink.c: (gst_fake_sink_event):
* gst/elements/gstfilesink.c: (gst_file_sink_event):
Event updates.
* gst/gstbuffer.h:
Use faster casts.
* gst/gstelement.c: (gst_element_seek):
* gst/gstelement.h:
Update gst_element_seek.
* gst/gstevent.c: (gst_event_finalize), (_gst_event_copy),
(gst_event_new), (gst_event_new_custom), (gst_event_get_structure),
(gst_event_new_flush_start), (gst_event_new_flush_stop),
(gst_event_new_eos), (gst_event_new_newsegment),
(gst_event_parse_newsegment), (gst_event_new_tag),
(gst_event_parse_tag), (gst_event_new_filler), (gst_event_new_qos),
(gst_event_parse_qos), (gst_event_new_seek),
(gst_event_parse_seek), (gst_event_new_navigation):
* gst/gstevent.h:
Make GstEvent use GstStructure. Add parsing code, make sure the
API is sufficiently generic.
Mark possible directions of events and serialization.
* gst/gstmessage.c: (gst_message_init), (gst_message_finalize),
(_gst_message_copy), (gst_message_new_segment_start),
(gst_message_new_segment_done), (gst_message_new_custom),
(gst_message_parse_segment_start),
(gst_message_parse_segment_done):
Small cleanups.
* gst/gstpad.c: (gst_pad_get_caps_unlocked), (gst_pad_accept_caps),
(gst_pad_set_caps), (gst_pad_send_event):
Update for new events.
Catch events sent in wrong directions.
* gst/gstqueue.c: (gst_queue_link_src),
(gst_queue_handle_sink_event), (gst_queue_chain), (gst_queue_loop),
(gst_queue_handle_src_query):
Event updates.
* gst/gsttag.c:
* gst/gsttag.h:
Remove event code from this file.
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_event),
(gst_dp_event_from_packet):
Event updates.
2005-07-27 18:33:03 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2006-02-28 10:52:02 +00:00
|
|
|
/* make sure it pauses, this should happen since we sent
|
|
|
|
* flush_start downstream. */
|
Some docs updates
Original commit message from CVS:
* CHANGES-0.9:
* docs/design/part-TODO.txt:
* docs/design/part-events.txt:
Some docs updates
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_push), (gst_base_sink_activate_pull):
* gst/base/gstbasesrc.c: (gst_base_src_send_discont),
(gst_base_src_do_seek), (gst_base_src_event_handler),
(gst_base_src_loop):
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),
(gst_base_transform_configure_caps), (gst_base_transform_setcaps),
(gst_base_transform_get_size), (gst_base_transform_buffer_alloc),
(gst_base_transform_event), (gst_base_transform_handle_buffer),
(gst_base_transform_set_passthrough),
(gst_base_transform_is_passthrough):
* gst/elements/gstfakesink.c: (gst_fake_sink_event):
* gst/elements/gstfilesink.c: (gst_file_sink_event):
Event updates.
* gst/gstbuffer.h:
Use faster casts.
* gst/gstelement.c: (gst_element_seek):
* gst/gstelement.h:
Update gst_element_seek.
* gst/gstevent.c: (gst_event_finalize), (_gst_event_copy),
(gst_event_new), (gst_event_new_custom), (gst_event_get_structure),
(gst_event_new_flush_start), (gst_event_new_flush_stop),
(gst_event_new_eos), (gst_event_new_newsegment),
(gst_event_parse_newsegment), (gst_event_new_tag),
(gst_event_parse_tag), (gst_event_new_filler), (gst_event_new_qos),
(gst_event_parse_qos), (gst_event_new_seek),
(gst_event_parse_seek), (gst_event_new_navigation):
* gst/gstevent.h:
Make GstEvent use GstStructure. Add parsing code, make sure the
API is sufficiently generic.
Mark possible directions of events and serialization.
* gst/gstmessage.c: (gst_message_init), (gst_message_finalize),
(_gst_message_copy), (gst_message_new_segment_start),
(gst_message_new_segment_done), (gst_message_new_custom),
(gst_message_parse_segment_start),
(gst_message_parse_segment_done):
Small cleanups.
* gst/gstpad.c: (gst_pad_get_caps_unlocked), (gst_pad_accept_caps),
(gst_pad_set_caps), (gst_pad_send_event):
Update for new events.
Catch events sent in wrong directions.
* gst/gstqueue.c: (gst_queue_link_src),
(gst_queue_handle_sink_event), (gst_queue_chain), (gst_queue_loop),
(gst_queue_handle_src_query):
Event updates.
* gst/gsttag.c:
* gst/gsttag.h:
Remove event code from this file.
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_event),
(gst_dp_event_from_packet):
Event updates.
2005-07-27 18:33:03 +00:00
|
|
|
gst_pad_pause_task (queue->srcpad);
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue, "loop stopped");
|
2016-03-11 14:04:52 +00:00
|
|
|
|
|
|
|
/* unblock query handler after the streaming thread is shut down.
|
|
|
|
* Otherwise downstream might have a query that is already unreffed
|
|
|
|
* upstream */
|
|
|
|
GST_QUEUE_MUTEX_LOCK (queue);
|
|
|
|
queue->last_query = FALSE;
|
|
|
|
g_cond_signal (&queue->query_handled);
|
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
2013-12-11 13:42:34 +00:00
|
|
|
break;
|
Some docs updates
Original commit message from CVS:
* CHANGES-0.9:
* docs/design/part-TODO.txt:
* docs/design/part-events.txt:
Some docs updates
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_push), (gst_base_sink_activate_pull):
* gst/base/gstbasesrc.c: (gst_base_src_send_discont),
(gst_base_src_do_seek), (gst_base_src_event_handler),
(gst_base_src_loop):
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),
(gst_base_transform_configure_caps), (gst_base_transform_setcaps),
(gst_base_transform_get_size), (gst_base_transform_buffer_alloc),
(gst_base_transform_event), (gst_base_transform_handle_buffer),
(gst_base_transform_set_passthrough),
(gst_base_transform_is_passthrough):
* gst/elements/gstfakesink.c: (gst_fake_sink_event):
* gst/elements/gstfilesink.c: (gst_file_sink_event):
Event updates.
* gst/gstbuffer.h:
Use faster casts.
* gst/gstelement.c: (gst_element_seek):
* gst/gstelement.h:
Update gst_element_seek.
* gst/gstevent.c: (gst_event_finalize), (_gst_event_copy),
(gst_event_new), (gst_event_new_custom), (gst_event_get_structure),
(gst_event_new_flush_start), (gst_event_new_flush_stop),
(gst_event_new_eos), (gst_event_new_newsegment),
(gst_event_parse_newsegment), (gst_event_new_tag),
(gst_event_parse_tag), (gst_event_new_filler), (gst_event_new_qos),
(gst_event_parse_qos), (gst_event_new_seek),
(gst_event_parse_seek), (gst_event_new_navigation):
* gst/gstevent.h:
Make GstEvent use GstStructure. Add parsing code, make sure the
API is sufficiently generic.
Mark possible directions of events and serialization.
* gst/gstmessage.c: (gst_message_init), (gst_message_finalize),
(_gst_message_copy), (gst_message_new_segment_start),
(gst_message_new_segment_done), (gst_message_new_custom),
(gst_message_parse_segment_start),
(gst_message_parse_segment_done):
Small cleanups.
* gst/gstpad.c: (gst_pad_get_caps_unlocked), (gst_pad_accept_caps),
(gst_pad_set_caps), (gst_pad_send_event):
Update for new events.
Catch events sent in wrong directions.
* gst/gstqueue.c: (gst_queue_link_src),
(gst_queue_handle_sink_event), (gst_queue_chain), (gst_queue_loop),
(gst_queue_handle_src_query):
Event updates.
* gst/gsttag.c:
* gst/gsttag.h:
Remove event code from this file.
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_event),
(gst_dp_event_from_packet):
Event updates.
2005-07-27 18:33:03 +00:00
|
|
|
case GST_EVENT_FLUSH_STOP:
|
2005-10-24 15:41:48 +00:00
|
|
|
/* forward event */
|
2013-12-11 13:42:34 +00:00
|
|
|
ret = gst_pad_push_event (queue->srcpad, event);
|
Some docs updates
Original commit message from CVS:
* CHANGES-0.9:
* docs/design/part-TODO.txt:
* docs/design/part-events.txt:
Some docs updates
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_push), (gst_base_sink_activate_pull):
* gst/base/gstbasesrc.c: (gst_base_src_send_discont),
(gst_base_src_do_seek), (gst_base_src_event_handler),
(gst_base_src_loop):
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),
(gst_base_transform_configure_caps), (gst_base_transform_setcaps),
(gst_base_transform_get_size), (gst_base_transform_buffer_alloc),
(gst_base_transform_event), (gst_base_transform_handle_buffer),
(gst_base_transform_set_passthrough),
(gst_base_transform_is_passthrough):
* gst/elements/gstfakesink.c: (gst_fake_sink_event):
* gst/elements/gstfilesink.c: (gst_file_sink_event):
Event updates.
* gst/gstbuffer.h:
Use faster casts.
* gst/gstelement.c: (gst_element_seek):
* gst/gstelement.h:
Update gst_element_seek.
* gst/gstevent.c: (gst_event_finalize), (_gst_event_copy),
(gst_event_new), (gst_event_new_custom), (gst_event_get_structure),
(gst_event_new_flush_start), (gst_event_new_flush_stop),
(gst_event_new_eos), (gst_event_new_newsegment),
(gst_event_parse_newsegment), (gst_event_new_tag),
(gst_event_parse_tag), (gst_event_new_filler), (gst_event_new_qos),
(gst_event_parse_qos), (gst_event_new_seek),
(gst_event_parse_seek), (gst_event_new_navigation):
* gst/gstevent.h:
Make GstEvent use GstStructure. Add parsing code, make sure the
API is sufficiently generic.
Mark possible directions of events and serialization.
* gst/gstmessage.c: (gst_message_init), (gst_message_finalize),
(_gst_message_copy), (gst_message_new_segment_start),
(gst_message_new_segment_done), (gst_message_new_custom),
(gst_message_parse_segment_start),
(gst_message_parse_segment_done):
Small cleanups.
* gst/gstpad.c: (gst_pad_get_caps_unlocked), (gst_pad_accept_caps),
(gst_pad_set_caps), (gst_pad_send_event):
Update for new events.
Catch events sent in wrong directions.
* gst/gstqueue.c: (gst_queue_link_src),
(gst_queue_handle_sink_event), (gst_queue_chain), (gst_queue_loop),
(gst_queue_handle_src_query):
Event updates.
* gst/gsttag.c:
* gst/gsttag.h:
Remove event code from this file.
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_event),
(gst_dp_event_from_packet):
Event updates.
2005-07-27 18:33:03 +00:00
|
|
|
|
|
|
|
GST_QUEUE_MUTEX_LOCK (queue);
|
2013-05-27 11:01:43 +00:00
|
|
|
gst_queue_locked_flush (queue, FALSE);
|
Some docs updates
Original commit message from CVS:
* CHANGES-0.9:
* docs/design/part-TODO.txt:
* docs/design/part-events.txt:
Some docs updates
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_push), (gst_base_sink_activate_pull):
* gst/base/gstbasesrc.c: (gst_base_src_send_discont),
(gst_base_src_do_seek), (gst_base_src_event_handler),
(gst_base_src_loop):
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),
(gst_base_transform_configure_caps), (gst_base_transform_setcaps),
(gst_base_transform_get_size), (gst_base_transform_buffer_alloc),
(gst_base_transform_event), (gst_base_transform_handle_buffer),
(gst_base_transform_set_passthrough),
(gst_base_transform_is_passthrough):
* gst/elements/gstfakesink.c: (gst_fake_sink_event):
* gst/elements/gstfilesink.c: (gst_file_sink_event):
Event updates.
* gst/gstbuffer.h:
Use faster casts.
* gst/gstelement.c: (gst_element_seek):
* gst/gstelement.h:
Update gst_element_seek.
* gst/gstevent.c: (gst_event_finalize), (_gst_event_copy),
(gst_event_new), (gst_event_new_custom), (gst_event_get_structure),
(gst_event_new_flush_start), (gst_event_new_flush_stop),
(gst_event_new_eos), (gst_event_new_newsegment),
(gst_event_parse_newsegment), (gst_event_new_tag),
(gst_event_parse_tag), (gst_event_new_filler), (gst_event_new_qos),
(gst_event_parse_qos), (gst_event_new_seek),
(gst_event_parse_seek), (gst_event_new_navigation):
* gst/gstevent.h:
Make GstEvent use GstStructure. Add parsing code, make sure the
API is sufficiently generic.
Mark possible directions of events and serialization.
* gst/gstmessage.c: (gst_message_init), (gst_message_finalize),
(_gst_message_copy), (gst_message_new_segment_start),
(gst_message_new_segment_done), (gst_message_new_custom),
(gst_message_parse_segment_start),
(gst_message_parse_segment_done):
Small cleanups.
* gst/gstpad.c: (gst_pad_get_caps_unlocked), (gst_pad_accept_caps),
(gst_pad_set_caps), (gst_pad_send_event):
Update for new events.
Catch events sent in wrong directions.
* gst/gstqueue.c: (gst_queue_link_src),
(gst_queue_handle_sink_event), (gst_queue_chain), (gst_queue_loop),
(gst_queue_handle_src_query):
Event updates.
* gst/gsttag.c:
* gst/gsttag.h:
Remove event code from this file.
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_event),
(gst_dp_event_from_packet):
Event updates.
2005-07-27 18:33:03 +00:00
|
|
|
queue->srcresult = GST_FLOW_OK;
|
2007-09-14 20:24:22 +00:00
|
|
|
queue->eos = FALSE;
|
|
|
|
queue->unexpected = FALSE;
|
2014-08-21 13:02:16 +00:00
|
|
|
if (gst_pad_is_active (queue->srcpad)) {
|
|
|
|
gst_pad_start_task (queue->srcpad, (GstTaskFunction) gst_queue_loop,
|
|
|
|
queue->srcpad, NULL);
|
|
|
|
} else {
|
|
|
|
GST_INFO_OBJECT (queue->srcpad, "not re-starting task on srcpad, "
|
|
|
|
"pad not active any longer");
|
|
|
|
}
|
Some docs updates
Original commit message from CVS:
* CHANGES-0.9:
* docs/design/part-TODO.txt:
* docs/design/part-events.txt:
Some docs updates
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_push), (gst_base_sink_activate_pull):
* gst/base/gstbasesrc.c: (gst_base_src_send_discont),
(gst_base_src_do_seek), (gst_base_src_event_handler),
(gst_base_src_loop):
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),
(gst_base_transform_configure_caps), (gst_base_transform_setcaps),
(gst_base_transform_get_size), (gst_base_transform_buffer_alloc),
(gst_base_transform_event), (gst_base_transform_handle_buffer),
(gst_base_transform_set_passthrough),
(gst_base_transform_is_passthrough):
* gst/elements/gstfakesink.c: (gst_fake_sink_event):
* gst/elements/gstfilesink.c: (gst_file_sink_event):
Event updates.
* gst/gstbuffer.h:
Use faster casts.
* gst/gstelement.c: (gst_element_seek):
* gst/gstelement.h:
Update gst_element_seek.
* gst/gstevent.c: (gst_event_finalize), (_gst_event_copy),
(gst_event_new), (gst_event_new_custom), (gst_event_get_structure),
(gst_event_new_flush_start), (gst_event_new_flush_stop),
(gst_event_new_eos), (gst_event_new_newsegment),
(gst_event_parse_newsegment), (gst_event_new_tag),
(gst_event_parse_tag), (gst_event_new_filler), (gst_event_new_qos),
(gst_event_parse_qos), (gst_event_new_seek),
(gst_event_parse_seek), (gst_event_new_navigation):
* gst/gstevent.h:
Make GstEvent use GstStructure. Add parsing code, make sure the
API is sufficiently generic.
Mark possible directions of events and serialization.
* gst/gstmessage.c: (gst_message_init), (gst_message_finalize),
(_gst_message_copy), (gst_message_new_segment_start),
(gst_message_new_segment_done), (gst_message_new_custom),
(gst_message_parse_segment_start),
(gst_message_parse_segment_done):
Small cleanups.
* gst/gstpad.c: (gst_pad_get_caps_unlocked), (gst_pad_accept_caps),
(gst_pad_set_caps), (gst_pad_send_event):
Update for new events.
Catch events sent in wrong directions.
* gst/gstqueue.c: (gst_queue_link_src),
(gst_queue_handle_sink_event), (gst_queue_chain), (gst_queue_loop),
(gst_queue_handle_src_query):
Event updates.
* gst/gsttag.c:
* gst/gsttag.h:
Remove event code from this file.
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_event),
(gst_dp_event_from_packet):
Event updates.
2005-07-27 18:33:03 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
|
|
|
|
2006-01-19 13:30:31 +00:00
|
|
|
STATUS (queue, pad, "after flush");
|
2013-12-11 13:42:34 +00:00
|
|
|
break;
|
2005-03-21 17:34:02 +00:00
|
|
|
default:
|
2005-08-18 15:31:28 +00:00
|
|
|
if (GST_EVENT_IS_SERIALIZED (event)) {
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
/* serialized events go in the queue */
|
2012-10-29 12:08:31 +00:00
|
|
|
GST_QUEUE_MUTEX_LOCK (queue);
|
2017-08-11 08:12:09 +00:00
|
|
|
|
|
|
|
/* STREAM_START and SEGMENT reset the EOS status of a
|
|
|
|
* pad. Change the cached sinkpad flow result accordingly */
|
|
|
|
if (queue->srcresult == GST_FLOW_EOS
|
|
|
|
&& (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_START
|
|
|
|
|| GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT))
|
|
|
|
queue->srcresult = GST_FLOW_OK;
|
|
|
|
|
2012-10-29 12:08:31 +00:00
|
|
|
if (queue->srcresult != GST_FLOW_OK) {
|
|
|
|
/* Errors in sticky event pushing are no problem and ignored here
|
|
|
|
* as they will cause more meaningful errors during data flow.
|
|
|
|
* For EOS events, that are not followed by data flow, we still
|
2014-08-13 09:15:03 +00:00
|
|
|
* return FALSE here though and report an error.
|
2012-10-29 12:08:31 +00:00
|
|
|
*/
|
2014-08-13 09:15:03 +00:00
|
|
|
if (!GST_EVENT_IS_STICKY (event)) {
|
2014-09-22 07:33:04 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
2012-10-29 12:08:31 +00:00
|
|
|
goto out_flow_error;
|
2015-12-14 10:16:50 +00:00
|
|
|
} else if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
|
2014-08-13 09:15:03 +00:00
|
|
|
if (queue->srcresult == GST_FLOW_NOT_LINKED
|
|
|
|
|| queue->srcresult < GST_FLOW_EOS) {
|
2014-09-22 07:33:04 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
2016-08-23 16:27:58 +00:00
|
|
|
GST_ELEMENT_FLOW_ERROR (queue, queue->srcresult);
|
2014-09-23 12:31:29 +00:00
|
|
|
} else {
|
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
2014-08-13 09:15:03 +00:00
|
|
|
}
|
|
|
|
goto out_flow_error;
|
|
|
|
}
|
2012-10-29 12:08:31 +00:00
|
|
|
}
|
2017-08-11 08:12:09 +00:00
|
|
|
|
|
|
|
/* refuse more events on EOS unless they unset the EOS status */
|
|
|
|
if (queue->eos) {
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_STREAM_START:
|
|
|
|
case GST_EVENT_SEGMENT:
|
|
|
|
/* Restart the loop */
|
|
|
|
if (GST_PAD_MODE (queue->srcpad) == GST_PAD_MODE_PUSH) {
|
|
|
|
queue->srcresult = GST_FLOW_OK;
|
|
|
|
queue->eos = FALSE;
|
|
|
|
queue->unexpected = FALSE;
|
|
|
|
gst_pad_start_task (queue->srcpad,
|
|
|
|
(GstTaskFunction) gst_queue_loop, queue->srcpad, NULL);
|
|
|
|
} else {
|
|
|
|
queue->eos = FALSE;
|
|
|
|
queue->unexpected = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto out_eos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-08 07:47:44 +00:00
|
|
|
gst_queue_locked_enqueue_event (queue, event);
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
2005-08-18 15:31:28 +00:00
|
|
|
} else {
|
2012-10-31 19:33:30 +00:00
|
|
|
/* non-serialized events are forwarded downstream immediately */
|
2013-12-11 13:42:34 +00:00
|
|
|
ret = gst_pad_push_event (queue->srcpad, event);
|
2005-08-18 15:31:28 +00:00
|
|
|
}
|
2004-06-11 15:18:58 +00:00
|
|
|
break;
|
2003-12-14 13:14:35 +00:00
|
|
|
}
|
2017-01-02 15:13:30 +00:00
|
|
|
if (ret == FALSE) {
|
|
|
|
GST_ERROR_OBJECT (queue, "Failed to push event");
|
2015-11-12 16:15:37 +00:00
|
|
|
return GST_FLOW_ERROR;
|
2017-01-02 15:13:30 +00:00
|
|
|
}
|
2015-11-12 16:15:37 +00:00
|
|
|
return GST_FLOW_OK;
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
2007-09-14 20:24:22 +00:00
|
|
|
out_eos:
|
|
|
|
{
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue, "refusing event, we are EOS");
|
2007-05-18 11:20:33 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
2009-02-22 17:53:10 +00:00
|
|
|
gst_event_unref (event);
|
2015-11-12 16:15:37 +00:00
|
|
|
return GST_FLOW_EOS;
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
}
|
2012-10-29 12:08:31 +00:00
|
|
|
out_flow_error:
|
|
|
|
{
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
|
|
|
"refusing event, we have a downstream flow error: %s",
|
|
|
|
gst_flow_get_name (queue->srcresult));
|
|
|
|
gst_event_unref (event);
|
2015-11-12 16:15:37 +00:00
|
|
|
return queue->srcresult;
|
2012-10-29 12:08:31 +00:00
|
|
|
}
|
2003-12-14 13:14:35 +00:00
|
|
|
}
|
|
|
|
|
2011-11-09 16:36:00 +00:00
|
|
|
static gboolean
|
2011-11-16 16:22:56 +00:00
|
|
|
gst_queue_handle_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
2011-11-09 16:36:00 +00:00
|
|
|
{
|
2012-03-14 14:42:33 +00:00
|
|
|
GstQueue *queue = GST_QUEUE_CAST (parent);
|
2011-11-09 16:36:00 +00:00
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
|
|
|
default:
|
2012-03-14 14:42:33 +00:00
|
|
|
if (G_UNLIKELY (GST_QUERY_IS_SERIALIZED (query))) {
|
2015-05-30 13:27:05 +00:00
|
|
|
GstQueueItem qitem;
|
2013-05-27 13:59:07 +00:00
|
|
|
|
2012-03-14 14:42:33 +00:00
|
|
|
GST_QUEUE_MUTEX_LOCK_CHECK (queue, out_flushing);
|
|
|
|
GST_LOG_OBJECT (queue, "queuing query %p (%s)", query,
|
|
|
|
GST_QUERY_TYPE_NAME (query));
|
2015-05-30 13:27:05 +00:00
|
|
|
qitem.item = GST_MINI_OBJECT_CAST (query);
|
|
|
|
qitem.is_query = TRUE;
|
|
|
|
qitem.size = 0;
|
|
|
|
gst_queue_array_push_tail_struct (queue->queue, &qitem);
|
2012-03-14 14:42:33 +00:00
|
|
|
GST_QUEUE_SIGNAL_ADD (queue);
|
2016-12-13 18:51:17 +00:00
|
|
|
while (queue->srcresult == GST_FLOW_OK &&
|
|
|
|
queue->last_handled_query != query)
|
|
|
|
g_cond_wait (&queue->query_handled, &queue->qlock);
|
|
|
|
queue->last_handled_query = NULL;
|
2013-05-27 13:59:07 +00:00
|
|
|
if (queue->srcresult != GST_FLOW_OK)
|
|
|
|
goto out_flushing;
|
2012-03-14 14:42:33 +00:00
|
|
|
res = queue->last_query;
|
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
|
|
|
} else {
|
|
|
|
res = gst_pad_query_default (pad, parent, query);
|
|
|
|
}
|
2011-11-09 16:36:00 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return res;
|
2012-03-14 14:42:33 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
out_flushing:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (queue, "we are flushing");
|
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-11-09 16:36:00 +00:00
|
|
|
}
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
static gboolean
|
|
|
|
gst_queue_is_empty (GstQueue * queue)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2013-05-27 13:59:07 +00:00
|
|
|
GstQueueItem *head;
|
2012-07-09 13:37:28 +00:00
|
|
|
|
2015-05-30 13:27:05 +00:00
|
|
|
head = gst_queue_array_peek_head_struct (queue->queue);
|
|
|
|
|
|
|
|
if (head == NULL)
|
2009-06-15 19:11:05 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2012-07-09 13:37:28 +00:00
|
|
|
/* Only consider the queue empty if the minimum thresholds
|
|
|
|
* are not reached and data is at the queue head. Otherwise
|
|
|
|
* we would block forever on serialized queries.
|
|
|
|
*/
|
2013-05-27 13:59:07 +00:00
|
|
|
if (!GST_IS_BUFFER (head->item) && !GST_IS_BUFFER_LIST (head->item))
|
2012-07-09 13:37:28 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2009-06-11 13:00:52 +00:00
|
|
|
/* It is possible that a max size is reached before all min thresholds are.
|
|
|
|
* Therefore, only consider it empty if it is not filled. */
|
2009-06-15 19:11:05 +00:00
|
|
|
return ((queue->min_threshold.buffers > 0 &&
|
|
|
|
queue->cur_level.buffers < queue->min_threshold.buffers) ||
|
2010-12-26 21:20:31 +00:00
|
|
|
(queue->min_threshold.bytes > 0 &&
|
2009-06-15 19:11:05 +00:00
|
|
|
queue->cur_level.bytes < queue->min_threshold.bytes) ||
|
|
|
|
(queue->min_threshold.time > 0 &&
|
|
|
|
queue->cur_level.time < queue->min_threshold.time)) &&
|
|
|
|
!gst_queue_is_filled (queue);
|
2005-03-21 17:34:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_queue_is_filled (GstQueue * queue)
|
|
|
|
{
|
2010-12-26 21:20:31 +00:00
|
|
|
return (((queue->max_size.buffers > 0 &&
|
2005-03-21 17:34:02 +00:00
|
|
|
queue->cur_level.buffers >= queue->max_size.buffers) ||
|
2010-12-26 21:20:31 +00:00
|
|
|
(queue->max_size.bytes > 0 &&
|
2005-03-21 17:34:02 +00:00
|
|
|
queue->cur_level.bytes >= queue->max_size.bytes) ||
|
2010-12-26 21:20:31 +00:00
|
|
|
(queue->max_size.time > 0 &&
|
2005-03-21 17:34:02 +00:00
|
|
|
queue->cur_level.time >= queue->max_size.time)));
|
|
|
|
}
|
|
|
|
|
2008-04-30 09:35:43 +00:00
|
|
|
static void
|
|
|
|
gst_queue_leak_downstream (GstQueue * queue)
|
|
|
|
{
|
|
|
|
/* for as long as the queue is filled, dequeue an item and discard it */
|
2008-04-30 14:20:48 +00:00
|
|
|
while (gst_queue_is_filled (queue)) {
|
2008-04-30 09:35:43 +00:00
|
|
|
GstMiniObject *leak;
|
|
|
|
|
2012-03-14 14:42:33 +00:00
|
|
|
leak = gst_queue_locked_dequeue (queue);
|
2008-04-30 09:35:43 +00:00
|
|
|
/* there is nothing to dequeue and the queue is still filled.. This should
|
|
|
|
* not happen */
|
|
|
|
g_assert (leak != NULL);
|
|
|
|
|
|
|
|
GST_CAT_DEBUG_OBJECT (queue_dataflow, queue,
|
|
|
|
"queue is full, leaking item %p on downstream end", leak);
|
2013-05-09 10:50:20 +00:00
|
|
|
if (GST_IS_EVENT (leak) && GST_EVENT_IS_STICKY (leak)) {
|
|
|
|
GST_CAT_DEBUG_OBJECT (queue_dataflow, queue,
|
|
|
|
"Storing sticky event %s on srcpad", GST_EVENT_TYPE_NAME (leak));
|
|
|
|
gst_pad_store_sticky_event (queue->srcpad, GST_EVENT_CAST (leak));
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:43:17 +00:00
|
|
|
if (!GST_IS_QUERY (leak))
|
|
|
|
gst_mini_object_unref (leak);
|
2008-04-30 14:20:48 +00:00
|
|
|
|
|
|
|
/* last buffer needs to get a DISCONT flag */
|
|
|
|
queue->head_needs_discont = TRUE;
|
|
|
|
}
|
2008-04-30 09:35:43 +00:00
|
|
|
}
|
|
|
|
|
2015-02-17 09:44:40 +00:00
|
|
|
static gboolean
|
|
|
|
discont_first_buffer (GstBuffer ** buffer, guint i, gpointer user_data)
|
|
|
|
{
|
|
|
|
GstQueue *queue = user_data;
|
|
|
|
GstBuffer *subbuffer = gst_buffer_make_writable (*buffer);
|
|
|
|
|
|
|
|
if (subbuffer) {
|
|
|
|
*buffer = subbuffer;
|
|
|
|
GST_BUFFER_FLAG_SET (*buffer, GST_BUFFER_FLAG_DISCONT);
|
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (queue, "Could not mark buffer as DISCONT");
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
static GstFlowReturn
|
2015-02-17 09:44:40 +00:00
|
|
|
gst_queue_chain_buffer_or_list (GstPad * pad, GstObject * parent,
|
|
|
|
GstMiniObject * obj, gboolean is_list)
|
2005-03-21 17:34:02 +00:00
|
|
|
{
|
|
|
|
GstQueue *queue;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2011-11-17 11:40:45 +00:00
|
|
|
queue = GST_QUEUE_CAST (parent);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-10-27 20:28:31 +00:00
|
|
|
/* we have to lock the queue since we span threads */
|
gst/base/gstbasesrc.*: Add a gboolean to decide when to push out a discont.
Original commit message from CVS:
* gst/base/gstbasesrc.c: (gst_base_src_init),
(gst_base_src_do_seek), (gst_base_src_loop), (gst_base_src_start):
* gst/base/gstbasesrc.h:
Add a gboolean to decide when to push out a discont.
* gst/gstqueue.c: (gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_loop), (gst_queue_handle_src_query),
(gst_queue_sink_activate_push), (gst_queue_src_activate_push),
(gst_queue_set_property), (gst_queue_get_property):
Some cleanups.
* tests/threadstate/threadstate1.c: (main):
Make a thread test compile and run... very silly..
2005-07-20 10:58:10 +00:00
|
|
|
GST_QUEUE_MUTEX_LOCK_CHECK (queue, out_flushing);
|
2007-09-14 20:24:22 +00:00
|
|
|
/* when we received EOS, we refuse any more data */
|
|
|
|
if (queue->eos)
|
|
|
|
goto out_eos;
|
|
|
|
if (queue->unexpected)
|
|
|
|
goto out_unexpected;
|
2005-07-19 17:46:37 +00:00
|
|
|
|
2015-02-17 09:44:40 +00:00
|
|
|
if (!is_list) {
|
|
|
|
GstClockTime duration, timestamp;
|
|
|
|
GstBuffer *buffer = GST_BUFFER_CAST (obj);
|
|
|
|
|
2015-10-27 07:48:07 +00:00
|
|
|
timestamp = GST_BUFFER_DTS_OR_PTS (buffer);
|
2015-02-17 09:44:40 +00:00
|
|
|
duration = GST_BUFFER_DURATION (buffer);
|
2007-05-10 15:21:20 +00:00
|
|
|
|
2015-02-17 09:44:40 +00:00
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue, "received buffer %p of size %"
|
|
|
|
G_GSIZE_FORMAT ", time %" GST_TIME_FORMAT ", duration %"
|
|
|
|
GST_TIME_FORMAT, buffer, gst_buffer_get_size (buffer),
|
|
|
|
GST_TIME_ARGS (timestamp), GST_TIME_ARGS (duration));
|
|
|
|
} else {
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
|
|
|
"received buffer list %p with %u buffers", obj,
|
|
|
|
gst_buffer_list_length (GST_BUFFER_LIST_CAST (obj)));
|
|
|
|
}
|
2003-12-13 17:12:46 +00:00
|
|
|
|
|
|
|
/* We make space available if we're "full" according to whatever
|
|
|
|
* the user defined as "full". Note that this only applies to buffers.
|
|
|
|
* We always handle events and they don't count in our statistics. */
|
2005-03-21 17:34:02 +00:00
|
|
|
while (gst_queue_is_filled (queue)) {
|
2010-08-27 12:35:49 +00:00
|
|
|
if (!queue->silent) {
|
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
|
|
|
g_signal_emit (queue, gst_queue_signals[SIGNAL_OVERRUN], 0);
|
|
|
|
GST_QUEUE_MUTEX_LOCK_CHECK (queue, out_flushing);
|
2010-10-19 13:53:26 +00:00
|
|
|
/* we recheck, the signal could have changed the thresholds */
|
|
|
|
if (!gst_queue_is_filled (queue))
|
|
|
|
break;
|
2010-08-27 12:35:49 +00:00
|
|
|
}
|
2005-07-19 17:46:37 +00:00
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
/* how are we going to make space for this buffer? */
|
|
|
|
switch (queue->leaky) {
|
|
|
|
case GST_QUEUE_LEAK_UPSTREAM:
|
2008-02-20 15:44:33 +00:00
|
|
|
/* next buffer needs to get a DISCONT flag */
|
|
|
|
queue->tail_needs_discont = TRUE;
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
/* leak current buffer */
|
gst/elements/gstfilesrc.c: compute mapsize correctly
Original commit message from CVS:
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
compute mapsize correctly
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
use correct datatypes when calling a varargs function
* gst/elements/gsttypefindelement.c: (stop_typefinding):
push a DISCONT event as first thing
* gst/gst_private.h:
* gst/gstinfo.c: (_gst_debug_init):
remove GST_DATAFLOW debugging category
* gst/gstbin.c: (gst_bin_iterate):
use GST_SCHEDULING category
* gst/gstpad.c: (gst_pad_get_type), (_invent_event),
(gst_pad_push), (gst_pad_pull), (gst_pad_call_chain_function),
(gst_pad_call_get_function):
add GST_DATAFLOW to easily track flow of buffers or events.
* gst/gstqueue.c: (gst_queue_get_type),
(gst_queue_handle_pending_events), (gst_queue_chain),
(gst_queue_get), (gst_queue_handle_src_event):
use own static debugging category GST_DATAFLOW for dataflow,
use DEBUG category for showing which path events go, use LOG
category for buffers.
2004-05-11 16:20:41 +00:00
|
|
|
GST_CAT_DEBUG_OBJECT (queue_dataflow, queue,
|
2004-03-15 19:27:17 +00:00
|
|
|
"queue is full, leaking buffer on upstream end");
|
|
|
|
/* now we can clean up and exit right away */
|
|
|
|
goto out_unref;
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
case GST_QUEUE_LEAK_DOWNSTREAM:
|
2008-04-30 09:35:43 +00:00
|
|
|
gst_queue_leak_downstream (queue);
|
2004-03-15 19:27:17 +00:00
|
|
|
break;
|
2003-12-13 17:12:46 +00:00
|
|
|
default:
|
2004-03-15 19:27:17 +00:00
|
|
|
g_warning ("Unknown leaky type, using default");
|
|
|
|
/* fall-through */
|
2003-12-13 17:12:46 +00:00
|
|
|
case GST_QUEUE_NO_LEAK:
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
{
|
|
|
|
GST_CAT_DEBUG_OBJECT (queue_dataflow, queue,
|
|
|
|
"queue is full, waiting for free space");
|
gst/: Implement gst_pad_pause/start/stop_task(), take STREAM lock in task function.
Original commit message from CVS:
* gst/base/gstadapter.c: (gst_adapter_peek), (gst_adapter_flush):
* gst/base/gstbasesink.c: (gst_basesink_preroll_queue_push),
(gst_basesink_finish_preroll), (gst_basesink_chain),
(gst_basesink_loop), (gst_basesink_activate),
(gst_basesink_change_state):
* gst/base/gstbasesrc.c: (gst_basesrc_do_seek),
(gst_basesrc_get_range), (gst_basesrc_loop),
(gst_basesrc_activate):
* gst/elements/gsttee.c: (gst_tee_sink_activate):
* gst/gstpad.c: (gst_pad_dispose), (gst_real_pad_class_init),
(gst_real_pad_init), (gst_real_pad_set_property),
(gst_real_pad_get_property), (gst_pad_set_active),
(gst_pad_is_active), (gst_pad_get_query_types), (gst_pad_unlink),
(gst_pad_link_prepare), (gst_pad_link), (gst_pad_get_real_parent),
(gst_real_pad_get_caps_unlocked), (gst_pad_peer_get_caps),
(gst_pad_accept_caps), (gst_pad_get_peer), (gst_pad_realize),
(gst_pad_event_default_dispatch), (gst_pad_event_default),
(gst_pad_dispatcher), (gst_pad_query), (gst_real_pad_dispose),
(gst_pad_save_thyself), (handle_pad_block), (gst_pad_chain),
(gst_pad_push), (gst_pad_get_range), (gst_pad_pull_range),
(gst_pad_send_event), (gst_pad_start_task), (gst_pad_pause_task),
(gst_pad_stop_task):
* gst/gstpad.h:
* gst/gstqueue.c: (gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_loop), (gst_queue_src_activate):
* gst/gsttask.c: (gst_task_init), (gst_task_set_lock),
(gst_task_get_state):
* gst/gsttask.h:
* gst/schedulers/threadscheduler.c:
(gst_thread_scheduler_task_start), (gst_thread_scheduler_func):
Implement gst_pad_pause/start/stop_task(), take STREAM lock
in task function.
Remove ACTIVE pad flag, use FLUSHING everywhere
Added _pad_chain(), _pad_get_range() to call chain/getrange
functions.
Add locks around IS_FLUSHING when reading.
Take STREAM lock in chain(), get_range() functions so plugins
don't need to take it anymore.
2005-05-25 11:50:11 +00:00
|
|
|
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
/* don't leak. Instead, wait for space to be available */
|
|
|
|
do {
|
|
|
|
/* for as long as the queue is filled, wait till an item was deleted. */
|
|
|
|
GST_QUEUE_WAIT_DEL_CHECK (queue, out_flushing);
|
|
|
|
} while (gst_queue_is_filled (queue));
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2007-09-28 10:22:40 +00:00
|
|
|
GST_CAT_DEBUG_OBJECT (queue_dataflow, queue, "queue is not full");
|
|
|
|
|
2010-08-27 12:35:49 +00:00
|
|
|
if (!queue->silent) {
|
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
|
|
|
g_signal_emit (queue, gst_queue_signals[SIGNAL_RUNNING], 0);
|
|
|
|
GST_QUEUE_MUTEX_LOCK_CHECK (queue, out_flushing);
|
|
|
|
}
|
2004-03-15 19:27:17 +00:00
|
|
|
break;
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
}
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
2000-02-13 13:43:32 +00:00
|
|
|
}
|
|
|
|
|
2008-02-20 15:44:33 +00:00
|
|
|
if (queue->tail_needs_discont) {
|
2015-02-17 09:44:40 +00:00
|
|
|
if (!is_list) {
|
|
|
|
GstBuffer *buffer = GST_BUFFER_CAST (obj);
|
|
|
|
GstBuffer *subbuffer = gst_buffer_make_writable (buffer);
|
|
|
|
|
|
|
|
if (subbuffer) {
|
|
|
|
buffer = subbuffer;
|
|
|
|
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
|
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (queue, "Could not mark buffer as DISCONT");
|
|
|
|
}
|
2008-02-21 10:22:36 +00:00
|
|
|
|
2015-02-17 09:44:40 +00:00
|
|
|
obj = GST_MINI_OBJECT_CAST (buffer);
|
2008-02-21 10:22:36 +00:00
|
|
|
} else {
|
2015-02-17 09:44:40 +00:00
|
|
|
GstBufferList *buffer_list = GST_BUFFER_LIST_CAST (obj);
|
|
|
|
|
|
|
|
buffer_list = gst_buffer_list_make_writable (buffer_list);
|
|
|
|
gst_buffer_list_foreach (buffer_list, discont_first_buffer, queue);
|
|
|
|
obj = GST_MINI_OBJECT_CAST (buffer_list);
|
2008-02-21 10:22:36 +00:00
|
|
|
}
|
2008-02-20 15:44:33 +00:00
|
|
|
queue->tail_needs_discont = FALSE;
|
|
|
|
}
|
|
|
|
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
/* put buffer in queue now */
|
2015-02-17 09:44:40 +00:00
|
|
|
if (is_list)
|
|
|
|
gst_queue_locked_enqueue_buffer_list (queue, obj);
|
|
|
|
else
|
|
|
|
gst_queue_locked_enqueue_buffer (queue, obj);
|
gst/base/gstbasesrc.*: Add a gboolean to decide when to push out a discont.
Original commit message from CVS:
* gst/base/gstbasesrc.c: (gst_base_src_init),
(gst_base_src_do_seek), (gst_base_src_loop), (gst_base_src_start):
* gst/base/gstbasesrc.h:
Add a gboolean to decide when to push out a discont.
* gst/gstqueue.c: (gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_loop), (gst_queue_handle_src_query),
(gst_queue_sink_activate_push), (gst_queue_src_activate_push),
(gst_queue_set_property), (gst_queue_get_property):
Some cleanups.
* tests/threadstate/threadstate1.c: (main):
Make a thread test compile and run... very silly..
2005-07-20 10:58:10 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
return GST_FLOW_OK;
|
2003-03-21 20:53:26 +00:00
|
|
|
|
2005-07-19 17:46:37 +00:00
|
|
|
/* special conditions */
|
2003-03-21 20:53:26 +00:00
|
|
|
out_unref:
|
2005-07-14 18:10:04 +00:00
|
|
|
{
|
gst/base/gstbasesrc.*: Add a gboolean to decide when to push out a discont.
Original commit message from CVS:
* gst/base/gstbasesrc.c: (gst_base_src_init),
(gst_base_src_do_seek), (gst_base_src_loop), (gst_base_src_start):
* gst/base/gstbasesrc.h:
Add a gboolean to decide when to push out a discont.
* gst/gstqueue.c: (gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_loop), (gst_queue_handle_src_query),
(gst_queue_sink_activate_push), (gst_queue_src_activate_push),
(gst_queue_set_property), (gst_queue_get_property):
Some cleanups.
* tests/threadstate/threadstate1.c: (main):
Make a thread test compile and run... very silly..
2005-07-20 10:58:10 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2015-02-17 09:44:40 +00:00
|
|
|
gst_mini_object_unref (obj);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2005-07-14 18:10:04 +00:00
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
2005-03-21 17:34:02 +00:00
|
|
|
out_flushing:
|
2005-07-14 18:10:04 +00:00
|
|
|
{
|
2005-07-19 17:46:37 +00:00
|
|
|
GstFlowReturn ret = queue->srcresult;
|
|
|
|
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
2005-10-24 15:41:48 +00:00
|
|
|
"exit because task paused, reason: %s", gst_flow_get_name (ret));
|
gst/base/gstbasesrc.*: Add a gboolean to decide when to push out a discont.
Original commit message from CVS:
* gst/base/gstbasesrc.c: (gst_base_src_init),
(gst_base_src_do_seek), (gst_base_src_loop), (gst_base_src_start):
* gst/base/gstbasesrc.h:
Add a gboolean to decide when to push out a discont.
* gst/gstqueue.c: (gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_loop), (gst_queue_handle_src_query),
(gst_queue_sink_activate_push), (gst_queue_src_activate_push),
(gst_queue_set_property), (gst_queue_get_property):
Some cleanups.
* tests/threadstate/threadstate1.c: (main):
Make a thread test compile and run... very silly..
2005-07-20 10:58:10 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
2015-02-17 09:44:40 +00:00
|
|
|
gst_mini_object_unref (obj);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2005-07-19 17:46:37 +00:00
|
|
|
return ret;
|
2005-07-14 18:10:04 +00:00
|
|
|
}
|
2007-09-14 20:24:22 +00:00
|
|
|
out_eos:
|
|
|
|
{
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue, "exit because we received EOS");
|
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
|
|
|
|
2015-02-17 09:44:40 +00:00
|
|
|
gst_mini_object_unref (obj);
|
2007-09-14 20:24:22 +00:00
|
|
|
|
2011-10-10 09:33:51 +00:00
|
|
|
return GST_FLOW_EOS;
|
2007-09-14 20:24:22 +00:00
|
|
|
}
|
|
|
|
out_unexpected:
|
|
|
|
{
|
2011-10-10 09:33:51 +00:00
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue, "exit because we received EOS");
|
2007-09-14 20:24:22 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
|
|
|
|
2015-02-17 09:44:40 +00:00
|
|
|
gst_mini_object_unref (obj);
|
2007-09-14 20:24:22 +00:00
|
|
|
|
2011-10-10 09:33:51 +00:00
|
|
|
return GST_FLOW_EOS;
|
2007-09-14 20:24:22 +00:00
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2015-02-17 09:44:40 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_queue_chain_list (GstPad * pad, GstObject * parent,
|
|
|
|
GstBufferList * buffer_list)
|
|
|
|
{
|
|
|
|
return gst_queue_chain_buffer_or_list (pad, parent,
|
|
|
|
GST_MINI_OBJECT_CAST (buffer_list), TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_queue_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|
|
|
{
|
|
|
|
return gst_queue_chain_buffer_or_list (pad, parent,
|
|
|
|
GST_MINI_OBJECT_CAST (buffer), FALSE);
|
|
|
|
}
|
|
|
|
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
/* dequeue an item from the queue an push it downstream. This functions returns
|
|
|
|
* the result of the push. */
|
|
|
|
static GstFlowReturn
|
2006-01-19 13:30:31 +00:00
|
|
|
gst_queue_push_one (GstQueue * queue)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2014-03-10 12:49:07 +00:00
|
|
|
GstFlowReturn result = queue->srcresult;
|
2006-01-19 13:30:31 +00:00
|
|
|
GstMiniObject *data;
|
2015-02-17 09:44:40 +00:00
|
|
|
gboolean is_list;
|
2000-12-21 01:27:27 +00:00
|
|
|
|
2012-03-14 14:42:33 +00:00
|
|
|
data = gst_queue_locked_dequeue (queue);
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
if (data == NULL)
|
|
|
|
goto no_item;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2007-09-14 20:24:22 +00:00
|
|
|
next:
|
2015-02-17 09:44:40 +00:00
|
|
|
is_list = GST_IS_BUFFER_LIST (data);
|
2007-10-15 11:36:37 +00:00
|
|
|
|
2015-02-17 09:44:40 +00:00
|
|
|
if (GST_IS_BUFFER (data) || is_list) {
|
|
|
|
if (!is_list) {
|
|
|
|
GstBuffer *buffer;
|
2001-12-29 03:02:14 +00:00
|
|
|
|
2015-02-17 09:44:40 +00:00
|
|
|
buffer = GST_BUFFER_CAST (data);
|
2008-02-21 10:22:36 +00:00
|
|
|
|
2015-02-17 09:44:40 +00:00
|
|
|
if (queue->head_needs_discont) {
|
|
|
|
GstBuffer *subbuffer = gst_buffer_make_writable (buffer);
|
|
|
|
|
|
|
|
if (subbuffer) {
|
|
|
|
buffer = subbuffer;
|
|
|
|
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
|
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (queue, "Could not mark buffer as DISCONT");
|
|
|
|
}
|
|
|
|
queue->head_needs_discont = FALSE;
|
2008-02-21 10:22:36 +00:00
|
|
|
}
|
2011-05-05 08:37:19 +00:00
|
|
|
|
2015-02-17 09:44:40 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
|
|
|
result = gst_pad_push (queue->srcpad, buffer);
|
|
|
|
} else {
|
|
|
|
GstBufferList *buffer_list;
|
|
|
|
|
|
|
|
buffer_list = GST_BUFFER_LIST_CAST (data);
|
|
|
|
|
|
|
|
if (queue->head_needs_discont) {
|
|
|
|
buffer_list = gst_buffer_list_make_writable (buffer_list);
|
|
|
|
gst_buffer_list_foreach (buffer_list, discont_first_buffer, queue);
|
|
|
|
queue->head_needs_discont = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
|
|
|
result = gst_pad_push_list (queue->srcpad, buffer_list);
|
|
|
|
}
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
|
2005-10-24 15:41:48 +00:00
|
|
|
/* need to check for srcresult here as well */
|
|
|
|
GST_QUEUE_MUTEX_LOCK_CHECK (queue, out_flushing);
|
2007-09-14 20:24:22 +00:00
|
|
|
|
2011-10-10 09:33:51 +00:00
|
|
|
if (result == GST_FLOW_EOS) {
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue, "got EOS from downstream");
|
2007-09-14 20:24:22 +00:00
|
|
|
/* stop pushing buffers, we dequeue all items until we see an item that we
|
2011-05-13 16:07:24 +00:00
|
|
|
* can push again, which is EOS or SEGMENT. If there is nothing in the
|
2007-09-14 20:24:22 +00:00
|
|
|
* queue we can push, we set a flag to make the sinkpad refuse more
|
2011-10-10 09:33:51 +00:00
|
|
|
* buffers with an EOS return value. */
|
2012-03-14 14:42:33 +00:00
|
|
|
while ((data = gst_queue_locked_dequeue (queue))) {
|
|
|
|
if (GST_IS_BUFFER (data)) {
|
2007-09-14 20:24:22 +00:00
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
2011-10-10 09:33:51 +00:00
|
|
|
"dropping EOS buffer %p", data);
|
2007-09-14 20:24:22 +00:00
|
|
|
gst_buffer_unref (GST_BUFFER_CAST (data));
|
2015-02-17 09:44:40 +00:00
|
|
|
} else if (GST_IS_BUFFER_LIST (data)) {
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
|
|
|
"dropping EOS buffer list %p", data);
|
|
|
|
gst_buffer_list_unref (GST_BUFFER_LIST_CAST (data));
|
2012-03-14 14:42:33 +00:00
|
|
|
} else if (GST_IS_EVENT (data)) {
|
2007-09-14 20:24:22 +00:00
|
|
|
GstEvent *event = GST_EVENT_CAST (data);
|
|
|
|
GstEventType type = GST_EVENT_TYPE (event);
|
|
|
|
|
2017-08-09 08:51:39 +00:00
|
|
|
if (type == GST_EVENT_EOS || type == GST_EVENT_SEGMENT
|
|
|
|
|| type == GST_EVENT_STREAM_START) {
|
2007-09-14 20:24:22 +00:00
|
|
|
/* we found a pushable item in the queue, push it out */
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
2011-10-10 09:33:51 +00:00
|
|
|
"pushing pushable event %s after EOS",
|
2007-09-14 20:24:22 +00:00
|
|
|
GST_EVENT_TYPE_NAME (event));
|
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
2011-10-10 09:33:51 +00:00
|
|
|
"dropping EOS event %p", event);
|
2007-09-14 20:24:22 +00:00
|
|
|
gst_event_unref (event);
|
2012-03-14 14:42:33 +00:00
|
|
|
} else if (GST_IS_QUERY (data)) {
|
|
|
|
GstQuery *query = GST_QUERY_CAST (data);
|
|
|
|
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
|
|
|
"dropping query %p because of EOS", query);
|
|
|
|
queue->last_query = FALSE;
|
2013-05-27 13:59:07 +00:00
|
|
|
g_cond_signal (&queue->query_handled);
|
2007-09-14 20:24:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* no more items in the queue. Set the unexpected flag so that upstream
|
|
|
|
* make us refuse any more buffers on the sinkpad. Since we will still
|
2011-05-13 16:07:24 +00:00
|
|
|
* accept EOS and SEGMENT we return _FLOW_OK to the caller so that the
|
2007-09-14 20:24:22 +00:00
|
|
|
* task function does not shut down. */
|
|
|
|
queue->unexpected = TRUE;
|
|
|
|
result = GST_FLOW_OK;
|
|
|
|
}
|
2012-03-14 14:42:33 +00:00
|
|
|
} else if (GST_IS_EVENT (data)) {
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
GstEvent *event = GST_EVENT_CAST (data);
|
|
|
|
GstEventType type = GST_EVENT_TYPE (event);
|
2007-05-10 15:21:20 +00:00
|
|
|
|
gst/base/gstbasesrc.*: Add a gboolean to decide when to push out a discont.
Original commit message from CVS:
* gst/base/gstbasesrc.c: (gst_base_src_init),
(gst_base_src_do_seek), (gst_base_src_loop), (gst_base_src_start):
* gst/base/gstbasesrc.h:
Add a gboolean to decide when to push out a discont.
* gst/gstqueue.c: (gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_loop), (gst_queue_handle_src_query),
(gst_queue_sink_activate_push), (gst_queue_src_activate_push),
(gst_queue_set_property), (gst_queue_get_property):
Some cleanups.
* tests/threadstate/threadstate1.c: (main):
Make a thread test compile and run... very silly..
2005-07-20 10:58:10 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
|
2007-05-10 15:21:20 +00:00
|
|
|
gst_pad_push_event (queue->srcpad, event);
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
|
gst/base/gstbasesrc.*: Add a gboolean to decide when to push out a discont.
Original commit message from CVS:
* gst/base/gstbasesrc.c: (gst_base_src_init),
(gst_base_src_do_seek), (gst_base_src_loop), (gst_base_src_start):
* gst/base/gstbasesrc.h:
Add a gboolean to decide when to push out a discont.
* gst/gstqueue.c: (gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_loop), (gst_queue_handle_src_query),
(gst_queue_sink_activate_push), (gst_queue_src_activate_push),
(gst_queue_set_property), (gst_queue_get_property):
Some cleanups.
* tests/threadstate/threadstate1.c: (main):
Make a thread test compile and run... very silly..
2005-07-20 10:58:10 +00:00
|
|
|
GST_QUEUE_MUTEX_LOCK_CHECK (queue, out_flushing);
|
2011-10-10 09:33:51 +00:00
|
|
|
/* if we're EOS, return EOS so that the task pauses. */
|
2007-09-14 20:24:22 +00:00
|
|
|
if (type == GST_EVENT_EOS) {
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
2011-10-10 09:33:51 +00:00
|
|
|
"pushed EOS event %p, return EOS", event);
|
|
|
|
result = GST_FLOW_EOS;
|
2007-09-14 20:24:22 +00:00
|
|
|
}
|
2012-03-14 14:42:33 +00:00
|
|
|
} else if (GST_IS_QUERY (data)) {
|
|
|
|
GstQuery *query = GST_QUERY_CAST (data);
|
2013-06-19 08:53:21 +00:00
|
|
|
gboolean ret;
|
2012-03-14 14:42:33 +00:00
|
|
|
|
2013-06-19 08:53:21 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
|
|
|
ret = gst_pad_peer_query (queue->srcpad, query);
|
|
|
|
GST_QUEUE_MUTEX_LOCK_CHECK (queue, out_flushing_query);
|
|
|
|
queue->last_query = ret;
|
2016-12-13 18:51:17 +00:00
|
|
|
queue->last_handled_query = query;
|
2013-05-27 13:59:07 +00:00
|
|
|
g_cond_signal (&queue->query_handled);
|
2012-03-14 14:42:33 +00:00
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
|
|
|
"did query %p, return %d", query, queue->last_query);
|
2005-03-21 17:34:02 +00:00
|
|
|
}
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
return result;
|
2001-10-27 20:28:31 +00:00
|
|
|
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
/* ERRORS */
|
|
|
|
no_item:
|
|
|
|
{
|
2017-01-02 15:13:30 +00:00
|
|
|
GST_CAT_ERROR_OBJECT (queue_dataflow, queue,
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
"exit because we have no item in the queue");
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
2006-01-19 13:30:31 +00:00
|
|
|
out_flushing:
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
{
|
2017-03-15 05:18:36 +00:00
|
|
|
GstFlowReturn ret = queue->srcresult;
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
|
|
|
"exit because task paused, reason: %s", gst_flow_get_name (ret));
|
|
|
|
return ret;
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
}
|
2013-06-19 08:53:21 +00:00
|
|
|
out_flushing_query:
|
|
|
|
{
|
2017-03-15 05:18:36 +00:00
|
|
|
GstFlowReturn ret = queue->srcresult;
|
2013-06-19 08:53:21 +00:00
|
|
|
queue->last_query = FALSE;
|
|
|
|
g_cond_signal (&queue->query_handled);
|
2017-03-15 05:18:36 +00:00
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
|
|
|
"exit because task paused, reason: %s", gst_flow_get_name (ret));
|
|
|
|
return ret;
|
2013-06-19 08:53:21 +00:00
|
|
|
}
|
2006-01-19 13:30:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_queue_loop (GstPad * pad)
|
|
|
|
{
|
|
|
|
GstQueue *queue;
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
GstFlowReturn ret;
|
2006-01-19 13:30:31 +00:00
|
|
|
|
2009-09-28 11:21:07 +00:00
|
|
|
queue = (GstQueue *) GST_PAD_PARENT (pad);
|
2006-01-19 13:30:31 +00:00
|
|
|
|
|
|
|
/* have to lock for thread-safety */
|
|
|
|
GST_QUEUE_MUTEX_LOCK_CHECK (queue, out_flushing);
|
|
|
|
|
|
|
|
while (gst_queue_is_empty (queue)) {
|
2010-10-19 13:53:26 +00:00
|
|
|
GST_CAT_DEBUG_OBJECT (queue_dataflow, queue, "queue is empty");
|
2010-08-27 12:35:49 +00:00
|
|
|
if (!queue->silent) {
|
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
|
|
|
g_signal_emit (queue, gst_queue_signals[SIGNAL_UNDERRUN], 0);
|
|
|
|
GST_QUEUE_MUTEX_LOCK_CHECK (queue, out_flushing);
|
|
|
|
}
|
2006-01-19 13:30:31 +00:00
|
|
|
|
2006-05-11 19:07:48 +00:00
|
|
|
/* we recheck, the signal could have changed the thresholds */
|
2006-01-19 13:30:31 +00:00
|
|
|
while (gst_queue_is_empty (queue)) {
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
GST_QUEUE_WAIT_ADD_CHECK (queue, out_flushing);
|
2006-01-19 13:30:31 +00:00
|
|
|
}
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
|
2010-10-19 13:53:26 +00:00
|
|
|
GST_CAT_DEBUG_OBJECT (queue_dataflow, queue, "queue is not empty");
|
2010-08-27 12:35:49 +00:00
|
|
|
if (!queue->silent) {
|
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
|
|
|
g_signal_emit (queue, gst_queue_signals[SIGNAL_RUNNING], 0);
|
|
|
|
g_signal_emit (queue, gst_queue_signals[SIGNAL_PUSHING], 0);
|
|
|
|
GST_QUEUE_MUTEX_LOCK_CHECK (queue, out_flushing);
|
|
|
|
}
|
2006-01-19 13:30:31 +00:00
|
|
|
}
|
|
|
|
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
ret = gst_queue_push_one (queue);
|
|
|
|
queue->srcresult = ret;
|
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
goto out_flushing;
|
2006-01-19 13:30:31 +00:00
|
|
|
|
gst/base/gstbasesrc.*: Add a gboolean to decide when to push out a discont.
Original commit message from CVS:
* gst/base/gstbasesrc.c: (gst_base_src_init),
(gst_base_src_do_seek), (gst_base_src_loop), (gst_base_src_start):
* gst/base/gstbasesrc.h:
Add a gboolean to decide when to push out a discont.
* gst/gstqueue.c: (gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_loop), (gst_queue_handle_src_query),
(gst_queue_sink_activate_push), (gst_queue_src_activate_push),
(gst_queue_set_property), (gst_queue_get_property):
Some cleanups.
* tests/threadstate/threadstate1.c: (main):
Make a thread test compile and run... very silly..
2005-07-20 10:58:10 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
2005-07-19 17:46:37 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
return;
|
2001-10-27 20:28:31 +00:00
|
|
|
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
/* ERRORS */
|
2005-03-21 17:34:02 +00:00
|
|
|
out_flushing:
|
2005-07-19 17:46:37 +00:00
|
|
|
{
|
2009-08-06 11:29:29 +00:00
|
|
|
gboolean eos = queue->eos;
|
|
|
|
GstFlowReturn ret = queue->srcresult;
|
|
|
|
|
gst/base/gstbasesink.c: Speed up current position calculation.
Original commit message from CVS:
* gst/base/gstbasesink.c: (gst_base_sink_get_position),
(gst_base_sink_query):
Speed up current position calculation.
* gst/base/gstbasesrc.c: (gst_base_src_query),
(gst_base_src_default_newsegment):
Correctly set stream position in newsegment.
* gst/gstbin.c: (gst_bin_add_func), (add_to_queue),
(update_degree), (gst_bin_sort_iterator_next),
(gst_bin_sort_iterator_resync), (gst_bin_sort_iterator_free):
* gst/gstmessage.c: (gst_message_new_custom):
Clean up debugging info
* gst/gstqueue.c: (gst_queue_link_src), (gst_queue_chain),
(gst_queue_loop), (gst_queue_handle_src_query):
Pause task faster.
2005-10-20 11:48:53 +00:00
|
|
|
gst_pad_pause_task (queue->srcpad);
|
2005-07-19 17:46:37 +00:00
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
2009-08-06 11:29:29 +00:00
|
|
|
"pause task, reason: %s", gst_flow_get_name (ret));
|
2015-03-03 11:48:34 +00:00
|
|
|
if (ret == GST_FLOW_FLUSHING) {
|
2013-05-27 11:01:43 +00:00
|
|
|
gst_queue_locked_flush (queue, FALSE);
|
2015-03-03 11:48:34 +00:00
|
|
|
} else {
|
2012-03-29 15:44:02 +00:00
|
|
|
GST_QUEUE_SIGNAL_DEL (queue);
|
2015-03-03 11:48:34 +00:00
|
|
|
queue->last_query = FALSE;
|
|
|
|
g_cond_signal (&queue->query_handled);
|
|
|
|
}
|
gst/base/gstbasesrc.*: Add a gboolean to decide when to push out a discont.
Original commit message from CVS:
* gst/base/gstbasesrc.c: (gst_base_src_init),
(gst_base_src_do_seek), (gst_base_src_loop), (gst_base_src_start):
* gst/base/gstbasesrc.h:
Add a gboolean to decide when to push out a discont.
* gst/gstqueue.c: (gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_loop), (gst_queue_handle_src_query),
(gst_queue_sink_activate_push), (gst_queue_src_activate_push),
(gst_queue_set_property), (gst_queue_get_property):
Some cleanups.
* tests/threadstate/threadstate1.c: (main):
Make a thread test compile and run... very silly..
2005-07-20 10:58:10 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
2009-08-06 11:29:29 +00:00
|
|
|
/* let app know about us giving up if upstream is not expected to do so */
|
2011-10-10 09:33:51 +00:00
|
|
|
/* EOS is already taken care of elsewhere */
|
|
|
|
if (eos && (ret == GST_FLOW_NOT_LINKED || ret < GST_FLOW_EOS)) {
|
2016-08-23 16:27:58 +00:00
|
|
|
GST_ELEMENT_FLOW_ERROR (queue, ret);
|
2009-08-06 11:29:29 +00:00
|
|
|
gst_pad_push_event (queue->srcpad, gst_event_new_eos ());
|
|
|
|
}
|
2005-07-19 17:46:37 +00:00
|
|
|
return;
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2002-05-26 21:54:27 +00:00
|
|
|
static gboolean
|
2011-11-17 11:40:45 +00:00
|
|
|
gst_queue_handle_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
2002-05-26 21:54:27 +00:00
|
|
|
{
|
2005-03-21 17:34:02 +00:00
|
|
|
gboolean res = TRUE;
|
2011-11-17 11:40:45 +00:00
|
|
|
GstQueue *queue = GST_QUEUE (parent);
|
2005-06-30 12:26:26 +00:00
|
|
|
|
2005-07-19 17:46:37 +00:00
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
2004-06-11 15:18:58 +00:00
|
|
|
GST_CAT_DEBUG_OBJECT (queue_dataflow, queue, "got event %p (%d)",
|
|
|
|
event, GST_EVENT_TYPE (event));
|
2005-06-30 12:26:26 +00:00
|
|
|
#endif
|
2002-06-08 16:30:43 +00:00
|
|
|
|
2013-04-04 17:06:35 +00:00
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_RECONFIGURE:
|
|
|
|
GST_QUEUE_MUTEX_LOCK (queue);
|
|
|
|
if (queue->srcresult == GST_FLOW_NOT_LINKED) {
|
|
|
|
/* when we got not linked, assume downstream is linked again now and we
|
|
|
|
* can try to start pushing again */
|
|
|
|
queue->srcresult = GST_FLOW_OK;
|
|
|
|
gst_pad_start_task (pad, (GstTaskFunction) gst_queue_loop, pad, NULL);
|
|
|
|
}
|
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
|
|
|
|
|
|
|
res = gst_pad_push_event (queue->sinkpad, event);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = gst_pad_event_default (pad, parent, event);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-06-02 15:34:34 +00:00
|
|
|
|
2003-01-15 21:01:58 +00:00
|
|
|
return res;
|
2002-05-26 21:54:27 +00:00
|
|
|
}
|
|
|
|
|
2004-10-11 13:14:03 +00:00
|
|
|
static gboolean
|
2011-11-16 16:22:56 +00:00
|
|
|
gst_queue_handle_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
2004-10-11 13:14:03 +00:00
|
|
|
{
|
2011-11-16 16:22:56 +00:00
|
|
|
GstQueue *queue = GST_QUEUE (parent);
|
2005-07-19 17:46:37 +00:00
|
|
|
gboolean res;
|
2004-10-11 13:14:03 +00:00
|
|
|
|
2012-07-18 08:15:51 +00:00
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
|
|
|
case GST_QUERY_SCHEDULING:{
|
|
|
|
gst_query_add_scheduling_mode (query, GST_PAD_MODE_PUSH);
|
|
|
|
res = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
res = gst_pad_query_default (pad, parent, query);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-11-16 16:22:56 +00:00
|
|
|
if (!res)
|
2004-10-11 13:14:03 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2012-07-18 08:15:51 +00:00
|
|
|
/* Adjust peer response for data contained in queue */
|
2011-05-17 09:20:05 +00:00
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
2005-05-09 10:53:13 +00:00
|
|
|
case GST_QUERY_POSITION:
|
|
|
|
{
|
gst/: API change fix.
Original commit message from CVS:
* gst/base/gstbasesink.c: (gst_base_sink_commit_state),
(gst_base_sink_handle_object), (gst_base_sink_query), (do_playing):
* gst/base/gstbasesrc.c: (gst_base_src_query):
* gst/elements/gstfilesink.c: (gst_file_sink_query):
* gst/elements/gsttypefindelement.c:
(gst_type_find_handle_src_query), (find_element_get_length),
(gst_type_find_element_activate):
API change fix.
* gst/gstquery.c: (gst_query_new_position),
(gst_query_set_position), (gst_query_parse_position),
(gst_query_new_duration), (gst_query_set_duration),
(gst_query_parse_duration), (gst_query_set_segment),
(gst_query_parse_segment):
* gst/gstquery.h:
Bundling query position/duration is not a good idea since duration
does not change much and we don't want to recalculate it for every
position query, so they are separated again..
Base value in segment query is not needed.
* gst/gstqueue.c: (gst_queue_handle_src_query):
* gst/gstutils.c: (gst_element_query_position),
(gst_element_query_duration), (gst_pad_query_position),
(gst_pad_query_duration):
* gst/gstutils.h:
Updates for query API change.
Added some docs here and there.
2005-10-19 15:50:10 +00:00
|
|
|
gint64 peer_pos;
|
2005-05-09 10:53:13 +00:00
|
|
|
GstFormat format;
|
|
|
|
|
|
|
|
/* get peer position */
|
2011-05-17 09:20:05 +00:00
|
|
|
gst_query_parse_position (query, &format, &peer_pos);
|
2005-05-09 10:53:13 +00:00
|
|
|
|
|
|
|
/* FIXME: this code assumes that there's no discont in the queue */
|
|
|
|
switch (format) {
|
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
peer_pos -= queue->cur_level.bytes;
|
2016-11-15 11:39:43 +00:00
|
|
|
if (peer_pos < 0) /* Clamp result to 0 */
|
|
|
|
peer_pos = 0;
|
2005-05-09 10:53:13 +00:00
|
|
|
break;
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
peer_pos -= queue->cur_level.time;
|
2016-11-15 11:39:43 +00:00
|
|
|
if (peer_pos < 0) /* Clamp result to 0 */
|
|
|
|
peer_pos = 0;
|
2005-05-09 10:53:13 +00:00
|
|
|
break;
|
|
|
|
default:
|
2008-10-08 11:20:17 +00:00
|
|
|
GST_DEBUG_OBJECT (queue, "Can't adjust query in %s format, don't "
|
2005-12-27 12:11:19 +00:00
|
|
|
"know how to adjust value", gst_format_get_name (format));
|
2008-10-08 11:20:17 +00:00
|
|
|
return TRUE;
|
2005-05-09 10:53:13 +00:00
|
|
|
}
|
gst/: API change fix.
Original commit message from CVS:
* gst/base/gstbasesink.c: (gst_base_sink_commit_state),
(gst_base_sink_handle_object), (gst_base_sink_query), (do_playing):
* gst/base/gstbasesrc.c: (gst_base_src_query):
* gst/elements/gstfilesink.c: (gst_file_sink_query):
* gst/elements/gsttypefindelement.c:
(gst_type_find_handle_src_query), (find_element_get_length),
(gst_type_find_element_activate):
API change fix.
* gst/gstquery.c: (gst_query_new_position),
(gst_query_set_position), (gst_query_parse_position),
(gst_query_new_duration), (gst_query_set_duration),
(gst_query_parse_duration), (gst_query_set_segment),
(gst_query_parse_segment):
* gst/gstquery.h:
Bundling query position/duration is not a good idea since duration
does not change much and we don't want to recalculate it for every
position query, so they are separated again..
Base value in segment query is not needed.
* gst/gstqueue.c: (gst_queue_handle_src_query):
* gst/gstutils.c: (gst_element_query_position),
(gst_element_query_duration), (gst_pad_query_position),
(gst_pad_query_duration):
* gst/gstutils.h:
Updates for query API change.
Added some docs here and there.
2005-10-19 15:50:10 +00:00
|
|
|
/* set updated position */
|
2011-05-17 09:20:05 +00:00
|
|
|
gst_query_set_position (query, format, peer_pos);
|
2005-05-09 10:53:13 +00:00
|
|
|
break;
|
2004-10-11 13:14:03 +00:00
|
|
|
}
|
2007-09-13 17:15:38 +00:00
|
|
|
case GST_QUERY_LATENCY:
|
|
|
|
{
|
|
|
|
gboolean live;
|
|
|
|
GstClockTime min, max;
|
|
|
|
|
2011-05-17 09:20:05 +00:00
|
|
|
gst_query_parse_latency (query, &live, &min, &max);
|
2007-09-13 17:15:38 +00:00
|
|
|
|
|
|
|
/* we can delay up to the limit of the queue in time. If we have no time
|
|
|
|
* limit, the best thing we can do is to return an infinite delay. In
|
|
|
|
* reality a better estimate would be the byte/buffer rate but that is not
|
|
|
|
* possible right now. */
|
2015-02-11 12:41:56 +00:00
|
|
|
/* TODO: Use CONVERT query? */
|
|
|
|
if (queue->max_size.time > 0 && max != -1
|
|
|
|
&& queue->leaky == GST_QUEUE_NO_LEAK)
|
2007-09-13 17:15:38 +00:00
|
|
|
max += queue->max_size.time;
|
2015-02-11 12:41:56 +00:00
|
|
|
else if (queue->max_size.time > 0 && queue->leaky != GST_QUEUE_NO_LEAK)
|
|
|
|
max = MIN (queue->max_size.time, max);
|
2007-09-13 17:15:38 +00:00
|
|
|
else
|
|
|
|
max = -1;
|
|
|
|
|
2008-04-21 08:34:09 +00:00
|
|
|
/* adjust for min-threshold */
|
2015-02-11 12:41:56 +00:00
|
|
|
if (queue->min_threshold.time > 0)
|
2008-04-21 08:34:09 +00:00
|
|
|
min += queue->min_threshold.time;
|
|
|
|
|
2011-05-17 09:20:05 +00:00
|
|
|
gst_query_set_latency (query, live, min, max);
|
2007-09-13 17:15:38 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-05-09 10:53:13 +00:00
|
|
|
default:
|
gst/: API change fix.
Original commit message from CVS:
* gst/base/gstbasesink.c: (gst_base_sink_commit_state),
(gst_base_sink_handle_object), (gst_base_sink_query), (do_playing):
* gst/base/gstbasesrc.c: (gst_base_src_query):
* gst/elements/gstfilesink.c: (gst_file_sink_query):
* gst/elements/gsttypefindelement.c:
(gst_type_find_handle_src_query), (find_element_get_length),
(gst_type_find_element_activate):
API change fix.
* gst/gstquery.c: (gst_query_new_position),
(gst_query_set_position), (gst_query_parse_position),
(gst_query_new_duration), (gst_query_set_duration),
(gst_query_parse_duration), (gst_query_set_segment),
(gst_query_parse_segment):
* gst/gstquery.h:
Bundling query position/duration is not a good idea since duration
does not change much and we don't want to recalculate it for every
position query, so they are separated again..
Base value in segment query is not needed.
* gst/gstqueue.c: (gst_queue_handle_src_query):
* gst/gstutils.c: (gst_element_query_position),
(gst_element_query_duration), (gst_pad_query_position),
(gst_pad_query_duration):
* gst/gstutils.h:
Updates for query API change.
Added some docs here and there.
2005-10-19 15:50:10 +00:00
|
|
|
/* peer handled other queries */
|
2005-05-09 10:53:13 +00:00
|
|
|
break;
|
2004-10-11 13:14:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-05-26 21:54:27 +00:00
|
|
|
static gboolean
|
2011-11-21 12:29:05 +00:00
|
|
|
gst_queue_sink_activate_mode (GstPad * pad, GstObject * parent, GstPadMode mode,
|
|
|
|
gboolean active)
|
2002-05-26 21:54:27 +00:00
|
|
|
{
|
2011-11-21 12:29:05 +00:00
|
|
|
gboolean result;
|
2002-05-26 21:54:27 +00:00
|
|
|
GstQueue *queue;
|
|
|
|
|
2011-11-18 12:46:46 +00:00
|
|
|
queue = GST_QUEUE (parent);
|
2002-05-26 21:54:27 +00:00
|
|
|
|
2011-11-21 12:29:05 +00:00
|
|
|
switch (mode) {
|
|
|
|
case GST_PAD_MODE_PUSH:
|
|
|
|
if (active) {
|
|
|
|
GST_QUEUE_MUTEX_LOCK (queue);
|
|
|
|
queue->srcresult = GST_FLOW_OK;
|
|
|
|
queue->eos = FALSE;
|
|
|
|
queue->unexpected = FALSE;
|
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
|
|
|
} else {
|
|
|
|
/* step 1, unblock chain function */
|
|
|
|
GST_QUEUE_MUTEX_LOCK (queue);
|
2012-02-08 14:16:46 +00:00
|
|
|
queue->srcresult = GST_FLOW_FLUSHING;
|
2013-08-20 08:16:41 +00:00
|
|
|
/* the item del signal will unblock */
|
2016-03-11 14:04:52 +00:00
|
|
|
GST_QUEUE_SIGNAL_DEL (queue);
|
2013-08-19 14:38:16 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
|
|
|
|
|
|
|
/* step 2, wait until streaming thread stopped and flush queue */
|
|
|
|
GST_PAD_STREAM_LOCK (pad);
|
|
|
|
GST_QUEUE_MUTEX_LOCK (queue);
|
2013-05-27 11:01:43 +00:00
|
|
|
gst_queue_locked_flush (queue, TRUE);
|
2011-11-21 12:29:05 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
2013-08-19 14:38:16 +00:00
|
|
|
GST_PAD_STREAM_UNLOCK (pad);
|
2011-11-21 12:29:05 +00:00
|
|
|
}
|
|
|
|
result = TRUE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
result = FALSE;
|
|
|
|
break;
|
2005-03-21 17:34:02 +00:00
|
|
|
}
|
|
|
|
return result;
|
2002-05-26 21:54:27 +00:00
|
|
|
}
|
|
|
|
|
gst/: Fix state changes for non sinks. We now change sinks, then elements with unconnected srcpads, then the rest.
Original commit message from CVS:
* gst/gstbin.c: (bin_element_is_sink), (has_ancestor),
(bin_element_is_semi_sink), (append_child), (gst_bin_change_state):
* gst/gstpad.c: (gst_pad_set_active), (gst_pad_link_prepare),
(gst_pad_link), (gst_pad_accept_caps), (gst_pad_query),
(gst_pad_send_event), (gst_pad_start_task):
* gst/gstqueue.c: (gst_queue_init), (gst_queue_locked_flush),
(gst_queue_handle_sink_event), (gst_queue_chain), (gst_queue_loop),
(gst_queue_sink_activate), (gst_queue_src_activate),
(gst_queue_change_state):
* gst/gstqueue.h:
Fix state changes for non sinks. We now change sinks, then elements
with unconnected srcpads, then the rest.
More efficient queue unlocking in flush and state changes.
Set the pad activate mode even if it does not have an activate
function.
2005-05-25 19:33:39 +00:00
|
|
|
static gboolean
|
2011-11-21 12:29:05 +00:00
|
|
|
gst_queue_src_activate_mode (GstPad * pad, GstObject * parent, GstPadMode mode,
|
|
|
|
gboolean active)
|
gst/: Fix state changes for non sinks. We now change sinks, then elements with unconnected srcpads, then the rest.
Original commit message from CVS:
* gst/gstbin.c: (bin_element_is_sink), (has_ancestor),
(bin_element_is_semi_sink), (append_child), (gst_bin_change_state):
* gst/gstpad.c: (gst_pad_set_active), (gst_pad_link_prepare),
(gst_pad_link), (gst_pad_accept_caps), (gst_pad_query),
(gst_pad_send_event), (gst_pad_start_task):
* gst/gstqueue.c: (gst_queue_init), (gst_queue_locked_flush),
(gst_queue_handle_sink_event), (gst_queue_chain), (gst_queue_loop),
(gst_queue_sink_activate), (gst_queue_src_activate),
(gst_queue_change_state):
* gst/gstqueue.h:
Fix state changes for non sinks. We now change sinks, then elements
with unconnected srcpads, then the rest.
More efficient queue unlocking in flush and state changes.
Set the pad activate mode even if it does not have an activate
function.
2005-05-25 19:33:39 +00:00
|
|
|
{
|
2011-11-21 12:29:05 +00:00
|
|
|
gboolean result;
|
gst/: Fix state changes for non sinks. We now change sinks, then elements with unconnected srcpads, then the rest.
Original commit message from CVS:
* gst/gstbin.c: (bin_element_is_sink), (has_ancestor),
(bin_element_is_semi_sink), (append_child), (gst_bin_change_state):
* gst/gstpad.c: (gst_pad_set_active), (gst_pad_link_prepare),
(gst_pad_link), (gst_pad_accept_caps), (gst_pad_query),
(gst_pad_send_event), (gst_pad_start_task):
* gst/gstqueue.c: (gst_queue_init), (gst_queue_locked_flush),
(gst_queue_handle_sink_event), (gst_queue_chain), (gst_queue_loop),
(gst_queue_sink_activate), (gst_queue_src_activate),
(gst_queue_change_state):
* gst/gstqueue.h:
Fix state changes for non sinks. We now change sinks, then elements
with unconnected srcpads, then the rest.
More efficient queue unlocking in flush and state changes.
Set the pad activate mode even if it does not have an activate
function.
2005-05-25 19:33:39 +00:00
|
|
|
GstQueue *queue;
|
|
|
|
|
2011-11-18 12:46:46 +00:00
|
|
|
queue = GST_QUEUE (parent);
|
gst/: Fix state changes for non sinks. We now change sinks, then elements with unconnected srcpads, then the rest.
Original commit message from CVS:
* gst/gstbin.c: (bin_element_is_sink), (has_ancestor),
(bin_element_is_semi_sink), (append_child), (gst_bin_change_state):
* gst/gstpad.c: (gst_pad_set_active), (gst_pad_link_prepare),
(gst_pad_link), (gst_pad_accept_caps), (gst_pad_query),
(gst_pad_send_event), (gst_pad_start_task):
* gst/gstqueue.c: (gst_queue_init), (gst_queue_locked_flush),
(gst_queue_handle_sink_event), (gst_queue_chain), (gst_queue_loop),
(gst_queue_sink_activate), (gst_queue_src_activate),
(gst_queue_change_state):
* gst/gstqueue.h:
Fix state changes for non sinks. We now change sinks, then elements
with unconnected srcpads, then the rest.
More efficient queue unlocking in flush and state changes.
Set the pad activate mode even if it does not have an activate
function.
2005-05-25 19:33:39 +00:00
|
|
|
|
2011-11-21 12:29:05 +00:00
|
|
|
switch (mode) {
|
|
|
|
case GST_PAD_MODE_PUSH:
|
|
|
|
if (active) {
|
|
|
|
GST_QUEUE_MUTEX_LOCK (queue);
|
|
|
|
queue->srcresult = GST_FLOW_OK;
|
|
|
|
queue->eos = FALSE;
|
|
|
|
queue->unexpected = FALSE;
|
2012-02-21 11:52:44 +00:00
|
|
|
result =
|
2012-06-20 08:31:49 +00:00
|
|
|
gst_pad_start_task (pad, (GstTaskFunction) gst_queue_loop, pad,
|
|
|
|
NULL);
|
2011-11-21 12:29:05 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
|
|
|
} else {
|
|
|
|
/* step 1, unblock loop function */
|
|
|
|
GST_QUEUE_MUTEX_LOCK (queue);
|
2012-02-08 14:16:46 +00:00
|
|
|
queue->srcresult = GST_FLOW_FLUSHING;
|
2011-11-21 12:29:05 +00:00
|
|
|
/* the item add signal will unblock */
|
2012-01-19 08:27:04 +00:00
|
|
|
g_cond_signal (&queue->item_add);
|
2011-11-21 12:29:05 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
gst/base/gsttypefindhelper.c (gst_type_find_helper): Unref any remaining buffer.
Original commit message from CVS:
2005-06-27 Andy Wingo <wingo@pobox.com>
* gst/base/gsttypefindhelper.c (gst_type_find_helper): Unref any
remaining buffer.
* gst/gsttrace.c (gst_alloc_trace_list_sorted): New helper,
returns a sorted copy of the trace list.
(gst_alloc_trace_print_live): New API, only prints traces with
live objects. Sort the list.
(gst_alloc_trace_print_all): Sort the list.
(gst_alloc_trace_print): Align columns.
* gst/elements/gstttypefindelement.c:
* gst/elements/gsttee.c:
* gst/base/gstbasesrc.c:
* gst/base/gstbasesink.c:
* gst/base/gstbasetransform.c:
* gst/gstqueue.c: Adapt for pad activation changes.
* gst/gstpipeline.c (gst_pipeline_init): Unref after parenting
sched.
(gst_pipeline_dispose): Drop ref on sched.
* gst/gstpad.c (gst_pad_init): Set the default activate func.
(gst_pad_activate_default): Push mode by default.
(pre_activate_switch, post_activate_switch): New stubs, things to
do before and after switching activation modes on pads.
(gst_pad_set_active): Take a boolean and not a mode, dispatch to
the pad's activate function to choose which mode to activate.
Shortcut on deactivation and call the right function directly.
(gst_pad_activate_pull): New API, (de)activates a pad in pull
mode.
(gst_pad_activate_push): New API, same for push mode.
(gst_pad_set_activate_function)
(gst_pad_set_activatepull_function)
(gst_pad_set_activatepush_function): Setters for new API.
* gst/gstminiobject.c (gst_mini_object_new, gst_mini_object_free):
Trace all miniobjects.
(gst_mini_object_make_writable): Unref the arg if we copy, like
gst_caps_make_writable.
* gst/gstmessage.c (_gst_message_initialize): No trace init.
* gst/gstghostpad.c (gst_proxy_pad_do_activate)
(gst_proxy_pad_do_activatepull, gst_proxy_pad_do_activatepush):
Adapt for new pad API.
* gst/gstevent.c (_gst_event_initialize): Don't initialize trace.
* gst/gstelement.h:
* gst/gstelement.c (gst_element_iterate_src_pads)
(gst_element_iterate_sink_pads): New API functions.
* gst/gstelement.c (iterator_fold_with_resync): New utility,
should fold into gstiterator.c in some form.
(gst_element_pads_activate): Simplified via use of fold and
delegation of decisions to gstpad->activate.
* gst/gstbus.c (gst_bus_source_finalize): Set the bus to NULL,
help in debugging.
* gst/gstbuffer.c (_gst_buffer_initialize): Ref the buffer type
class once in init, like gstmessage. Didn't run into this issue
but it seems correct. Don't initialize a trace, gstminiobject does
that.
* check/pipelines/simple_launch_lines.c (test_stop_from_app): New
test, runs fakesrc ! fakesink, stopping on ::handoff via a message
to the bus.
(assert_live_count): New util function, uses alloc traces to check
cleanup.
* check/gst/gstghostpad.c (test_ghost_pads): More refcount checks.
To be modified when unlink drops the internal pad.
2005-06-27 18:35:05 +00:00
|
|
|
|
2011-11-21 12:29:05 +00:00
|
|
|
/* step 2, make sure streaming finishes */
|
|
|
|
result = gst_pad_stop_task (pad);
|
2016-12-13 18:00:55 +00:00
|
|
|
|
|
|
|
GST_QUEUE_MUTEX_LOCK (queue);
|
|
|
|
gst_queue_locked_flush (queue, FALSE);
|
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
2011-11-21 12:29:05 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
result = FALSE;
|
|
|
|
break;
|
gst/: Fix state changes for non sinks. We now change sinks, then elements with unconnected srcpads, then the rest.
Original commit message from CVS:
* gst/gstbin.c: (bin_element_is_sink), (has_ancestor),
(bin_element_is_semi_sink), (append_child), (gst_bin_change_state):
* gst/gstpad.c: (gst_pad_set_active), (gst_pad_link_prepare),
(gst_pad_link), (gst_pad_accept_caps), (gst_pad_query),
(gst_pad_send_event), (gst_pad_start_task):
* gst/gstqueue.c: (gst_queue_init), (gst_queue_locked_flush),
(gst_queue_handle_sink_event), (gst_queue_chain), (gst_queue_loop),
(gst_queue_sink_activate), (gst_queue_src_activate),
(gst_queue_change_state):
* gst/gstqueue.h:
Fix state changes for non sinks. We now change sinks, then elements
with unconnected srcpads, then the rest.
More efficient queue unlocking in flush and state changes.
Set the pad activate mode even if it does not have an activate
function.
2005-05-25 19:33:39 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2008-04-30 09:35:43 +00:00
|
|
|
static void
|
|
|
|
queue_capacity_change (GstQueue * queue)
|
|
|
|
{
|
|
|
|
if (queue->leaky == GST_QUEUE_LEAK_DOWNSTREAM) {
|
|
|
|
gst_queue_leak_downstream (queue);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* changing the capacity of the queue must wake up
|
|
|
|
* the _chain function, it might have more room now
|
|
|
|
* to store the buffer/event in the queue */
|
|
|
|
GST_QUEUE_SIGNAL_DEL (queue);
|
|
|
|
}
|
2006-05-11 19:07:48 +00:00
|
|
|
|
|
|
|
/* Changing the minimum required fill level must
|
|
|
|
* wake up the _loop function as it might now
|
|
|
|
* be able to preceed.
|
|
|
|
*/
|
|
|
|
#define QUEUE_THRESHOLD_CHANGE(q)\
|
2007-09-28 10:15:23 +00:00
|
|
|
GST_QUEUE_SIGNAL_ADD (q);
|
2006-05-11 19:07:48 +00:00
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_queue_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2003-12-13 17:12:46 +00:00
|
|
|
GstQueue *queue = GST_QUEUE (object);
|
2001-01-20 17:59:25 +00:00
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
/* someone could change levels here, and since this
|
|
|
|
* affects the get/put funcs, we need to lock for safety. */
|
gst/base/gstbasesrc.*: Add a gboolean to decide when to push out a discont.
Original commit message from CVS:
* gst/base/gstbasesrc.c: (gst_base_src_init),
(gst_base_src_do_seek), (gst_base_src_loop), (gst_base_src_start):
* gst/base/gstbasesrc.h:
Add a gboolean to decide when to push out a discont.
* gst/gstqueue.c: (gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_loop), (gst_queue_handle_src_query),
(gst_queue_sink_activate_push), (gst_queue_src_activate_push),
(gst_queue_set_property), (gst_queue_get_property):
Some cleanups.
* tests/threadstate/threadstate1.c: (main):
Make a thread test compile and run... very silly..
2005-07-20 10:58:10 +00:00
|
|
|
GST_QUEUE_MUTEX_LOCK (queue);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
switch (prop_id) {
|
2010-08-27 07:22:27 +00:00
|
|
|
case PROP_MAX_SIZE_BYTES:
|
2003-12-13 17:12:46 +00:00
|
|
|
queue->max_size.bytes = g_value_get_uint (value);
|
2008-04-30 09:35:43 +00:00
|
|
|
queue_capacity_change (queue);
|
2003-12-13 17:12:46 +00:00
|
|
|
break;
|
2010-08-27 07:22:27 +00:00
|
|
|
case PROP_MAX_SIZE_BUFFERS:
|
2003-12-13 17:12:46 +00:00
|
|
|
queue->max_size.buffers = g_value_get_uint (value);
|
2008-04-30 09:35:43 +00:00
|
|
|
queue_capacity_change (queue);
|
2003-12-13 17:12:46 +00:00
|
|
|
break;
|
2010-08-27 07:22:27 +00:00
|
|
|
case PROP_MAX_SIZE_TIME:
|
2003-12-13 17:12:46 +00:00
|
|
|
queue->max_size.time = g_value_get_uint64 (value);
|
2008-04-30 09:35:43 +00:00
|
|
|
queue_capacity_change (queue);
|
2000-02-13 15:20:49 +00:00
|
|
|
break;
|
2010-08-27 07:22:27 +00:00
|
|
|
case PROP_MIN_THRESHOLD_BYTES:
|
2004-01-15 20:37:07 +00:00
|
|
|
queue->min_threshold.bytes = g_value_get_uint (value);
|
plugins/elements/gstqueue.*: In queue, when EOS is received, if minimum threshold > max_size - current_level, there i...
Original commit message from CVS:
Patch by Tommi Myöhänen <ext-tommi dot myohanen at nokia dot com>
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_locked_flush), (gst_queue_handle_sink_event),
(gst_queue_set_property):
* plugins/elements/gstqueue.h:
In queue, when EOS is received, if minimum threshold > max_size -
current_level, there is chance that queue blocks forever in conditional item
del wait. This is because the queue is not emptied completely due to minimum
threshold.
Here is another approach. Instead of setting cur_levels to max in EOS, just
zero all minimum threshold levels. This should make sure that queue gives out
all data. When going to READY (stop) state, just reset the original minimum
threshold levels.
Fixes #336336.
2006-03-29 11:02:33 +00:00
|
|
|
queue->orig_min_threshold.bytes = queue->min_threshold.bytes;
|
2006-05-11 19:07:48 +00:00
|
|
|
QUEUE_THRESHOLD_CHANGE (queue);
|
2001-12-22 21:18:17 +00:00
|
|
|
break;
|
2010-08-27 07:22:27 +00:00
|
|
|
case PROP_MIN_THRESHOLD_BUFFERS:
|
2004-01-15 20:37:07 +00:00
|
|
|
queue->min_threshold.buffers = g_value_get_uint (value);
|
plugins/elements/gstqueue.*: In queue, when EOS is received, if minimum threshold > max_size - current_level, there i...
Original commit message from CVS:
Patch by Tommi Myöhänen <ext-tommi dot myohanen at nokia dot com>
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_locked_flush), (gst_queue_handle_sink_event),
(gst_queue_set_property):
* plugins/elements/gstqueue.h:
In queue, when EOS is received, if minimum threshold > max_size -
current_level, there is chance that queue blocks forever in conditional item
del wait. This is because the queue is not emptied completely due to minimum
threshold.
Here is another approach. Instead of setting cur_levels to max in EOS, just
zero all minimum threshold levels. This should make sure that queue gives out
all data. When going to READY (stop) state, just reset the original minimum
threshold levels.
Fixes #336336.
2006-03-29 11:02:33 +00:00
|
|
|
queue->orig_min_threshold.buffers = queue->min_threshold.buffers;
|
2006-05-11 19:07:48 +00:00
|
|
|
QUEUE_THRESHOLD_CHANGE (queue);
|
2003-12-13 17:12:46 +00:00
|
|
|
break;
|
2010-08-27 07:22:27 +00:00
|
|
|
case PROP_MIN_THRESHOLD_TIME:
|
2004-01-15 20:37:07 +00:00
|
|
|
queue->min_threshold.time = g_value_get_uint64 (value);
|
plugins/elements/gstqueue.*: In queue, when EOS is received, if minimum threshold > max_size - current_level, there i...
Original commit message from CVS:
Patch by Tommi Myöhänen <ext-tommi dot myohanen at nokia dot com>
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_locked_flush), (gst_queue_handle_sink_event),
(gst_queue_set_property):
* plugins/elements/gstqueue.h:
In queue, when EOS is received, if minimum threshold > max_size -
current_level, there is chance that queue blocks forever in conditional item
del wait. This is because the queue is not emptied completely due to minimum
threshold.
Here is another approach. Instead of setting cur_levels to max in EOS, just
zero all minimum threshold levels. This should make sure that queue gives out
all data. When going to READY (stop) state, just reset the original minimum
threshold levels.
Fixes #336336.
2006-03-29 11:02:33 +00:00
|
|
|
queue->orig_min_threshold.time = queue->min_threshold.time;
|
2006-05-11 19:07:48 +00:00
|
|
|
QUEUE_THRESHOLD_CHANGE (queue);
|
2003-12-13 17:12:46 +00:00
|
|
|
break;
|
2010-08-27 07:22:27 +00:00
|
|
|
case PROP_LEAKY:
|
2003-12-13 17:12:46 +00:00
|
|
|
queue->leaky = g_value_get_enum (value);
|
2003-05-30 23:20:02 +00:00
|
|
|
break;
|
2010-08-27 12:35:49 +00:00
|
|
|
case PROP_SILENT:
|
|
|
|
queue->silent = g_value_get_boolean (value);
|
|
|
|
break;
|
2012-10-31 19:33:30 +00:00
|
|
|
case PROP_FLUSH_ON_EOS:
|
|
|
|
queue->flush_on_eos = g_value_get_boolean (value);
|
|
|
|
break;
|
2000-01-30 09:03:00 +00:00
|
|
|
default:
|
2001-06-25 01:20:11 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2000-01-30 09:03:00 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-12-13 17:12:46 +00:00
|
|
|
|
gst/base/gstbasesrc.*: Add a gboolean to decide when to push out a discont.
Original commit message from CVS:
* gst/base/gstbasesrc.c: (gst_base_src_init),
(gst_base_src_do_seek), (gst_base_src_loop), (gst_base_src_start):
* gst/base/gstbasesrc.h:
Add a gboolean to decide when to push out a discont.
* gst/gstqueue.c: (gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_loop), (gst_queue_handle_src_query),
(gst_queue_sink_activate_push), (gst_queue_src_activate_push),
(gst_queue_set_property), (gst_queue_get_property):
Some cleanups.
* tests/threadstate/threadstate1.c: (main):
Make a thread test compile and run... very silly..
2005-07-20 10:58:10 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_queue_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2003-12-13 17:12:46 +00:00
|
|
|
GstQueue *queue = GST_QUEUE (object);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
gst/base/gstbasesrc.*: Add a gboolean to decide when to push out a discont.
Original commit message from CVS:
* gst/base/gstbasesrc.c: (gst_base_src_init),
(gst_base_src_do_seek), (gst_base_src_loop), (gst_base_src_start):
* gst/base/gstbasesrc.h:
Add a gboolean to decide when to push out a discont.
* gst/gstqueue.c: (gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_loop), (gst_queue_handle_src_query),
(gst_queue_sink_activate_push), (gst_queue_src_activate_push),
(gst_queue_set_property), (gst_queue_get_property):
Some cleanups.
* tests/threadstate/threadstate1.c: (main):
Make a thread test compile and run... very silly..
2005-07-20 10:58:10 +00:00
|
|
|
GST_QUEUE_MUTEX_LOCK (queue);
|
2005-07-19 17:46:37 +00:00
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
switch (prop_id) {
|
2010-08-27 07:22:27 +00:00
|
|
|
case PROP_CUR_LEVEL_BYTES:
|
2003-12-13 17:12:46 +00:00
|
|
|
g_value_set_uint (value, queue->cur_level.bytes);
|
|
|
|
break;
|
2010-08-27 07:22:27 +00:00
|
|
|
case PROP_CUR_LEVEL_BUFFERS:
|
2003-12-13 17:12:46 +00:00
|
|
|
g_value_set_uint (value, queue->cur_level.buffers);
|
|
|
|
break;
|
2010-08-27 07:22:27 +00:00
|
|
|
case PROP_CUR_LEVEL_TIME:
|
2003-12-13 17:12:46 +00:00
|
|
|
g_value_set_uint64 (value, queue->cur_level.time);
|
|
|
|
break;
|
2010-08-27 07:22:27 +00:00
|
|
|
case PROP_MAX_SIZE_BYTES:
|
2003-12-13 17:12:46 +00:00
|
|
|
g_value_set_uint (value, queue->max_size.bytes);
|
2001-05-25 21:00:07 +00:00
|
|
|
break;
|
2010-08-27 07:22:27 +00:00
|
|
|
case PROP_MAX_SIZE_BUFFERS:
|
2003-12-13 17:12:46 +00:00
|
|
|
g_value_set_uint (value, queue->max_size.buffers);
|
2000-01-30 09:03:00 +00:00
|
|
|
break;
|
2010-08-27 07:22:27 +00:00
|
|
|
case PROP_MAX_SIZE_TIME:
|
2003-12-13 17:12:46 +00:00
|
|
|
g_value_set_uint64 (value, queue->max_size.time);
|
2001-12-22 21:18:17 +00:00
|
|
|
break;
|
2010-08-27 07:22:27 +00:00
|
|
|
case PROP_MIN_THRESHOLD_BYTES:
|
2004-01-15 20:37:07 +00:00
|
|
|
g_value_set_uint (value, queue->min_threshold.bytes);
|
2003-12-13 17:12:46 +00:00
|
|
|
break;
|
2010-08-27 07:22:27 +00:00
|
|
|
case PROP_MIN_THRESHOLD_BUFFERS:
|
2004-01-15 20:37:07 +00:00
|
|
|
g_value_set_uint (value, queue->min_threshold.buffers);
|
2003-12-13 17:12:46 +00:00
|
|
|
break;
|
2010-08-27 07:22:27 +00:00
|
|
|
case PROP_MIN_THRESHOLD_TIME:
|
2004-01-15 20:37:07 +00:00
|
|
|
g_value_set_uint64 (value, queue->min_threshold.time);
|
2003-12-13 17:12:46 +00:00
|
|
|
break;
|
2010-08-27 07:22:27 +00:00
|
|
|
case PROP_LEAKY:
|
2003-12-13 17:12:46 +00:00
|
|
|
g_value_set_enum (value, queue->leaky);
|
2003-05-30 23:20:02 +00:00
|
|
|
break;
|
2010-08-27 12:35:49 +00:00
|
|
|
case PROP_SILENT:
|
|
|
|
g_value_set_boolean (value, queue->silent);
|
|
|
|
break;
|
2012-10-31 19:33:30 +00:00
|
|
|
case PROP_FLUSH_ON_EOS:
|
|
|
|
g_value_set_boolean (value, queue->flush_on_eos);
|
|
|
|
break;
|
2000-01-30 09:03:00 +00:00
|
|
|
default:
|
2001-06-25 01:20:11 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2000-01-30 09:03:00 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-07-19 17:46:37 +00:00
|
|
|
|
gst/base/gstbasesrc.*: Add a gboolean to decide when to push out a discont.
Original commit message from CVS:
* gst/base/gstbasesrc.c: (gst_base_src_init),
(gst_base_src_do_seek), (gst_base_src_loop), (gst_base_src_start):
* gst/base/gstbasesrc.h:
Add a gboolean to decide when to push out a discont.
* gst/gstqueue.c: (gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_loop), (gst_queue_handle_src_query),
(gst_queue_sink_activate_push), (gst_queue_src_activate_push),
(gst_queue_set_property), (gst_queue_get_property):
Some cleanups.
* tests/threadstate/threadstate1.c: (main):
Make a thread test compile and run... very silly..
2005-07-20 10:58:10 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK (queue);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|