libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
|
|
|
* unit test for queue
|
|
|
|
*
|
|
|
|
* Copyright (C) <2006> Stefan Kost <ensonic@users.sf.net>
|
|
|
|
*
|
|
|
|
* 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.
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
*/
|
2017-11-24 12:41:20 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
|
|
|
|
#include <gst/check/gstcheck.h>
|
|
|
|
|
2012-09-12 09:52:25 +00:00
|
|
|
#define UNDERRUN_LOCK() (g_mutex_lock (&underrun_mutex))
|
|
|
|
#define UNDERRUN_UNLOCK() (g_mutex_unlock (&underrun_mutex))
|
|
|
|
#define UNDERRUN_SIGNAL() (g_cond_signal (&underrun_cond))
|
|
|
|
#define UNDERRUN_WAIT() (g_cond_wait (&underrun_cond, &underrun_mutex))
|
2010-08-18 13:12:45 +00:00
|
|
|
|
|
|
|
static GstElement *queue;
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
|
|
|
|
/* For ease of programming we use globals to keep refs for our floating
|
|
|
|
* src and sink pads we create; otherwise we always have to do get_pad,
|
|
|
|
* get_peer, and then remove references in every test function */
|
2010-08-18 13:12:45 +00:00
|
|
|
static GstPad *mysrcpad;
|
|
|
|
static GstPad *mysinkpad;
|
2012-02-21 15:39:05 +00:00
|
|
|
static GstPad *qsrcpad;
|
|
|
|
static gulong probe_id;
|
2010-08-18 13:12:45 +00:00
|
|
|
|
|
|
|
static gint overrun_count;
|
|
|
|
|
2012-09-12 09:52:25 +00:00
|
|
|
static GMutex underrun_mutex;
|
|
|
|
static GCond underrun_cond;
|
2010-08-18 13:12:45 +00:00
|
|
|
static gint underrun_count;
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
|
2015-04-05 15:06:44 +00:00
|
|
|
static GMutex events_lock;
|
|
|
|
static GCond events_cond;
|
|
|
|
static gint events_count;
|
2010-08-19 15:07:00 +00:00
|
|
|
static GList *events;
|
|
|
|
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +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);
|
|
|
|
|
|
|
|
static void
|
|
|
|
queue_overrun (GstElement * queue, gpointer user_data)
|
|
|
|
{
|
|
|
|
overrun_count++;
|
2012-02-21 15:39:05 +00:00
|
|
|
GST_DEBUG ("queue overrun %d", overrun_count);
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
queue_underrun (GstElement * queue, gpointer user_data)
|
|
|
|
{
|
2010-08-18 13:12:45 +00:00
|
|
|
UNDERRUN_LOCK ();
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
underrun_count++;
|
2012-02-21 15:39:05 +00:00
|
|
|
GST_DEBUG ("queue underrun %d", underrun_count);
|
2010-08-18 13:12:45 +00:00
|
|
|
UNDERRUN_SIGNAL ();
|
|
|
|
UNDERRUN_UNLOCK ();
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
}
|
|
|
|
|
2010-08-19 15:07:00 +00:00
|
|
|
static gboolean
|
2011-11-17 11:40:45 +00:00
|
|
|
event_func (GstPad * pad, GstObject * parent, GstEvent * event)
|
2010-08-19 15:07:00 +00:00
|
|
|
{
|
2015-04-05 15:06:44 +00:00
|
|
|
GST_DEBUG ("%s event", GST_EVENT_TYPE_NAME (event));
|
|
|
|
|
|
|
|
g_mutex_lock (&events_lock);
|
|
|
|
|
2010-08-19 15:07:00 +00:00
|
|
|
events = g_list_append (events, event);
|
2015-04-05 15:06:44 +00:00
|
|
|
++events_count;
|
2010-08-19 15:07:00 +00:00
|
|
|
|
2015-04-05 15:06:44 +00:00
|
|
|
g_cond_broadcast (&events_cond);
|
|
|
|
g_mutex_unlock (&events_lock);
|
2010-08-19 15:07:00 +00:00
|
|
|
|
2015-04-05 15:06:44 +00:00
|
|
|
return TRUE;
|
2010-08-19 15:07:00 +00:00
|
|
|
}
|
|
|
|
|
2012-02-21 15:39:05 +00:00
|
|
|
static void
|
|
|
|
block_src (void)
|
|
|
|
{
|
|
|
|
qsrcpad = gst_element_get_static_pad (queue, "src");
|
|
|
|
probe_id = gst_pad_add_probe (qsrcpad, GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM,
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
unblock_src (void)
|
|
|
|
{
|
|
|
|
gst_pad_remove_probe (qsrcpad, probe_id);
|
|
|
|
gst_object_unref (qsrcpad);
|
|
|
|
}
|
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
static void
|
|
|
|
setup (void)
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
{
|
|
|
|
GST_DEBUG ("setup_queue");
|
|
|
|
|
|
|
|
queue = gst_check_setup_element ("queue");
|
|
|
|
g_signal_connect (queue, "underrun", G_CALLBACK (queue_underrun), NULL);
|
|
|
|
|
2011-11-24 20:36:12 +00:00
|
|
|
mysrcpad = gst_check_setup_src_pad (queue, &srctemplate);
|
2010-08-18 13:12:45 +00:00
|
|
|
gst_pad_set_active (mysrcpad, TRUE);
|
|
|
|
|
2010-08-19 15:07:00 +00:00
|
|
|
mysinkpad = NULL;
|
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
overrun_count = 0;
|
|
|
|
|
|
|
|
underrun_count = 0;
|
2010-08-19 15:07:00 +00:00
|
|
|
|
2015-04-05 15:06:44 +00:00
|
|
|
|
|
|
|
g_mutex_init (&events_lock);
|
|
|
|
g_cond_init (&events_cond);
|
|
|
|
events_count = 0;
|
2010-08-19 15:07:00 +00:00
|
|
|
events = NULL;
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
}
|
|
|
|
|
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* gst/gstconfig.h.in:
* libs/gst/base/gstcollectpads.c: (gst_collect_pads_read_buffer):
* libs/gst/check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_drop_buffers),
(gst_check_element_push_buffer_list):
* libs/gst/controller/gstcontroller.c: (gst_controller_get),
(gst_controller_get_type):
* libs/gst/controller/gsthelper.c: (gst_object_control_properties),
(gst_object_get_controller), (gst_object_get_control_source):
* libs/gst/controller/gstinterpolationcontrolsource.c:
(gst_interpolation_control_source_new):
* libs/gst/controller/gstlfocontrolsource.c:
(gst_lfo_control_source_new):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_event_from_packet_0_2):
* plugins/elements/gstfdsrc.c:
* plugins/elements/gstmultiqueue.c:
* plugins/elements/gsttee.c:
* plugins/elements/gsttypefindelement.c:
* plugins/indexers/gstfileindex.c: (_file_index_id_save_xml),
(gst_file_index_add_association):
* plugins/indexers/gstmemindex.c:
* tests/benchmarks/gstpollstress.c: (mess_some_more):
* tests/check/elements/queue.c: (setup_queue):
* tests/check/gst/gstpipeline.c:
* tests/check/libs/collectpads.c: (setup), (teardown),
(gst_collect_pads_suite):
* tests/examples/adapter/adapter_test.c:
* tests/examples/metadata/read-metadata.c: (make_pipeline):
* tests/examples/xml/createxml.c:
* tests/examples/xml/runxml.c:
* tools/gst-inspect.c:
* tools/gst-run.c:
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers, not using variable sized arrays
on the stack, moving variable declarations to the beginning of
a block and using "foo (void)" instead of "foo ()" for declarations.
2008-02-29 12:41:33 +00:00
|
|
|
static void
|
2010-08-18 13:12:45 +00:00
|
|
|
cleanup (void)
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
{
|
|
|
|
GST_DEBUG ("cleanup_queue");
|
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
gst_check_drop_buffers ();
|
|
|
|
|
2015-04-05 15:06:44 +00:00
|
|
|
while (events != NULL) {
|
|
|
|
gst_event_unref (GST_EVENT (events->data));
|
|
|
|
events = g_list_delete_link (events, events);
|
|
|
|
}
|
|
|
|
events_count = 0;
|
|
|
|
g_mutex_clear (&events_lock);
|
|
|
|
g_cond_clear (&events_cond);
|
2010-08-19 15:07:00 +00:00
|
|
|
|
|
|
|
if (mysinkpad != NULL) {
|
|
|
|
gst_pad_set_active (mysinkpad, FALSE);
|
|
|
|
gst_check_teardown_sink_pad (queue);
|
|
|
|
}
|
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
gst_pad_set_active (mysrcpad, FALSE);
|
|
|
|
gst_check_teardown_src_pad (queue);
|
|
|
|
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
gst_check_teardown_element (queue);
|
2010-08-18 13:12:45 +00:00
|
|
|
queue = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* setup the sinkpad on a playing queue element. gst_check_setup_sink_pad()
|
|
|
|
* does not work in this case since it does not activate the pad before linking
|
|
|
|
* it. */
|
|
|
|
static GstPad *
|
|
|
|
setup_sink_pad (GstElement * element, GstStaticPadTemplate * tmpl)
|
|
|
|
{
|
|
|
|
GstPad *srcpad;
|
|
|
|
GstPad *sinkpad;
|
|
|
|
|
|
|
|
sinkpad = gst_pad_new_from_static_template (tmpl, "sink");
|
|
|
|
fail_if (sinkpad == NULL);
|
|
|
|
srcpad = gst_element_get_static_pad (element, "src");
|
|
|
|
fail_if (srcpad == NULL);
|
|
|
|
gst_pad_set_chain_function (sinkpad, gst_check_chain_func);
|
2010-08-19 15:07:00 +00:00
|
|
|
gst_pad_set_event_function (sinkpad, event_func);
|
2010-08-18 13:12:45 +00:00
|
|
|
gst_pad_set_active (sinkpad, TRUE);
|
|
|
|
fail_unless (gst_pad_link (srcpad, sinkpad) == GST_PAD_LINK_OK);
|
|
|
|
gst_object_unref (srcpad);
|
|
|
|
|
|
|
|
return sinkpad;
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* set queue size to 2 buffers
|
|
|
|
* pull 1 buffer
|
|
|
|
* check over/underuns
|
|
|
|
*/
|
|
|
|
GST_START_TEST (test_non_leaky_underrun)
|
|
|
|
{
|
2010-08-18 13:12:45 +00:00
|
|
|
g_signal_connect (queue, "overrun", G_CALLBACK (queue_overrun), NULL);
|
|
|
|
g_object_set (G_OBJECT (queue), "max-size-buffers", 2, NULL);
|
2011-11-24 20:36:12 +00:00
|
|
|
mysinkpad = gst_check_setup_sink_pad (queue, &sinktemplate);
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
gst_pad_set_active (mysinkpad, TRUE);
|
|
|
|
|
2006-12-21 15:00:08 +00:00
|
|
|
GST_DEBUG ("starting");
|
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
UNDERRUN_LOCK ();
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
2010-08-18 13:12:45 +00:00
|
|
|
UNDERRUN_WAIT ();
|
|
|
|
UNDERRUN_UNLOCK ();
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
|
|
|
|
fail_unless (overrun_count == 0);
|
2006-12-21 14:24:54 +00:00
|
|
|
fail_unless (underrun_count == 1);
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("stopping");
|
2010-08-18 13:12:45 +00:00
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
static void
|
|
|
|
queue_overrun_link_and_activate (GstElement * queue, gpointer user_data)
|
|
|
|
{
|
|
|
|
GST_DEBUG ("queue overrun");
|
|
|
|
overrun_count++;
|
|
|
|
|
|
|
|
/* link the src pad of the queue to make it dequeue buffers */
|
|
|
|
mysinkpad = setup_sink_pad (queue, &sinktemplate);
|
2012-02-21 15:39:05 +00:00
|
|
|
|
|
|
|
unblock_src ();
|
2010-08-18 13:12:45 +00:00
|
|
|
}
|
|
|
|
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
/* set queue size to 2 buffers
|
|
|
|
* push 2 buffers
|
|
|
|
* check over/underuns
|
|
|
|
* push 1 more buffer
|
|
|
|
* check over/underuns again
|
|
|
|
*/
|
|
|
|
GST_START_TEST (test_non_leaky_overrun)
|
|
|
|
{
|
2010-08-18 13:12:45 +00:00
|
|
|
GstBuffer *buffer1;
|
|
|
|
GstBuffer *buffer2;
|
|
|
|
GstBuffer *buffer3;
|
|
|
|
GstBuffer *buffer;
|
2013-05-09 11:32:07 +00:00
|
|
|
GstSegment segment;
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
g_signal_connect (queue, "overrun",
|
|
|
|
G_CALLBACK (queue_overrun_link_and_activate), NULL);
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
g_object_set (G_OBJECT (queue), "max-size-buffers", 2, NULL);
|
|
|
|
|
2012-02-21 15:39:05 +00:00
|
|
|
block_src ();
|
|
|
|
|
2006-12-21 15:00:08 +00:00
|
|
|
GST_DEBUG ("starting");
|
|
|
|
|
2012-02-21 15:39:05 +00:00
|
|
|
UNDERRUN_LOCK ();
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
2012-02-21 15:39:05 +00:00
|
|
|
UNDERRUN_WAIT ();
|
|
|
|
UNDERRUN_UNLOCK ();
|
|
|
|
|
2013-05-09 11:32:07 +00:00
|
|
|
gst_segment_init (&segment, GST_FORMAT_BYTES);
|
2012-07-29 12:25:34 +00:00
|
|
|
gst_pad_push_event (mysrcpad, gst_event_new_stream_start ("test"));
|
2013-05-09 11:32:07 +00:00
|
|
|
gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment));
|
2012-02-21 15:39:05 +00:00
|
|
|
|
|
|
|
fail_unless (underrun_count == 1);
|
2010-08-18 13:12:45 +00:00
|
|
|
fail_unless (overrun_count == 0);
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
|
|
|
|
buffer1 = gst_buffer_new_and_alloc (4);
|
2010-08-18 13:12:45 +00:00
|
|
|
/* pushing gives away my reference */
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
gst_pad_push (mysrcpad, buffer1);
|
|
|
|
|
2006-12-21 09:58:25 +00:00
|
|
|
GST_DEBUG ("added 1st");
|
|
|
|
fail_unless (overrun_count == 0);
|
2012-02-21 15:39:05 +00:00
|
|
|
fail_unless (underrun_count == 1);
|
2006-12-21 09:58:25 +00:00
|
|
|
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
buffer2 = gst_buffer_new_and_alloc (4);
|
|
|
|
gst_pad_push (mysrcpad, buffer2);
|
|
|
|
|
2006-12-21 09:58:25 +00:00
|
|
|
GST_DEBUG ("added 2nd");
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
fail_unless (overrun_count == 0);
|
2012-02-21 15:39:05 +00:00
|
|
|
fail_unless (underrun_count == 1);
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
|
|
|
|
buffer3 = gst_buffer_new_and_alloc (4);
|
2010-08-18 13:12:45 +00:00
|
|
|
/* the next call to gst_pad_push will emit the overrun signal. The signal
|
2010-08-19 08:03:08 +00:00
|
|
|
* handler queue_overrun_link_and_activate() (above) increases overrun_count,
|
|
|
|
* activates and links mysinkpad. The queue task then dequeues a buffer and
|
2010-08-18 13:12:45 +00:00
|
|
|
* gst_pad_push() will return. */
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
gst_pad_push (mysrcpad, buffer3);
|
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
GST_DEBUG ("added 3rd");
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
fail_unless (overrun_count == 1);
|
|
|
|
|
2012-02-21 15:39:05 +00:00
|
|
|
/* lock the check_mutex to block the first buffer pushed to mysinkpad */
|
2012-09-12 10:22:53 +00:00
|
|
|
g_mutex_lock (&check_mutex);
|
2010-08-18 13:12:45 +00:00
|
|
|
/* now let the queue push all buffers */
|
|
|
|
while (g_list_length (buffers) < 3) {
|
2012-09-12 10:22:53 +00:00
|
|
|
g_cond_wait (&check_cond, &check_mutex);
|
2010-08-18 13:12:45 +00:00
|
|
|
}
|
2012-09-12 10:22:53 +00:00
|
|
|
g_mutex_unlock (&check_mutex);
|
2010-08-18 13:12:45 +00:00
|
|
|
|
|
|
|
fail_unless (overrun_count == 1);
|
|
|
|
/* make sure we get the underrun signal before we check underrun_count */
|
|
|
|
UNDERRUN_LOCK ();
|
2012-02-21 15:39:05 +00:00
|
|
|
while (underrun_count < 2) {
|
2010-08-18 13:12:45 +00:00
|
|
|
UNDERRUN_WAIT ();
|
|
|
|
}
|
2012-02-21 15:39:05 +00:00
|
|
|
/* we can't check the underrun_count here safely because when adding the 3rd
|
|
|
|
* buffer, the queue lock is released to emit the overrun signal and the
|
|
|
|
* downstream part can then push and empty the queue and signal an additional
|
|
|
|
* underrun */
|
|
|
|
/* fail_unless_equals_int (underrun_count, 2); */
|
2010-08-18 13:12:45 +00:00
|
|
|
UNDERRUN_UNLOCK ();
|
|
|
|
|
|
|
|
buffer = g_list_nth (buffers, 0)->data;
|
|
|
|
fail_unless (buffer == buffer1);
|
|
|
|
|
|
|
|
buffer = g_list_nth (buffers, 1)->data;
|
|
|
|
fail_unless (buffer == buffer2);
|
|
|
|
|
|
|
|
GST_DEBUG ("stopping");
|
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2007-01-04 13:37:08 +00:00
|
|
|
/* set queue size to 2 buffers
|
|
|
|
* push 2 buffers
|
|
|
|
* check over/underuns
|
|
|
|
* push 1 more buffer
|
|
|
|
* check over/underuns again
|
|
|
|
* check which buffer was leaked
|
|
|
|
*/
|
|
|
|
GST_START_TEST (test_leaky_upstream)
|
|
|
|
{
|
2010-08-18 13:12:45 +00:00
|
|
|
GstBuffer *buffer1;
|
|
|
|
GstBuffer *buffer2;
|
|
|
|
GstBuffer *buffer3;
|
2007-01-04 13:37:08 +00:00
|
|
|
GstBuffer *buffer;
|
2013-05-09 11:32:07 +00:00
|
|
|
GstSegment segment;
|
2007-01-04 13:37:08 +00:00
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
g_signal_connect (queue, "overrun", G_CALLBACK (queue_overrun), NULL);
|
2007-01-04 13:37:08 +00:00
|
|
|
g_object_set (G_OBJECT (queue), "max-size-buffers", 2, "leaky", 1, NULL);
|
|
|
|
|
|
|
|
GST_DEBUG ("starting");
|
|
|
|
|
2012-02-21 15:39:05 +00:00
|
|
|
block_src ();
|
|
|
|
|
|
|
|
UNDERRUN_LOCK ();
|
2007-01-04 13:37:08 +00:00
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
2012-02-21 15:39:05 +00:00
|
|
|
UNDERRUN_WAIT ();
|
|
|
|
UNDERRUN_UNLOCK ();
|
|
|
|
|
2013-05-09 11:32:07 +00:00
|
|
|
gst_segment_init (&segment, GST_FORMAT_BYTES);
|
2012-07-29 12:25:34 +00:00
|
|
|
gst_pad_push_event (mysrcpad, gst_event_new_stream_start ("test"));
|
2013-05-09 11:32:07 +00:00
|
|
|
gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment));
|
2012-02-21 15:39:05 +00:00
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
fail_unless (overrun_count == 0);
|
2012-02-21 15:39:05 +00:00
|
|
|
fail_unless (underrun_count == 1);
|
2007-01-04 13:37:08 +00:00
|
|
|
|
|
|
|
buffer1 = gst_buffer_new_and_alloc (4);
|
2010-08-18 13:12:45 +00:00
|
|
|
/* pushing gives away my reference */
|
2007-01-04 13:37:08 +00:00
|
|
|
gst_pad_push (mysrcpad, buffer1);
|
|
|
|
|
|
|
|
GST_DEBUG ("added 1st");
|
|
|
|
fail_unless (overrun_count == 0);
|
2012-02-21 15:39:05 +00:00
|
|
|
fail_unless (underrun_count == 1);
|
2007-01-04 13:37:08 +00:00
|
|
|
|
|
|
|
buffer2 = gst_buffer_new_and_alloc (4);
|
|
|
|
gst_pad_push (mysrcpad, buffer2);
|
|
|
|
|
|
|
|
GST_DEBUG ("added 2nd");
|
|
|
|
fail_unless (overrun_count == 0);
|
2012-02-21 15:39:05 +00:00
|
|
|
fail_unless (underrun_count == 1);
|
2007-01-04 13:37:08 +00:00
|
|
|
|
|
|
|
buffer3 = gst_buffer_new_and_alloc (4);
|
2012-02-21 15:39:05 +00:00
|
|
|
/* buffer4 will be leaked, keep a ref so refcount can be checked below */
|
2010-08-18 13:12:45 +00:00
|
|
|
gst_buffer_ref (buffer3);
|
|
|
|
gst_pad_push (mysrcpad, buffer3);
|
2007-01-04 13:37:08 +00:00
|
|
|
|
2012-02-21 15:39:05 +00:00
|
|
|
GST_DEBUG ("added 3nd");
|
2010-08-18 13:12:45 +00:00
|
|
|
/* it still triggers overrun when leaking */
|
|
|
|
fail_unless (overrun_count == 1);
|
2012-02-21 15:39:05 +00:00
|
|
|
fail_unless (underrun_count == 1);
|
2007-01-04 13:37:08 +00:00
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
/* wait for underrun and check that we got buffer1 and buffer2 only */
|
|
|
|
UNDERRUN_LOCK ();
|
|
|
|
mysinkpad = setup_sink_pad (queue, &sinktemplate);
|
2012-02-21 15:39:05 +00:00
|
|
|
unblock_src ();
|
2010-08-18 13:12:45 +00:00
|
|
|
UNDERRUN_WAIT ();
|
|
|
|
UNDERRUN_UNLOCK ();
|
2007-01-04 13:37:08 +00:00
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
fail_unless (overrun_count == 1);
|
2012-02-21 15:39:05 +00:00
|
|
|
fail_unless (underrun_count == 2);
|
2007-01-04 13:37:08 +00:00
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
fail_unless (g_list_length (buffers) == 2);
|
|
|
|
|
|
|
|
buffer = g_list_nth (buffers, 0)->data;
|
2007-01-04 13:37:08 +00:00
|
|
|
fail_unless (buffer == buffer1);
|
2010-08-18 13:12:45 +00:00
|
|
|
|
|
|
|
buffer = g_list_nth (buffers, 1)->data;
|
|
|
|
fail_unless (buffer == buffer2);
|
|
|
|
|
2007-01-04 13:37:08 +00:00
|
|
|
ASSERT_BUFFER_REFCOUNT (buffer3, "buffer", 1);
|
2010-08-18 13:12:45 +00:00
|
|
|
gst_buffer_unref (buffer3);
|
2007-01-04 13:37:08 +00:00
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
GST_DEBUG ("stopping");
|
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
|
2007-01-04 13:37:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
/* set queue size to 2 buffers
|
|
|
|
* push 2 buffers
|
|
|
|
* check over/underuns
|
|
|
|
* push 1 more buffer
|
|
|
|
* check over/underuns again
|
|
|
|
* check which buffer was leaked
|
|
|
|
*/
|
2007-01-04 13:37:08 +00:00
|
|
|
GST_START_TEST (test_leaky_downstream)
|
|
|
|
{
|
2010-08-18 13:12:45 +00:00
|
|
|
GstBuffer *buffer1;
|
|
|
|
GstBuffer *buffer2;
|
|
|
|
GstBuffer *buffer3;
|
2007-01-04 13:37:08 +00:00
|
|
|
GstBuffer *buffer;
|
2013-05-09 11:32:07 +00:00
|
|
|
GstSegment segment;
|
2007-01-04 13:37:08 +00:00
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
g_signal_connect (queue, "overrun", G_CALLBACK (queue_overrun), NULL);
|
|
|
|
g_object_set (G_OBJECT (queue), "max-size-buffers", 2, "leaky", 2, NULL);
|
2007-01-04 13:37:08 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("starting");
|
|
|
|
|
2012-02-21 15:39:05 +00:00
|
|
|
block_src ();
|
|
|
|
|
|
|
|
UNDERRUN_LOCK ();
|
2007-01-04 13:37:08 +00:00
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
2012-02-21 15:39:05 +00:00
|
|
|
UNDERRUN_WAIT ();
|
|
|
|
UNDERRUN_UNLOCK ();
|
|
|
|
|
2013-05-09 11:32:07 +00:00
|
|
|
gst_segment_init (&segment, GST_FORMAT_BYTES);
|
2012-07-29 12:25:34 +00:00
|
|
|
gst_pad_push_event (mysrcpad, gst_event_new_stream_start ("test"));
|
2013-05-09 11:32:07 +00:00
|
|
|
gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment));
|
2012-02-21 15:39:05 +00:00
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
fail_unless (overrun_count == 0);
|
2012-02-21 15:39:05 +00:00
|
|
|
fail_unless (underrun_count == 1);
|
2007-01-04 13:37:08 +00:00
|
|
|
|
|
|
|
buffer1 = gst_buffer_new_and_alloc (4);
|
2012-02-21 15:39:05 +00:00
|
|
|
/* pushing gives away one reference */
|
2010-08-18 13:12:45 +00:00
|
|
|
/* buffer1 will be leaked, keep a ref so refcount can be checked below */
|
|
|
|
gst_buffer_ref (buffer1);
|
|
|
|
gst_pad_push (mysrcpad, buffer1);
|
2007-01-04 13:37:08 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("added 1st");
|
|
|
|
fail_unless (overrun_count == 0);
|
2012-02-21 15:39:05 +00:00
|
|
|
fail_unless (underrun_count == 1);
|
2007-01-04 13:37:08 +00:00
|
|
|
|
|
|
|
buffer2 = gst_buffer_new_and_alloc (4);
|
|
|
|
gst_pad_push (mysrcpad, buffer2);
|
|
|
|
|
|
|
|
GST_DEBUG ("added 2nd");
|
|
|
|
fail_unless (overrun_count == 0);
|
2012-02-21 15:39:05 +00:00
|
|
|
fail_unless (underrun_count == 1);
|
2007-01-04 13:37:08 +00:00
|
|
|
|
|
|
|
buffer3 = gst_buffer_new_and_alloc (4);
|
|
|
|
gst_pad_push (mysrcpad, buffer3);
|
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
GST_DEBUG ("added 3rd");
|
|
|
|
/* it still triggers overrun when leaking */
|
|
|
|
fail_unless (overrun_count == 1);
|
2012-02-21 15:39:05 +00:00
|
|
|
fail_unless (underrun_count == 1);
|
2007-01-04 13:37:08 +00:00
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
/* wait for underrun and check that we got buffer1 and buffer2 only */
|
|
|
|
UNDERRUN_LOCK ();
|
|
|
|
mysinkpad = setup_sink_pad (queue, &sinktemplate);
|
2012-02-21 15:39:05 +00:00
|
|
|
unblock_src ();
|
2010-08-18 13:12:45 +00:00
|
|
|
UNDERRUN_WAIT ();
|
|
|
|
UNDERRUN_UNLOCK ();
|
2007-01-04 13:37:08 +00:00
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
fail_unless (overrun_count == 1);
|
2012-02-21 15:39:05 +00:00
|
|
|
fail_unless (underrun_count == 2);
|
2010-08-18 13:12:45 +00:00
|
|
|
|
|
|
|
fail_unless (g_list_length (buffers) == 2);
|
2007-01-04 13:37:08 +00:00
|
|
|
|
|
|
|
ASSERT_BUFFER_REFCOUNT (buffer1, "buffer", 1);
|
2010-08-18 13:12:45 +00:00
|
|
|
gst_buffer_unref (buffer1);
|
2007-01-04 13:37:08 +00:00
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
buffer = g_list_nth (buffers, 0)->data;
|
|
|
|
fail_unless (buffer == buffer2);
|
|
|
|
|
|
|
|
buffer = g_list_nth (buffers, 1)->data;
|
|
|
|
fail_unless (buffer == buffer3);
|
|
|
|
|
|
|
|
GST_DEBUG ("stopping");
|
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
|
2007-01-04 13:37:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
/* set queue size to 6 buffers and 7 seconds
|
|
|
|
* push 7 buffers with and without duration
|
|
|
|
* check current-level-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_START_TEST (test_time_level)
|
|
|
|
{
|
|
|
|
GstBuffer *buffer = NULL;
|
|
|
|
GstClockTime time;
|
2013-05-09 11:32:07 +00:00
|
|
|
GstSegment 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
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
g_signal_connect (queue, "overrun",
|
|
|
|
G_CALLBACK (queue_overrun_link_and_activate), 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
|
|
|
g_object_set (G_OBJECT (queue), "max-size-buffers", 6, NULL);
|
2010-08-18 13:12:45 +00:00
|
|
|
g_object_set (G_OBJECT (queue), "max-size-time", 7 * GST_SECOND, 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
|
|
|
|
|
|
|
GST_DEBUG ("starting");
|
|
|
|
|
2012-02-21 15:39:05 +00:00
|
|
|
block_src ();
|
|
|
|
|
|
|
|
UNDERRUN_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
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
2012-02-21 15:39:05 +00:00
|
|
|
UNDERRUN_WAIT ();
|
|
|
|
UNDERRUN_UNLOCK ();
|
|
|
|
|
2013-05-09 11:32:07 +00:00
|
|
|
gst_segment_init (&segment, GST_FORMAT_BYTES);
|
2012-07-29 12:25:34 +00:00
|
|
|
gst_pad_push_event (mysrcpad, gst_event_new_stream_start ("test"));
|
2013-05-09 11:32:07 +00:00
|
|
|
gst_pad_push_event (mysrcpad, gst_event_new_segment (&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
|
|
|
|
|
|
|
/* push buffer without duration */
|
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer) = GST_SECOND;
|
2010-08-18 13:12:45 +00:00
|
|
|
/* pushing gives away my reference */
|
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_pad_push (mysrcpad, buffer);
|
|
|
|
|
|
|
|
/* level should be 1 seconds because buffer has no duration and starts at 1
|
|
|
|
* SECOND (sparse stream). */
|
|
|
|
g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL);
|
|
|
|
fail_if (time != GST_SECOND);
|
|
|
|
|
|
|
|
/* second push should set the level to 2 second */
|
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer) = 2 * GST_SECOND;
|
|
|
|
gst_pad_push (mysrcpad, buffer);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL);
|
|
|
|
fail_if (time != 2 * GST_SECOND);
|
|
|
|
|
|
|
|
/* third push should set the level to 4 seconds, the 1 second diff with the
|
|
|
|
* previous buffer (without duration) and the 1 second duration of this
|
|
|
|
* buffer. */
|
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer) = 3 * GST_SECOND;
|
|
|
|
GST_BUFFER_DURATION (buffer) = 1 * GST_SECOND;
|
|
|
|
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
|
|
|
|
gst_pad_push (mysrcpad, buffer);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL);
|
|
|
|
fail_if (time != 4 * GST_SECOND);
|
|
|
|
|
|
|
|
/* fourth push should set the level to 6 seconds, the 2 second diff with the
|
|
|
|
* previous buffer, same duration. */
|
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer) = 5 * GST_SECOND;
|
|
|
|
GST_BUFFER_DURATION (buffer) = 1 * GST_SECOND;
|
|
|
|
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
|
|
|
|
gst_pad_push (mysrcpad, buffer);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL);
|
|
|
|
fail_if (time != 6 * GST_SECOND);
|
|
|
|
|
|
|
|
/* fifth push should not adjust the level, the timestamp and duration are the
|
|
|
|
* same, meaning the previous buffer did not really have a duration. */
|
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer) = 5 * GST_SECOND;
|
|
|
|
GST_BUFFER_DURATION (buffer) = 1 * GST_SECOND;
|
|
|
|
gst_pad_push (mysrcpad, buffer);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL);
|
|
|
|
fail_if (time != 6 * GST_SECOND);
|
|
|
|
|
|
|
|
/* sixth push should adjust the level with 1 second, we now know the
|
|
|
|
* previous buffer actually had a duration of 2 SECONDS */
|
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer) = 7 * GST_SECOND;
|
|
|
|
gst_pad_push (mysrcpad, buffer);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL);
|
|
|
|
fail_if (time != 7 * GST_SECOND);
|
|
|
|
|
2010-08-18 13:12:45 +00:00
|
|
|
/* eighth push should cause overrun */
|
|
|
|
fail_unless (overrun_count == 0);
|
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer) = 8 * GST_SECOND;
|
|
|
|
/* the next call to gst_pad_push will emit the overrun signal. The signal
|
2010-08-19 08:03:08 +00:00
|
|
|
* handler queue_overrun_link_and_activate() (above) increases overrun_count,
|
|
|
|
* activates and links mysinkpad. The queue task then dequeues a buffer and
|
2010-08-18 13:12:45 +00:00
|
|
|
* gst_pad_push() will return. */
|
|
|
|
gst_pad_push (mysrcpad, buffer);
|
|
|
|
|
|
|
|
fail_unless (overrun_count == 1);
|
|
|
|
|
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_DEBUG ("stopping");
|
2010-08-18 13:12:45 +00:00
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
|
2010-08-19 15:07:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
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-11 08:27:52 +00:00
|
|
|
GST_START_TEST (test_time_level_task_not_started)
|
|
|
|
{
|
|
|
|
GstEvent *event;
|
|
|
|
GstClockTime time;
|
2011-05-13 16:07:24 +00:00
|
|
|
GstSegment segment;
|
2010-10-11 08:27:52 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("starting");
|
|
|
|
|
2012-02-21 15:39:05 +00:00
|
|
|
block_src ();
|
|
|
|
|
|
|
|
UNDERRUN_LOCK ();
|
2010-10-11 08:27:52 +00:00
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
2012-02-21 15:39:05 +00:00
|
|
|
UNDERRUN_WAIT ();
|
|
|
|
UNDERRUN_UNLOCK ();
|
|
|
|
|
2012-07-29 12:25:34 +00:00
|
|
|
gst_pad_push_event (mysrcpad, gst_event_new_stream_start ("test"));
|
2010-10-11 08:27:52 +00:00
|
|
|
|
2011-05-13 16:07:24 +00:00
|
|
|
gst_segment_init (&segment, GST_FORMAT_TIME);
|
|
|
|
segment.start = 1 * GST_SECOND;
|
|
|
|
segment.stop = 5 * GST_SECOND;
|
|
|
|
segment.time = 0;
|
2011-07-05 14:20:03 +00:00
|
|
|
segment.position = 1 * GST_SECOND;
|
2011-05-13 16:07:24 +00:00
|
|
|
|
|
|
|
event = gst_event_new_segment (&segment);
|
2010-10-11 08:27:52 +00:00
|
|
|
gst_pad_push_event (mysrcpad, event);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL);
|
|
|
|
fail_if (time != 0 * GST_SECOND);
|
|
|
|
|
2011-05-13 16:07:24 +00:00
|
|
|
segment.base = 4 * GST_SECOND;
|
|
|
|
event = gst_event_new_segment (&segment);
|
2010-10-11 08:27:52 +00:00
|
|
|
gst_pad_push_event (mysrcpad, event);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL);
|
2011-07-05 14:20:03 +00:00
|
|
|
GST_DEBUG ("time now %" GST_TIME_FORMAT, GST_TIME_ARGS (time));
|
2010-10-11 08:27:52 +00:00
|
|
|
fail_if (time != 4 * GST_SECOND);
|
|
|
|
|
2012-02-21 15:39:05 +00:00
|
|
|
unblock_src ();
|
|
|
|
|
2010-10-11 08:27:52 +00:00
|
|
|
GST_DEBUG ("stopping");
|
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2012-10-29 12:08:31 +00:00
|
|
|
GST_START_TEST (test_sticky_not_linked)
|
|
|
|
{
|
|
|
|
GstEvent *event;
|
|
|
|
GstSegment segment;
|
|
|
|
gboolean ret;
|
|
|
|
GstFlowReturn flow_ret;
|
|
|
|
|
|
|
|
GST_DEBUG ("starting");
|
|
|
|
|
|
|
|
g_object_set (queue, "max-size-buffers", 1, NULL);
|
|
|
|
|
|
|
|
UNDERRUN_LOCK ();
|
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
UNDERRUN_WAIT ();
|
|
|
|
UNDERRUN_UNLOCK ();
|
|
|
|
|
|
|
|
gst_pad_push_event (mysrcpad, gst_event_new_stream_start ("test"));
|
|
|
|
|
|
|
|
gst_segment_init (&segment, GST_FORMAT_TIME);
|
|
|
|
segment.start = 1 * GST_SECOND;
|
|
|
|
segment.stop = 5 * GST_SECOND;
|
|
|
|
segment.time = 0;
|
|
|
|
segment.position = 1 * GST_SECOND;
|
|
|
|
|
|
|
|
event = gst_event_new_segment (&segment);
|
|
|
|
ret = gst_pad_push_event (mysrcpad, event);
|
|
|
|
fail_unless (ret == TRUE);
|
|
|
|
|
|
|
|
/* the first few buffers can return OK as they are queued and gst_queue_loop
|
|
|
|
* is woken up, tries to push and sets ->srcresult to NOT_LINKED
|
|
|
|
*/
|
|
|
|
flow_ret = GST_FLOW_OK;
|
|
|
|
while (flow_ret != GST_FLOW_NOT_LINKED)
|
|
|
|
flow_ret = gst_pad_push (mysrcpad, gst_buffer_new ());
|
|
|
|
|
|
|
|
/* send a new sticky event so that it will be pushed on the next gst_pad_push
|
|
|
|
*/
|
|
|
|
event = gst_event_new_segment (&segment);
|
|
|
|
ret = gst_pad_push_event (mysrcpad, event);
|
|
|
|
fail_unless (ret == TRUE);
|
|
|
|
|
|
|
|
/* make sure that gst_queue_sink_event doesn't return FALSE if the queue is
|
|
|
|
* unlinked, as that would make gst_pad_push return ERROR
|
|
|
|
*/
|
|
|
|
flow_ret = gst_pad_push (mysrcpad, gst_buffer_new ());
|
|
|
|
fail_unless_equals_int (flow_ret, GST_FLOW_NOT_LINKED);
|
|
|
|
|
|
|
|
GST_DEBUG ("stopping");
|
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2011-05-13 16:07:24 +00:00
|
|
|
#if 0
|
2010-08-19 15:07:00 +00:00
|
|
|
static gboolean
|
|
|
|
event_equals_newsegment (GstEvent * event, gboolean update, gdouble rate,
|
|
|
|
GstFormat format, gint64 start, gint64 stop, gint64 position)
|
|
|
|
{
|
|
|
|
gboolean ns_update;
|
2011-05-09 15:51:07 +00:00
|
|
|
gdouble ns_rate, ns_arate;
|
2010-08-19 15:07:00 +00:00
|
|
|
GstFormat ns_format;
|
|
|
|
gint64 ns_start;
|
|
|
|
gint64 ns_stop;
|
|
|
|
gint64 ns_position;
|
|
|
|
|
2011-05-13 16:07:24 +00:00
|
|
|
if (GST_EVENT_TYPE (event) != GST_EVENT_SEGMENT) {
|
2010-08-19 15:07:00 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-05-09 15:51:07 +00:00
|
|
|
gst_event_parse_new_segment (event, &ns_update, &ns_rate, &ns_arate,
|
|
|
|
&ns_format, &ns_start, &ns_stop, &ns_position);
|
2010-08-19 15:07:00 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("update %d, rate %lf, format %s, start %" GST_TIME_FORMAT
|
|
|
|
", stop %" GST_TIME_FORMAT ", position %" GST_TIME_FORMAT, ns_update,
|
|
|
|
ns_rate, gst_format_get_name (ns_format), GST_TIME_ARGS (ns_start),
|
|
|
|
GST_TIME_ARGS (ns_stop), GST_TIME_ARGS (ns_position));
|
|
|
|
|
|
|
|
return (ns_update == update && ns_rate == rate && ns_format == format &&
|
|
|
|
ns_start == start && ns_stop == stop && ns_position == position);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_newsegment)
|
|
|
|
{
|
|
|
|
GstEvent *event;
|
|
|
|
GstBuffer *buffer1;
|
|
|
|
GstBuffer *buffer2;
|
|
|
|
GstBuffer *buffer;
|
|
|
|
|
|
|
|
g_signal_connect (queue, "overrun", G_CALLBACK (queue_overrun), NULL);
|
2010-08-23 11:06:19 +00:00
|
|
|
g_object_set (G_OBJECT (queue), "max-size-buffers", 1, "max-size-time",
|
|
|
|
(guint64) 0, "leaky", 2, NULL);
|
2010-08-19 15:07:00 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("starting");
|
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
fail_unless (overrun_count == 0);
|
|
|
|
fail_unless (underrun_count == 0);
|
|
|
|
|
2011-05-09 15:51:07 +00:00
|
|
|
event = gst_event_new_new_segment (FALSE, 2.0, 1.0, GST_FORMAT_TIME, 0,
|
2010-08-19 15:07:00 +00:00
|
|
|
2 * GST_SECOND, 0);
|
|
|
|
gst_pad_push_event (mysrcpad, event);
|
|
|
|
|
|
|
|
GST_DEBUG ("added 1st newsegment");
|
|
|
|
fail_unless (overrun_count == 0);
|
|
|
|
fail_unless (underrun_count == 0);
|
|
|
|
|
2011-05-09 15:51:07 +00:00
|
|
|
event = gst_event_new_new_segment (FALSE, 1.0, 1.0, GST_FORMAT_TIME, 0,
|
2010-08-19 15:07:00 +00:00
|
|
|
3 * GST_SECOND, 0);
|
|
|
|
gst_pad_push_event (mysrcpad, event);
|
|
|
|
|
|
|
|
GST_DEBUG ("added 2nd newsegment");
|
|
|
|
fail_unless (overrun_count == 0);
|
|
|
|
fail_unless (underrun_count == 0);
|
|
|
|
|
2011-05-09 15:51:07 +00:00
|
|
|
event = gst_event_new_new_segment (FALSE, 1.0, 1.0, GST_FORMAT_TIME,
|
2010-08-19 15:07:00 +00:00
|
|
|
4 * GST_SECOND, 5 * GST_SECOND, 4 * GST_SECOND);
|
|
|
|
gst_pad_push_event (mysrcpad, event);
|
|
|
|
|
|
|
|
GST_DEBUG ("added 3rd newsegment");
|
|
|
|
fail_unless (overrun_count == 0);
|
|
|
|
fail_unless (underrun_count == 0);
|
|
|
|
|
|
|
|
buffer1 = gst_buffer_new_and_alloc (4);
|
|
|
|
/* buffer1 will be leaked, keep a ref so refcount can be checked below */
|
|
|
|
gst_buffer_ref (buffer1);
|
|
|
|
/* pushing gives away one reference */
|
|
|
|
gst_pad_push (mysrcpad, buffer1);
|
|
|
|
|
|
|
|
GST_DEBUG ("added 1st buffer");
|
|
|
|
fail_unless (overrun_count == 0);
|
|
|
|
fail_unless (underrun_count == 0);
|
|
|
|
|
|
|
|
buffer2 = gst_buffer_new_and_alloc (4);
|
|
|
|
/* next push will cause overrun and leak all newsegment events and buffer1 */
|
|
|
|
gst_pad_push (mysrcpad, buffer2);
|
|
|
|
|
|
|
|
GST_DEBUG ("added 2nd buffer");
|
|
|
|
/* it still triggers overrun when leaking */
|
|
|
|
fail_unless (overrun_count == 1);
|
|
|
|
fail_unless (underrun_count == 0);
|
|
|
|
|
|
|
|
/* wait for underrun and check that we got one accumulated newsegment event,
|
|
|
|
* one real newsegment event and buffer2 only */
|
|
|
|
UNDERRUN_LOCK ();
|
|
|
|
mysinkpad = setup_sink_pad (queue, &sinktemplate);
|
|
|
|
UNDERRUN_WAIT ();
|
|
|
|
UNDERRUN_UNLOCK ();
|
|
|
|
|
|
|
|
fail_unless (overrun_count == 1);
|
|
|
|
fail_unless (underrun_count == 1);
|
|
|
|
|
|
|
|
fail_unless (g_list_length (events) == 2);
|
|
|
|
|
|
|
|
event = g_list_nth (events, 0)->data;
|
|
|
|
fail_unless (event_equals_newsegment (event, FALSE, 1.0, GST_FORMAT_TIME, 0,
|
|
|
|
4 * GST_SECOND, 0));
|
|
|
|
|
|
|
|
event = g_list_nth (events, 1)->data;
|
|
|
|
fail_unless (event_equals_newsegment (event, FALSE, 1.0, GST_FORMAT_TIME,
|
|
|
|
4 * GST_SECOND, 5 * GST_SECOND, 4 * GST_SECOND));
|
|
|
|
|
|
|
|
fail_unless (g_list_length (buffers) == 1);
|
|
|
|
|
|
|
|
ASSERT_BUFFER_REFCOUNT (buffer1, "buffer", 1);
|
|
|
|
gst_buffer_unref (buffer1);
|
|
|
|
|
|
|
|
buffer = g_list_nth (buffers, 0)->data;
|
|
|
|
fail_unless (buffer == buffer2);
|
|
|
|
|
|
|
|
GST_DEBUG ("stopping");
|
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to 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
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
2011-05-13 16:07:24 +00:00
|
|
|
#endif
|
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-01-29 11:40:52 +00:00
|
|
|
static gpointer
|
|
|
|
thread_func (gpointer data)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
for (i = 0; i < 100; i++) {
|
|
|
|
GstCaps *caps;
|
|
|
|
GstQuery *query;
|
|
|
|
gboolean ok;
|
|
|
|
caps = gst_caps_new_any ();
|
|
|
|
query = gst_query_new_allocation (caps, FALSE);
|
|
|
|
ok = gst_pad_peer_query (mysrcpad, query);
|
|
|
|
gst_query_unref (query);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
query = NULL;
|
|
|
|
caps = NULL;
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean query_func (GstPad * pad, GstObject * parent, GstQuery * query);
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
query_func (GstPad * pad, GstObject * parent, GstQuery * query)
|
|
|
|
{
|
|
|
|
|
|
|
|
g_usleep (1000);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_queries_while_flushing)
|
|
|
|
{
|
|
|
|
GstEvent *event;
|
|
|
|
GThread *thread;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
mysinkpad = gst_check_setup_sink_pad (queue, &sinktemplate);
|
|
|
|
gst_pad_set_query_function (mysinkpad, query_func);
|
|
|
|
gst_pad_set_active (mysinkpad, TRUE);
|
|
|
|
|
|
|
|
/* hard to reproduce, so just run it a few times in a row */
|
|
|
|
for (i = 0; i < 500; ++i) {
|
|
|
|
GST_DEBUG ("starting");
|
|
|
|
UNDERRUN_LOCK ();
|
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
UNDERRUN_WAIT ();
|
|
|
|
UNDERRUN_UNLOCK ();
|
|
|
|
|
|
|
|
thread = g_thread_new ("deactivating thread", thread_func, NULL);
|
|
|
|
g_usleep (1000);
|
|
|
|
|
|
|
|
event = gst_event_new_flush_start ();
|
|
|
|
gst_pad_push_event (mysrcpad, event);
|
|
|
|
|
|
|
|
g_thread_join (thread);
|
|
|
|
|
|
|
|
GST_DEBUG ("stopping");
|
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to null");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2018-03-01 21:19:09 +00:00
|
|
|
|
|
|
|
GST_START_TEST (test_serialized_query_with_threshold)
|
|
|
|
{
|
|
|
|
GstQuery *query;
|
|
|
|
GstSegment segment;
|
|
|
|
|
|
|
|
gst_segment_init (&segment, GST_FORMAT_BYTES);
|
|
|
|
|
|
|
|
mysinkpad = gst_check_setup_sink_pad (queue, &sinktemplate);
|
|
|
|
gst_pad_set_event_function (mysinkpad, event_func);
|
|
|
|
gst_pad_set_active (mysinkpad, TRUE);
|
|
|
|
|
|
|
|
g_object_set (queue, "min-threshold-buffers", 10, NULL);
|
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
gst_pad_push_event (mysrcpad, gst_event_new_stream_start ("test"));
|
|
|
|
gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment));
|
|
|
|
|
|
|
|
gst_pad_push (mysrcpad, gst_buffer_new ());
|
|
|
|
|
|
|
|
query = gst_query_new_drain ();
|
|
|
|
gst_pad_peer_query (mysrcpad, query);
|
|
|
|
gst_query_unref (query);
|
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
|
2014-08-20 10:55:51 +00:00
|
|
|
static gpointer
|
|
|
|
push_event_thread_func (gpointer data)
|
|
|
|
{
|
|
|
|
GstEvent *event;
|
|
|
|
|
|
|
|
event = GST_EVENT (data);
|
|
|
|
|
|
|
|
GST_DEBUG ("pushing event %p on pad %p", event, mysrcpad);
|
|
|
|
gst_pad_push_event (mysrcpad, event);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_state_change_when_flushing)
|
|
|
|
{
|
|
|
|
GstEvent *event;
|
|
|
|
GThread *thread;
|
|
|
|
|
|
|
|
mysinkpad = gst_check_setup_sink_pad (queue, &sinktemplate);
|
|
|
|
gst_pad_set_active (mysinkpad, TRUE);
|
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (queue, GST_STATE_PAUSED) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
|
|
|
|
event = gst_event_new_flush_start ();
|
|
|
|
gst_pad_push_event (mysrcpad, event);
|
|
|
|
|
|
|
|
event = gst_event_new_flush_stop (TRUE);
|
|
|
|
thread = g_thread_new ("send event", push_event_thread_func, event);
|
|
|
|
|
|
|
|
GST_DEBUG ("changing state to READY");
|
|
|
|
fail_unless (gst_element_set_state (queue, GST_STATE_READY) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
GST_DEBUG ("state changed");
|
|
|
|
|
|
|
|
g_thread_join (thread);
|
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (queue, GST_STATE_NULL) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2015-02-17 10:11:43 +00:00
|
|
|
GST_START_TEST (test_time_level_buffer_list)
|
|
|
|
{
|
|
|
|
GstBuffer *buffer = NULL;
|
|
|
|
GstBufferList *buffer_list = NULL;
|
|
|
|
GstClockTime time;
|
|
|
|
guint buffers;
|
|
|
|
GstSegment segment;
|
|
|
|
|
|
|
|
g_signal_connect (queue, "overrun",
|
|
|
|
G_CALLBACK (queue_overrun_link_and_activate), NULL);
|
|
|
|
g_object_set (G_OBJECT (queue), "max-size-buffers", 11, NULL);
|
|
|
|
g_object_set (G_OBJECT (queue), "max-size-time",
|
|
|
|
G_GUINT64_CONSTANT (7000) * GST_MSECOND, NULL);
|
|
|
|
|
|
|
|
GST_DEBUG ("starting");
|
|
|
|
|
|
|
|
block_src ();
|
|
|
|
|
|
|
|
UNDERRUN_LOCK ();
|
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
UNDERRUN_WAIT ();
|
|
|
|
UNDERRUN_UNLOCK ();
|
|
|
|
|
|
|
|
gst_segment_init (&segment, GST_FORMAT_BYTES);
|
|
|
|
gst_pad_push_event (mysrcpad, gst_event_new_stream_start ("test"));
|
|
|
|
gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment));
|
|
|
|
|
|
|
|
/* push buffer without duration */
|
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer) = 1000 * GST_MSECOND;
|
|
|
|
/* pushing gives away my reference */
|
|
|
|
gst_pad_push (mysrcpad, buffer);
|
|
|
|
|
|
|
|
/* level should be 1 seconds because buffer has no duration and starts at 1
|
|
|
|
* SECOND (sparse stream). */
|
|
|
|
g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL);
|
|
|
|
fail_unless_equals_uint64 (time, 1000 * GST_MSECOND);
|
|
|
|
g_object_get (G_OBJECT (queue), "current-level-buffers", &buffers, NULL);
|
|
|
|
fail_unless_equals_int (buffers, 1);
|
|
|
|
|
|
|
|
/* second push should set the level to 2 second */
|
|
|
|
buffer_list = gst_buffer_list_new ();
|
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer) = 1500 * GST_MSECOND;
|
|
|
|
gst_buffer_list_add (buffer_list, buffer);
|
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer) = 2000 * GST_MSECOND;
|
|
|
|
gst_buffer_list_add (buffer_list, buffer);
|
|
|
|
gst_pad_push_list (mysrcpad, buffer_list);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL);
|
|
|
|
fail_unless_equals_uint64 (time, 2000 * GST_MSECOND);
|
|
|
|
g_object_get (G_OBJECT (queue), "current-level-buffers", &buffers, NULL);
|
|
|
|
fail_unless_equals_int (buffers, 3);
|
|
|
|
|
|
|
|
/* third push should set the level to 4 seconds, the 1 second diff with the
|
|
|
|
* previous buffer (without duration) and the 1 second duration of this
|
|
|
|
* buffer. */
|
|
|
|
buffer_list = gst_buffer_list_new ();
|
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer) = 3000 * GST_MSECOND;
|
|
|
|
GST_BUFFER_DURATION (buffer) = 500 * GST_MSECOND;
|
|
|
|
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
|
|
|
|
gst_buffer_list_add (buffer_list, buffer);
|
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer) = 3500 * GST_MSECOND;
|
|
|
|
GST_BUFFER_DURATION (buffer) = 500 * GST_MSECOND;
|
|
|
|
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
|
|
|
|
gst_buffer_list_add (buffer_list, buffer);
|
|
|
|
gst_pad_push_list (mysrcpad, buffer_list);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL);
|
|
|
|
fail_unless_equals_uint64 (time, 4000 * GST_MSECOND);
|
|
|
|
g_object_get (G_OBJECT (queue), "current-level-buffers", &buffers, NULL);
|
|
|
|
fail_unless_equals_int (buffers, 5);
|
|
|
|
|
|
|
|
/* fourth push should set the level to 6 seconds, the 2 second diff with the
|
|
|
|
* previous buffer, same duration. */
|
|
|
|
buffer_list = gst_buffer_list_new ();
|
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer) = 5000 * GST_MSECOND;
|
|
|
|
GST_BUFFER_DURATION (buffer) = 1000 * GST_MSECOND;
|
|
|
|
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
|
|
|
|
gst_buffer_list_add (buffer_list, buffer);
|
|
|
|
gst_pad_push_list (mysrcpad, buffer_list);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL);
|
|
|
|
fail_unless_equals_uint64 (time, 6000 * GST_MSECOND);
|
|
|
|
g_object_get (G_OBJECT (queue), "current-level-buffers", &buffers, NULL);
|
|
|
|
fail_unless_equals_int (buffers, 6);
|
|
|
|
|
|
|
|
/* fifth push should not adjust the level, the timestamp and duration are the
|
|
|
|
* same, meaning the previous buffer did not really have a duration. */
|
|
|
|
buffer_list = gst_buffer_list_new ();
|
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer) = 5000 * GST_MSECOND;
|
|
|
|
GST_BUFFER_DURATION (buffer) = 250 * GST_MSECOND;
|
|
|
|
gst_buffer_list_add (buffer_list, buffer);
|
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer) = 5250 * GST_MSECOND;
|
|
|
|
GST_BUFFER_DURATION (buffer) = 250 * GST_MSECOND;
|
|
|
|
gst_buffer_list_add (buffer_list, buffer);
|
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer) = 5500 * GST_MSECOND;
|
|
|
|
GST_BUFFER_DURATION (buffer) = 250 * GST_MSECOND;
|
|
|
|
gst_buffer_list_add (buffer_list, buffer);
|
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer) = 5750 * GST_MSECOND;
|
|
|
|
GST_BUFFER_DURATION (buffer) = 250 * GST_MSECOND;
|
|
|
|
gst_buffer_list_add (buffer_list, buffer);
|
|
|
|
gst_pad_push_list (mysrcpad, buffer_list);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL);
|
|
|
|
fail_unless_equals_uint64 (time, 6000 * GST_MSECOND);
|
|
|
|
g_object_get (G_OBJECT (queue), "current-level-buffers", &buffers, NULL);
|
|
|
|
fail_unless_equals_int (buffers, 10);
|
|
|
|
|
|
|
|
/* sixth push should adjust the level with 1 second, we now know the
|
|
|
|
* previous buffer actually had a duration of 2 SECONDS */
|
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer) = 7000 * GST_MSECOND;
|
|
|
|
gst_pad_push (mysrcpad, buffer);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL);
|
|
|
|
fail_unless_equals_uint64 (time, 7000 * GST_MSECOND);
|
|
|
|
g_object_get (G_OBJECT (queue), "current-level-buffers", &buffers, NULL);
|
|
|
|
fail_unless_equals_int (buffers, 11);
|
|
|
|
|
|
|
|
/* eighth push should cause overrun */
|
|
|
|
fail_unless (overrun_count == 0);
|
|
|
|
buffer_list = gst_buffer_list_new ();
|
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer) = 8000 * GST_MSECOND;
|
|
|
|
/* the next call to gst_pad_push will emit the overrun signal. The signal
|
|
|
|
* handler queue_overrun_link_and_activate() (above) increases overrun_count,
|
|
|
|
* activates and links mysinkpad. The queue task then dequeues a buffer and
|
|
|
|
* gst_pad_push() will return. */
|
|
|
|
gst_buffer_list_add (buffer_list, buffer);
|
|
|
|
gst_pad_push_list (mysrcpad, buffer_list);
|
|
|
|
|
|
|
|
fail_unless (overrun_count == 1);
|
|
|
|
|
|
|
|
GST_DEBUG ("stopping");
|
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2015-04-05 15:06:44 +00:00
|
|
|
GST_START_TEST (test_initial_events_nodelay)
|
|
|
|
{
|
|
|
|
GstSegment segment;
|
|
|
|
GstEvent *event;
|
|
|
|
GstCaps *caps;
|
|
|
|
gboolean ret;
|
|
|
|
|
|
|
|
mysinkpad = gst_check_setup_sink_pad (queue, &sinktemplate);
|
|
|
|
gst_pad_set_event_function (mysinkpad, event_func);
|
|
|
|
gst_pad_set_active (mysinkpad, TRUE);
|
|
|
|
|
|
|
|
GST_DEBUG ("starting");
|
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (queue,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
gst_pad_push_event (mysrcpad, gst_event_new_stream_start ("test"));
|
|
|
|
|
|
|
|
caps = gst_caps_new_empty_simple ("foo/x-bar");
|
|
|
|
ret = gst_pad_push_event (mysrcpad, gst_event_new_caps (caps));
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
fail_unless (ret == TRUE);
|
|
|
|
|
|
|
|
gst_segment_init (&segment, GST_FORMAT_TIME);
|
|
|
|
ret = gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment));
|
|
|
|
fail_unless (ret == TRUE);
|
|
|
|
|
|
|
|
g_mutex_lock (&events_lock);
|
|
|
|
while (events_count < 3) {
|
|
|
|
g_cond_wait (&events_cond, &events_lock);
|
|
|
|
}
|
|
|
|
g_mutex_unlock (&events_lock);
|
|
|
|
|
|
|
|
fail_unless_equals_int (g_list_length (events), 3);
|
|
|
|
event = g_list_nth_data (events, 0);
|
|
|
|
fail_unless_equals_int (GST_EVENT_TYPE (event), GST_EVENT_STREAM_START);
|
|
|
|
event = g_list_nth_data (events, 1);
|
|
|
|
fail_unless_equals_int (GST_EVENT_TYPE (event), GST_EVENT_CAPS);
|
|
|
|
event = g_list_nth_data (events, 2);
|
|
|
|
fail_unless_equals_int (GST_EVENT_TYPE (event), GST_EVENT_SEGMENT);
|
|
|
|
|
|
|
|
gst_element_set_state (queue, GST_STATE_NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* gst/gstconfig.h.in:
* libs/gst/base/gstcollectpads.c: (gst_collect_pads_read_buffer):
* libs/gst/check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_drop_buffers),
(gst_check_element_push_buffer_list):
* libs/gst/controller/gstcontroller.c: (gst_controller_get),
(gst_controller_get_type):
* libs/gst/controller/gsthelper.c: (gst_object_control_properties),
(gst_object_get_controller), (gst_object_get_control_source):
* libs/gst/controller/gstinterpolationcontrolsource.c:
(gst_interpolation_control_source_new):
* libs/gst/controller/gstlfocontrolsource.c:
(gst_lfo_control_source_new):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_event_from_packet_0_2):
* plugins/elements/gstfdsrc.c:
* plugins/elements/gstmultiqueue.c:
* plugins/elements/gsttee.c:
* plugins/elements/gsttypefindelement.c:
* plugins/indexers/gstfileindex.c: (_file_index_id_save_xml),
(gst_file_index_add_association):
* plugins/indexers/gstmemindex.c:
* tests/benchmarks/gstpollstress.c: (mess_some_more):
* tests/check/elements/queue.c: (setup_queue):
* tests/check/gst/gstpipeline.c:
* tests/check/libs/collectpads.c: (setup), (teardown),
(gst_collect_pads_suite):
* tests/examples/adapter/adapter_test.c:
* tests/examples/metadata/read-metadata.c: (make_pipeline):
* tests/examples/xml/createxml.c:
* tests/examples/xml/runxml.c:
* tools/gst-inspect.c:
* tools/gst-run.c:
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers, not using variable sized arrays
on the stack, moving variable declarations to the beginning of
a block and using "foo (void)" instead of "foo ()" for declarations.
2008-02-29 12:41:33 +00:00
|
|
|
static Suite *
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
queue_suite (void)
|
|
|
|
{
|
|
|
|
Suite *s = suite_create ("queue");
|
|
|
|
TCase *tc_chain = tcase_create ("general");
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
2010-08-18 13:12:45 +00:00
|
|
|
tcase_add_checked_fixture (tc_chain, setup, cleanup);
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
tcase_add_test (tc_chain, test_non_leaky_underrun);
|
|
|
|
tcase_add_test (tc_chain, test_non_leaky_overrun);
|
2007-01-04 13:37:08 +00:00
|
|
|
tcase_add_test (tc_chain, test_leaky_upstream);
|
|
|
|
tcase_add_test (tc_chain, test_leaky_downstream);
|
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
|
|
|
tcase_add_test (tc_chain, test_time_level);
|
2010-10-11 08:27:52 +00:00
|
|
|
tcase_add_test (tc_chain, test_time_level_task_not_started);
|
2013-01-29 11:40:52 +00:00
|
|
|
tcase_add_test (tc_chain, test_queries_while_flushing);
|
2018-03-01 21:19:09 +00:00
|
|
|
tcase_add_test (tc_chain, test_serialized_query_with_threshold);
|
2014-08-20 10:55:51 +00:00
|
|
|
tcase_add_test (tc_chain, test_state_change_when_flushing);
|
2011-05-13 16:07:24 +00:00
|
|
|
#if 0
|
2010-08-19 15:07:00 +00:00
|
|
|
tcase_add_test (tc_chain, test_newsegment);
|
2011-05-13 16:07:24 +00:00
|
|
|
#endif
|
2012-10-29 12:08:31 +00:00
|
|
|
tcase_add_test (tc_chain, test_sticky_not_linked);
|
2015-02-17 10:11:43 +00:00
|
|
|
tcase_add_test (tc_chain, test_time_level_buffer_list);
|
2015-04-05 15:06:44 +00:00
|
|
|
tcase_add_test (tc_chain, test_initial_events_nodelay);
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_CHECK_MAIN (queue);
|