2007-10-16 20:30:13 +00:00
|
|
|
/* GStreamer message bus unit tests
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
* Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
|
2007-10-16 20:30:13 +00:00
|
|
|
* Copyright (C) 2007 Tim-Philipp Müller <tim centricular net>
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +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.
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
*/
|
|
|
|
|
2005-08-20 12:14:28 +00:00
|
|
|
#include <gst/check/gstcheck.h>
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
|
|
|
|
static GstBus *test_bus = NULL;
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
static GMainLoop *main_loop;
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
|
2014-03-16 19:29:27 +00:00
|
|
|
static GType foo_device_get_type (void);
|
|
|
|
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
#define NUM_MESSAGES 1000
|
|
|
|
#define NUM_THREADS 10
|
|
|
|
|
|
|
|
static gpointer
|
|
|
|
pound_bus_with_messages (gpointer data)
|
|
|
|
{
|
|
|
|
gint thread_id = GPOINTER_TO_INT (data);
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_MESSAGES; i++) {
|
|
|
|
GstMessage *m;
|
|
|
|
GstStructure *s;
|
|
|
|
|
|
|
|
s = gst_structure_new ("test_message",
|
|
|
|
"thread_id", G_TYPE_INT, thread_id, "msg_id", G_TYPE_INT, i, NULL);
|
2005-07-05 08:47:40 +00:00
|
|
|
m = gst_message_new_application (NULL, s);
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
gst_bus_post (test_bus, m);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-02-29 13:59:24 +00:00
|
|
|
pull_messages (void)
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
{
|
|
|
|
GstMessage *m;
|
|
|
|
const GstStructure *s;
|
|
|
|
guint message_ids[NUM_THREADS];
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_THREADS; i++)
|
|
|
|
message_ids[i] = 0;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
gint _t, _i;
|
|
|
|
|
|
|
|
m = gst_bus_pop (test_bus);
|
|
|
|
if (!m)
|
|
|
|
break;
|
|
|
|
g_return_if_fail (GST_MESSAGE_TYPE (m) == GST_MESSAGE_APPLICATION);
|
|
|
|
|
|
|
|
s = gst_message_get_structure (m);
|
|
|
|
if (!gst_structure_get_int (s, "thread_id", &_t))
|
|
|
|
g_critical ("Invalid message");
|
|
|
|
if (!gst_structure_get_int (s, "msg_id", &_i))
|
|
|
|
g_critical ("Invalid message");
|
|
|
|
|
|
|
|
g_return_if_fail (_t < NUM_THREADS);
|
|
|
|
g_return_if_fail (_i == message_ids[_t]++);
|
|
|
|
|
|
|
|
gst_message_unref (m);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_THREADS; i++)
|
|
|
|
g_return_if_fail (message_ids[i] == NUM_MESSAGES);
|
|
|
|
}
|
|
|
|
|
2005-07-09 16:36:18 +00:00
|
|
|
GST_START_TEST (test_hammer_bus)
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
{
|
|
|
|
GThread *threads[NUM_THREADS];
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
test_bus = gst_bus_new ();
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_THREADS; i++)
|
2012-09-12 09:52:25 +00:00
|
|
|
threads[i] = g_thread_try_new ("gst-check", pound_bus_with_messages,
|
|
|
|
GINT_TO_POINTER (i), NULL);
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
|
|
|
|
for (i = 0; i < NUM_THREADS; i++)
|
|
|
|
g_thread_join (threads[i]);
|
|
|
|
|
|
|
|
pull_messages ();
|
|
|
|
|
|
|
|
gst_object_unref ((GstObject *) test_bus);
|
|
|
|
}
|
2006-01-14 14:12:26 +00:00
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
static gboolean
|
gst/gstbus.c: Make GstBusSource work with non-default main contexts (#562170).
Original commit message from CVS:
* gst/gstbus.c: (gst_bus_dispose), (gst_bus_get_property),
(gst_bus_wakeup_main_context), (gst_bus_set_main_context),
(gst_bus_post), (gst_bus_source_prepare), (gst_bus_source_finalize),
(gst_bus_create_watch):
Make GstBusSource work with non-default main contexts (#562170).
* tests/check/gst/gstbus.c: (message_func_eos), (message_func_app),
(test_watch), (test_watch_with_custom_context), (gst_bus_suite):
Add test case for GstBusSource with a non-default main context.
* tests/check/libs/.cvsignore:
Ignore more.
2008-12-27 17:41:11 +00:00
|
|
|
message_func_eos (GstBus * bus, GstMessage * message, guint * p_counter)
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
{
|
|
|
|
const GstStructure *s;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_EOS, FALSE);
|
|
|
|
|
|
|
|
GST_DEBUG ("got EOS message");
|
|
|
|
|
|
|
|
s = gst_message_get_structure (message);
|
|
|
|
if (!gst_structure_get_int (s, "msg_id", &i))
|
|
|
|
g_critical ("Invalid message");
|
|
|
|
|
gst/gstbus.c: Make GstBusSource work with non-default main contexts (#562170).
Original commit message from CVS:
* gst/gstbus.c: (gst_bus_dispose), (gst_bus_get_property),
(gst_bus_wakeup_main_context), (gst_bus_set_main_context),
(gst_bus_post), (gst_bus_source_prepare), (gst_bus_source_finalize),
(gst_bus_create_watch):
Make GstBusSource work with non-default main contexts (#562170).
* tests/check/gst/gstbus.c: (message_func_eos), (message_func_app),
(test_watch), (test_watch_with_custom_context), (gst_bus_suite):
Add test case for GstBusSource with a non-default main context.
* tests/check/libs/.cvsignore:
Ignore more.
2008-12-27 17:41:11 +00:00
|
|
|
if (p_counter != NULL)
|
|
|
|
*p_counter += 1;
|
|
|
|
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
return i != 9;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
gst/gstbus.c: Make GstBusSource work with non-default main contexts (#562170).
Original commit message from CVS:
* gst/gstbus.c: (gst_bus_dispose), (gst_bus_get_property),
(gst_bus_wakeup_main_context), (gst_bus_set_main_context),
(gst_bus_post), (gst_bus_source_prepare), (gst_bus_source_finalize),
(gst_bus_create_watch):
Make GstBusSource work with non-default main contexts (#562170).
* tests/check/gst/gstbus.c: (message_func_eos), (message_func_app),
(test_watch), (test_watch_with_custom_context), (gst_bus_suite):
Add test case for GstBusSource with a non-default main context.
* tests/check/libs/.cvsignore:
Ignore more.
2008-12-27 17:41:11 +00:00
|
|
|
message_func_app (GstBus * bus, GstMessage * message, guint * p_counter)
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
{
|
|
|
|
const GstStructure *s;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_APPLICATION,
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
GST_DEBUG ("got APP message");
|
|
|
|
|
|
|
|
s = gst_message_get_structure (message);
|
|
|
|
if (!gst_structure_get_int (s, "msg_id", &i))
|
|
|
|
g_critical ("Invalid message");
|
|
|
|
|
gst/gstbus.c: Make GstBusSource work with non-default main contexts (#562170).
Original commit message from CVS:
* gst/gstbus.c: (gst_bus_dispose), (gst_bus_get_property),
(gst_bus_wakeup_main_context), (gst_bus_set_main_context),
(gst_bus_post), (gst_bus_source_prepare), (gst_bus_source_finalize),
(gst_bus_create_watch):
Make GstBusSource work with non-default main contexts (#562170).
* tests/check/gst/gstbus.c: (message_func_eos), (message_func_app),
(test_watch), (test_watch_with_custom_context), (gst_bus_suite):
Add test case for GstBusSource with a non-default main context.
* tests/check/libs/.cvsignore:
Ignore more.
2008-12-27 17:41:11 +00:00
|
|
|
if (p_counter != NULL)
|
|
|
|
*p_counter += 1;
|
|
|
|
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
return i != 9;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
send_messages (gpointer data)
|
|
|
|
{
|
|
|
|
GstMessage *m;
|
|
|
|
GstStructure *s;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
s = gst_structure_new ("test_message", "msg_id", G_TYPE_INT, i, NULL);
|
|
|
|
m = gst_message_new_application (NULL, s);
|
|
|
|
gst_bus_post (test_bus, m);
|
|
|
|
s = gst_structure_new ("test_message", "msg_id", G_TYPE_INT, i, NULL);
|
|
|
|
m = gst_message_new_custom (GST_MESSAGE_EOS, NULL, s);
|
|
|
|
gst_bus_post (test_bus, m);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
/* test if adding a signal watch for different message types calls the
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
* respective callbacks. */
|
|
|
|
GST_START_TEST (test_watch)
|
|
|
|
{
|
gst/gstbus.c: Make GstBusSource work with non-default main contexts (#562170).
Original commit message from CVS:
* gst/gstbus.c: (gst_bus_dispose), (gst_bus_get_property),
(gst_bus_wakeup_main_context), (gst_bus_set_main_context),
(gst_bus_post), (gst_bus_source_prepare), (gst_bus_source_finalize),
(gst_bus_create_watch):
Make GstBusSource work with non-default main contexts (#562170).
* tests/check/gst/gstbus.c: (message_func_eos), (message_func_app),
(test_watch), (test_watch_with_custom_context), (gst_bus_suite):
Add test case for GstBusSource with a non-default main context.
* tests/check/libs/.cvsignore:
Ignore more.
2008-12-27 17:41:11 +00:00
|
|
|
guint num_eos = 0;
|
|
|
|
guint num_app = 0;
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
guint id;
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
|
|
|
|
test_bus = gst_bus_new ();
|
|
|
|
|
|
|
|
main_loop = g_main_loop_new (NULL, FALSE);
|
|
|
|
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
id = gst_bus_add_watch (test_bus, gst_bus_async_signal_func, NULL);
|
2008-10-13 17:19:25 +00:00
|
|
|
fail_if (id == 0);
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
g_signal_connect (test_bus, "message::eos", (GCallback) message_func_eos,
|
gst/gstbus.c: Make GstBusSource work with non-default main contexts (#562170).
Original commit message from CVS:
* gst/gstbus.c: (gst_bus_dispose), (gst_bus_get_property),
(gst_bus_wakeup_main_context), (gst_bus_set_main_context),
(gst_bus_post), (gst_bus_source_prepare), (gst_bus_source_finalize),
(gst_bus_create_watch):
Make GstBusSource work with non-default main contexts (#562170).
* tests/check/gst/gstbus.c: (message_func_eos), (message_func_app),
(test_watch), (test_watch_with_custom_context), (gst_bus_suite):
Add test case for GstBusSource with a non-default main context.
* tests/check/libs/.cvsignore:
Ignore more.
2008-12-27 17:41:11 +00:00
|
|
|
&num_eos);
|
check/gst/gstbin.c: Change for new bus API.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
Change for new bus API.
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
Change for new bus signal API.
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_have_pending),
(gst_bus_source_prepare), (gst_bus_source_check),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (gst_bus_poll), (gst_bus_async_signal_func),
(gst_bus_sync_signal_handler), (gst_bus_add_signal_watch):
* gst/gstbus.h:
Remove support for multiple GSources operating on different
message types as it is too complex and unneeded when using
signals.
Added support for receiving signals from the bus.
2005-09-29 13:07:37 +00:00
|
|
|
g_signal_connect (test_bus, "message::application",
|
gst/gstbus.c: Make GstBusSource work with non-default main contexts (#562170).
Original commit message from CVS:
* gst/gstbus.c: (gst_bus_dispose), (gst_bus_get_property),
(gst_bus_wakeup_main_context), (gst_bus_set_main_context),
(gst_bus_post), (gst_bus_source_prepare), (gst_bus_source_finalize),
(gst_bus_create_watch):
Make GstBusSource work with non-default main contexts (#562170).
* tests/check/gst/gstbus.c: (message_func_eos), (message_func_app),
(test_watch), (test_watch_with_custom_context), (gst_bus_suite):
Add test case for GstBusSource with a non-default main context.
* tests/check/libs/.cvsignore:
Ignore more.
2008-12-27 17:41:11 +00:00
|
|
|
(GCallback) message_func_app, &num_app);
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
|
|
|
|
g_idle_add ((GSourceFunc) send_messages, NULL);
|
|
|
|
while (g_main_context_pending (NULL))
|
|
|
|
g_main_context_iteration (NULL, FALSE);
|
|
|
|
|
gst/gstbus.c: Make GstBusSource work with non-default main contexts (#562170).
Original commit message from CVS:
* gst/gstbus.c: (gst_bus_dispose), (gst_bus_get_property),
(gst_bus_wakeup_main_context), (gst_bus_set_main_context),
(gst_bus_post), (gst_bus_source_prepare), (gst_bus_source_finalize),
(gst_bus_create_watch):
Make GstBusSource work with non-default main contexts (#562170).
* tests/check/gst/gstbus.c: (message_func_eos), (message_func_app),
(test_watch), (test_watch_with_custom_context), (gst_bus_suite):
Add test case for GstBusSource with a non-default main context.
* tests/check/libs/.cvsignore:
Ignore more.
2008-12-27 17:41:11 +00:00
|
|
|
fail_unless_equals_int (num_eos, 10);
|
|
|
|
fail_unless_equals_int (num_app, 10);
|
|
|
|
|
2014-08-19 21:28:52 +00:00
|
|
|
fail_unless (gst_bus_remove_watch (test_bus));
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
g_main_loop_unref (main_loop);
|
|
|
|
|
|
|
|
gst_object_unref ((GstObject *) test_bus);
|
|
|
|
}
|
2005-12-12 10:57:37 +00:00
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
gst/gstbus.c: Make GstBusSource work with non-default main contexts (#562170).
Original commit message from CVS:
* gst/gstbus.c: (gst_bus_dispose), (gst_bus_get_property),
(gst_bus_wakeup_main_context), (gst_bus_set_main_context),
(gst_bus_post), (gst_bus_source_prepare), (gst_bus_source_finalize),
(gst_bus_create_watch):
Make GstBusSource work with non-default main contexts (#562170).
* tests/check/gst/gstbus.c: (message_func_eos), (message_func_app),
(test_watch), (test_watch_with_custom_context), (gst_bus_suite):
Add test case for GstBusSource with a non-default main context.
* tests/check/libs/.cvsignore:
Ignore more.
2008-12-27 17:41:11 +00:00
|
|
|
/* test if adding a signal watch for different message types calls the
|
|
|
|
* respective callbacks. */
|
|
|
|
GST_START_TEST (test_watch_with_custom_context)
|
|
|
|
{
|
|
|
|
GMainContext *ctx;
|
|
|
|
GSource *source;
|
|
|
|
guint num_eos = 0;
|
|
|
|
guint num_app = 0;
|
|
|
|
guint id;
|
|
|
|
|
|
|
|
test_bus = gst_bus_new ();
|
|
|
|
|
|
|
|
ctx = g_main_context_new ();
|
|
|
|
main_loop = g_main_loop_new (ctx, FALSE);
|
|
|
|
|
|
|
|
source = gst_bus_create_watch (test_bus);
|
|
|
|
g_source_set_callback (source, (GSourceFunc) gst_bus_async_signal_func, NULL,
|
|
|
|
NULL);
|
|
|
|
id = g_source_attach (source, ctx);
|
|
|
|
g_source_unref (source);
|
|
|
|
fail_if (id == 0);
|
|
|
|
|
|
|
|
g_signal_connect (test_bus, "message::eos", (GCallback) message_func_eos,
|
|
|
|
&num_eos);
|
|
|
|
g_signal_connect (test_bus, "message::application",
|
|
|
|
(GCallback) message_func_app, &num_app);
|
|
|
|
|
|
|
|
source = g_idle_source_new ();
|
|
|
|
g_source_set_callback (source, (GSourceFunc) send_messages, NULL, NULL);
|
|
|
|
g_source_attach (source, ctx);
|
|
|
|
g_source_unref (source);
|
|
|
|
|
|
|
|
while (g_main_context_pending (ctx))
|
|
|
|
g_main_context_iteration (ctx, FALSE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (num_eos, 10);
|
|
|
|
fail_unless_equals_int (num_app, 10);
|
|
|
|
|
2013-11-18 15:28:32 +00:00
|
|
|
if ((source = g_main_context_find_source_by_id (ctx, id)))
|
|
|
|
g_source_destroy (source);
|
gst/gstbus.c: Make GstBusSource work with non-default main contexts (#562170).
Original commit message from CVS:
* gst/gstbus.c: (gst_bus_dispose), (gst_bus_get_property),
(gst_bus_wakeup_main_context), (gst_bus_set_main_context),
(gst_bus_post), (gst_bus_source_prepare), (gst_bus_source_finalize),
(gst_bus_create_watch):
Make GstBusSource work with non-default main contexts (#562170).
* tests/check/gst/gstbus.c: (message_func_eos), (message_func_app),
(test_watch), (test_watch_with_custom_context), (gst_bus_suite):
Add test case for GstBusSource with a non-default main context.
* tests/check/libs/.cvsignore:
Ignore more.
2008-12-27 17:41:11 +00:00
|
|
|
g_main_loop_unref (main_loop);
|
|
|
|
g_main_context_unref (ctx);
|
|
|
|
|
|
|
|
gst_object_unref (test_bus);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2011-01-31 15:58:18 +00:00
|
|
|
/* test if adding a signal watch for different message types calls the
|
|
|
|
* respective callbacks. */
|
|
|
|
GST_START_TEST (test_add_watch_with_custom_context)
|
|
|
|
{
|
|
|
|
GMainContext *ctx;
|
|
|
|
GSource *source;
|
|
|
|
guint num_eos = 0;
|
|
|
|
guint num_app = 0;
|
|
|
|
|
|
|
|
test_bus = gst_bus_new ();
|
|
|
|
|
|
|
|
ctx = g_main_context_new ();
|
|
|
|
main_loop = g_main_loop_new (ctx, FALSE);
|
|
|
|
|
|
|
|
g_main_context_push_thread_default (ctx);
|
|
|
|
gst_bus_add_signal_watch (test_bus);
|
|
|
|
g_main_context_pop_thread_default (ctx);
|
|
|
|
|
|
|
|
g_signal_connect (test_bus, "message::eos", (GCallback) message_func_eos,
|
|
|
|
&num_eos);
|
|
|
|
g_signal_connect (test_bus, "message::application",
|
|
|
|
(GCallback) message_func_app, &num_app);
|
|
|
|
|
|
|
|
source = g_idle_source_new ();
|
|
|
|
g_source_set_callback (source, (GSourceFunc) send_messages, NULL, NULL);
|
|
|
|
g_source_attach (source, ctx);
|
|
|
|
g_source_unref (source);
|
|
|
|
|
|
|
|
while (g_main_context_pending (ctx))
|
|
|
|
g_main_context_iteration (ctx, FALSE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (num_eos, 10);
|
|
|
|
fail_unless_equals_int (num_app, 10);
|
|
|
|
|
|
|
|
g_main_loop_unref (main_loop);
|
|
|
|
g_main_context_unref (ctx);
|
|
|
|
|
|
|
|
gst_object_unref (test_bus);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2014-10-11 17:28:21 +00:00
|
|
|
static gboolean
|
|
|
|
dummy_bus_func (GstBus * bus, GstMessage * msg, gpointer user_data)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_remove_watch)
|
|
|
|
{
|
|
|
|
test_bus = gst_bus_new ();
|
|
|
|
|
|
|
|
/* removing a non-existing watch should fail */
|
|
|
|
fail_if (gst_bus_remove_watch (test_bus));
|
|
|
|
|
|
|
|
gst_bus_add_watch (test_bus, dummy_bus_func, NULL);
|
|
|
|
|
|
|
|
fail_unless (gst_bus_remove_watch (test_bus));
|
|
|
|
|
|
|
|
/* now it should fail to remove the watch again */
|
|
|
|
fail_if (gst_bus_remove_watch (test_bus));
|
|
|
|
|
|
|
|
gst_object_unref (test_bus);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2007-02-27 17:22:07 +00:00
|
|
|
static gint messages_seen;
|
2005-11-10 18:15:24 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
message_func (GstBus * bus, GstMessage * message, gpointer data)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_APPLICATION);
|
|
|
|
|
|
|
|
messages_seen++;
|
|
|
|
}
|
|
|
|
|
2007-10-16 20:30:13 +00:00
|
|
|
static void
|
2014-03-16 19:29:27 +00:00
|
|
|
send_5app_1el_1err_2app_1eos_messages (guint interval_usecs)
|
2007-10-16 20:30:13 +00:00
|
|
|
{
|
|
|
|
GstMessage *m;
|
|
|
|
GstStructure *s;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < 5; i++) {
|
|
|
|
s = gst_structure_new ("test_message", "msg_id", G_TYPE_INT, i, NULL);
|
|
|
|
m = gst_message_new_application (NULL, s);
|
|
|
|
GST_LOG ("posting application message");
|
|
|
|
gst_bus_post (test_bus, m);
|
|
|
|
g_usleep (interval_usecs);
|
|
|
|
}
|
|
|
|
for (i = 0; i < 1; i++) {
|
|
|
|
s = gst_structure_new ("test_message", "msg_id", G_TYPE_INT, i, NULL);
|
|
|
|
m = gst_message_new_element (NULL, s);
|
|
|
|
GST_LOG ("posting element message");
|
|
|
|
gst_bus_post (test_bus, m);
|
|
|
|
g_usleep (interval_usecs);
|
|
|
|
}
|
|
|
|
for (i = 0; i < 1; i++) {
|
|
|
|
m = gst_message_new_error (NULL, NULL, "debug string");
|
|
|
|
GST_LOG ("posting error message");
|
|
|
|
gst_bus_post (test_bus, m);
|
|
|
|
g_usleep (interval_usecs);
|
|
|
|
}
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
s = gst_structure_new ("test_message", "msg_id", G_TYPE_INT, i, NULL);
|
|
|
|
m = gst_message_new_application (NULL, s);
|
|
|
|
GST_LOG ("posting application message");
|
|
|
|
gst_bus_post (test_bus, m);
|
|
|
|
g_usleep (interval_usecs);
|
|
|
|
}
|
2014-03-16 19:29:27 +00:00
|
|
|
for (i = 0; i < 1; i++) {
|
|
|
|
m = gst_message_new_eos (NULL);
|
|
|
|
GST_LOG ("posting EOS message");
|
|
|
|
gst_bus_post (test_bus, m);
|
|
|
|
g_usleep (interval_usecs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
send_extended_messages (guint interval_usecs)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GstDevice *device;
|
|
|
|
|
|
|
|
device = g_object_new (foo_device_get_type (), NULL);
|
|
|
|
|
|
|
|
msg = gst_message_new_device_added (NULL, device);
|
|
|
|
GST_LOG ("posting device-added message");
|
|
|
|
gst_bus_post (test_bus, msg);
|
|
|
|
g_usleep (interval_usecs);
|
|
|
|
|
|
|
|
msg = gst_message_new_device_removed (NULL, device);
|
|
|
|
GST_LOG ("posting device-removed message");
|
|
|
|
gst_bus_post (test_bus, msg);
|
|
|
|
g_usleep (interval_usecs);
|
|
|
|
|
|
|
|
gst_object_unref (device);
|
2007-10-16 20:30:13 +00:00
|
|
|
}
|
|
|
|
|
2014-03-16 19:29:27 +00:00
|
|
|
|
2005-11-10 18:15:24 +00:00
|
|
|
static void
|
|
|
|
send_10_app_messages (void)
|
|
|
|
{
|
|
|
|
GstMessage *m;
|
|
|
|
GstStructure *s;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
s = gst_structure_new ("test_message", "msg_id", G_TYPE_INT, i, NULL);
|
|
|
|
m = gst_message_new_application (NULL, s);
|
|
|
|
gst_bus_post (test_bus, m);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* test that you get the same messages from a poll as from signal watches. */
|
|
|
|
GST_START_TEST (test_watch_with_poll)
|
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
test_bus = gst_bus_new ();
|
2007-02-27 17:22:07 +00:00
|
|
|
messages_seen = 0;
|
2005-11-10 18:15:24 +00:00
|
|
|
|
|
|
|
gst_bus_add_signal_watch (test_bus);
|
|
|
|
g_signal_connect (test_bus, "message", (GCallback) message_func, NULL);
|
|
|
|
|
|
|
|
send_10_app_messages ();
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
gst_message_unref (gst_bus_poll (test_bus, GST_MESSAGE_APPLICATION,
|
|
|
|
GST_CLOCK_TIME_NONE));
|
|
|
|
|
|
|
|
fail_if (gst_bus_have_pending (test_bus), "unexpected messages on bus");
|
|
|
|
fail_unless (messages_seen == 10, "signal handler didn't get 10 messages");
|
|
|
|
|
|
|
|
gst_bus_remove_signal_watch (test_bus);
|
|
|
|
|
|
|
|
gst_object_unref (test_bus);
|
|
|
|
}
|
2006-07-01 20:56:56 +00:00
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2007-02-27 17:22:07 +00:00
|
|
|
/* test that you get the messages with pop. */
|
|
|
|
GST_START_TEST (test_timed_pop)
|
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
test_bus = gst_bus_new ();
|
|
|
|
|
|
|
|
send_10_app_messages ();
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
gst_message_unref (gst_bus_timed_pop (test_bus, GST_CLOCK_TIME_NONE));
|
|
|
|
|
|
|
|
fail_if (gst_bus_have_pending (test_bus), "unexpected messages on bus");
|
|
|
|
|
|
|
|
gst_object_unref (test_bus);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2014-03-16 14:08:45 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GstDevice device;
|
|
|
|
} FooDevice;
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GstDeviceClass device_klass;
|
|
|
|
} FooDeviceClass;
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (FooDevice, foo_device, GST_TYPE_DEVICE);
|
|
|
|
|
|
|
|
static void
|
|
|
|
foo_device_class_init (FooDeviceClass * klass)
|
|
|
|
{
|
|
|
|
/* nothing to do here */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
foo_device_init (FooDevice * device)
|
|
|
|
{
|
|
|
|
/* nothing to do here */
|
|
|
|
}
|
|
|
|
|
2007-10-16 20:30:13 +00:00
|
|
|
/* test that you get the messages with pop_filtered */
|
|
|
|
GST_START_TEST (test_timed_pop_filtered)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
test_bus = gst_bus_new ();
|
|
|
|
|
|
|
|
send_10_app_messages ();
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
msg = gst_bus_timed_pop_filtered (test_bus, GST_CLOCK_TIME_NONE,
|
|
|
|
GST_MESSAGE_ANY);
|
|
|
|
fail_unless (msg != NULL);
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* should flush all messages on the bus with types not matching */
|
|
|
|
send_10_app_messages ();
|
|
|
|
msg = gst_bus_timed_pop_filtered (test_bus, 0,
|
|
|
|
GST_MESSAGE_ANY ^ GST_MESSAGE_APPLICATION);
|
|
|
|
fail_unless (msg == NULL);
|
|
|
|
msg = gst_bus_timed_pop_filtered (test_bus, GST_SECOND / 2,
|
|
|
|
GST_MESSAGE_ANY ^ GST_MESSAGE_APPLICATION);
|
|
|
|
fail_unless (msg == NULL);
|
|
|
|
/* there should be nothing on the bus now */
|
|
|
|
fail_if (gst_bus_have_pending (test_bus), "unexpected messages on bus");
|
|
|
|
msg = gst_bus_timed_pop_filtered (test_bus, 0, GST_MESSAGE_ANY);
|
|
|
|
fail_unless (msg == NULL);
|
|
|
|
|
2014-03-16 19:29:27 +00:00
|
|
|
send_5app_1el_1err_2app_1eos_messages (0);
|
2007-10-16 20:30:13 +00:00
|
|
|
msg = gst_bus_timed_pop_filtered (test_bus, 0,
|
|
|
|
GST_MESSAGE_ANY ^ GST_MESSAGE_APPLICATION);
|
|
|
|
fail_unless (msg != NULL);
|
|
|
|
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
|
|
|
|
gst_message_unref (msg);
|
|
|
|
fail_unless (gst_bus_have_pending (test_bus), "expected messages on bus");
|
|
|
|
msg = gst_bus_timed_pop_filtered (test_bus, 0, GST_MESSAGE_APPLICATION);
|
|
|
|
fail_unless (msg != NULL);
|
|
|
|
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_APPLICATION);
|
|
|
|
gst_message_unref (msg);
|
|
|
|
msg = gst_bus_timed_pop_filtered (test_bus, 0, GST_MESSAGE_ERROR);
|
|
|
|
fail_unless (msg == NULL);
|
|
|
|
|
2014-03-16 19:29:27 +00:00
|
|
|
gst_object_unref (test_bus);
|
2014-03-16 14:08:45 +00:00
|
|
|
|
2014-03-16 19:29:27 +00:00
|
|
|
/* Test extended messages */
|
|
|
|
GST_DEBUG
|
|
|
|
("Checking extended messages received from gst_bus_timed_pop_filtered");
|
|
|
|
test_bus = gst_bus_new ();
|
2014-03-16 14:08:45 +00:00
|
|
|
|
2014-03-16 19:29:27 +00:00
|
|
|
send_5app_1el_1err_2app_1eos_messages (0);
|
|
|
|
send_extended_messages (0);
|
|
|
|
send_5app_1el_1err_2app_1eos_messages (0);
|
2014-03-16 14:08:45 +00:00
|
|
|
msg = gst_bus_timed_pop_filtered (test_bus, 0, GST_MESSAGE_EXTENDED);
|
|
|
|
fail_unless (msg != NULL);
|
|
|
|
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_DEVICE_ADDED);
|
|
|
|
gst_message_unref (msg);
|
|
|
|
|
2014-03-16 19:29:27 +00:00
|
|
|
msg = gst_bus_timed_pop_filtered (test_bus, 0, GST_MESSAGE_EXTENDED);
|
|
|
|
fail_unless (msg != NULL);
|
|
|
|
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_DEVICE_REMOVED);
|
|
|
|
gst_message_unref (msg);
|
|
|
|
gst_object_unref (test_bus);
|
|
|
|
|
|
|
|
/* Now check extended messages don't appear when we don't ask for them */
|
|
|
|
GST_DEBUG
|
|
|
|
("Checking extended messages *not* received from gst_bus_timed_pop_filtered when not wanted");
|
|
|
|
test_bus = gst_bus_new ();
|
|
|
|
|
|
|
|
send_extended_messages (0);
|
|
|
|
send_5app_1el_1err_2app_1eos_messages (0);
|
|
|
|
|
|
|
|
msg = gst_bus_timed_pop_filtered (test_bus, 0, GST_MESSAGE_ERROR);
|
|
|
|
fail_unless (msg != NULL);
|
|
|
|
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ERROR);
|
|
|
|
gst_message_unref (msg);
|
|
|
|
|
|
|
|
msg = gst_bus_timed_pop_filtered (test_bus, 0, GST_MESSAGE_EOS);
|
|
|
|
fail_unless (msg != NULL);
|
|
|
|
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_EOS);
|
|
|
|
gst_message_unref (msg);
|
|
|
|
|
2007-10-16 20:30:13 +00:00
|
|
|
gst_object_unref (test_bus);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
static gpointer
|
|
|
|
post_delayed_thread (gpointer data)
|
|
|
|
{
|
|
|
|
THREAD_START ();
|
2014-03-16 19:29:27 +00:00
|
|
|
send_5app_1el_1err_2app_1eos_messages (1 * G_USEC_PER_SEC);
|
2007-10-16 20:30:13 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* test that you get the messages with pop_filtered if there's a timeout*/
|
|
|
|
GST_START_TEST (test_timed_pop_filtered_with_timeout)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
|
|
|
|
MAIN_INIT ();
|
|
|
|
|
|
|
|
test_bus = gst_bus_new ();
|
|
|
|
|
|
|
|
MAIN_START_THREAD_FUNCTIONS (1, post_delayed_thread, NULL);
|
|
|
|
|
|
|
|
MAIN_SYNCHRONIZE ();
|
|
|
|
|
|
|
|
msg = gst_bus_timed_pop_filtered (test_bus, 2 * GST_SECOND,
|
|
|
|
GST_MESSAGE_ERROR);
|
|
|
|
fail_unless (msg == NULL, "Got unexpected %s message",
|
|
|
|
(msg) ? GST_MESSAGE_TYPE_NAME (msg) : "");
|
|
|
|
msg = gst_bus_timed_pop_filtered (test_bus, (3 + 1 + 1 + 1) * GST_SECOND,
|
|
|
|
GST_MESSAGE_ERROR | GST_MESSAGE_ELEMENT);
|
|
|
|
fail_unless (msg != NULL, "expected element message, but got nothing");
|
|
|
|
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
|
|
|
|
gst_message_unref (msg);
|
|
|
|
msg = gst_bus_timed_pop_filtered (test_bus, GST_CLOCK_TIME_NONE,
|
|
|
|
GST_MESSAGE_APPLICATION);
|
|
|
|
fail_unless (msg != NULL, "expected application message, but got nothing");
|
|
|
|
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_APPLICATION);
|
|
|
|
gst_message_unref (msg);
|
|
|
|
msg = gst_bus_timed_pop_filtered (test_bus, GST_CLOCK_TIME_NONE,
|
|
|
|
GST_MESSAGE_APPLICATION);
|
|
|
|
fail_unless (msg != NULL, "expected application message, but got nothing");
|
|
|
|
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_APPLICATION);
|
|
|
|
gst_message_unref (msg);
|
|
|
|
msg = gst_bus_timed_pop_filtered (test_bus, GST_SECOND / 4,
|
|
|
|
GST_MESSAGE_TAG | GST_MESSAGE_ERROR);
|
|
|
|
fail_unless (msg == NULL, "Got unexpected %s message",
|
|
|
|
(msg) ? GST_MESSAGE_TYPE_NAME (msg) : "");
|
|
|
|
|
|
|
|
MAIN_STOP_THREADS ();
|
|
|
|
|
|
|
|
gst_object_unref (test_bus);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2007-02-27 17:22:07 +00:00
|
|
|
/* test that you get the messages with pop from another thread. */
|
|
|
|
static gpointer
|
|
|
|
pop_thread (gpointer data)
|
|
|
|
{
|
|
|
|
GstBus *bus = GST_BUS_CAST (data);
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
gst_message_unref (gst_bus_timed_pop (bus, GST_CLOCK_TIME_NONE));
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_timed_pop_thread)
|
|
|
|
{
|
|
|
|
GThread *thread;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
test_bus = gst_bus_new ();
|
|
|
|
|
2012-09-12 09:52:25 +00:00
|
|
|
thread = g_thread_try_new ("gst-chek", pop_thread, test_bus, &error);
|
2007-02-27 17:22:07 +00:00
|
|
|
fail_if (error != NULL);
|
|
|
|
|
|
|
|
send_10_app_messages ();
|
|
|
|
|
|
|
|
g_thread_join (thread);
|
|
|
|
|
|
|
|
fail_if (gst_bus_have_pending (test_bus), "unexpected messages on bus");
|
|
|
|
|
|
|
|
/* try to pop a message without timeout. */
|
|
|
|
fail_if (gst_bus_timed_pop (test_bus, 0) != NULL);
|
|
|
|
|
|
|
|
/* with a small timeout */
|
|
|
|
fail_if (gst_bus_timed_pop (test_bus, 1000) != NULL);
|
|
|
|
|
|
|
|
gst_object_unref (test_bus);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2009-01-17 21:04:41 +00:00
|
|
|
static gboolean
|
|
|
|
cb_bus_call (GstBus * bus, GstMessage * msg, gpointer data)
|
|
|
|
{
|
|
|
|
GMainLoop *loop = data;
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
{
|
|
|
|
GST_INFO ("End-of-stream");
|
|
|
|
g_main_loop_quit (loop);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
{
|
|
|
|
GError *err = NULL;
|
|
|
|
|
|
|
|
gst_message_parse_error (msg, &err, NULL);
|
|
|
|
g_error ("Error: %s", err->message);
|
|
|
|
g_error_free (err);
|
|
|
|
|
|
|
|
g_main_loop_quit (loop);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
GST_LOG ("BUS MESSAGE: type=%s", GST_MESSAGE_TYPE_NAME (msg));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_custom_main_context)
|
|
|
|
{
|
|
|
|
GMainContext *ctx;
|
|
|
|
GMainLoop *loop;
|
|
|
|
GstElement *pipeline;
|
|
|
|
GstElement *src;
|
|
|
|
GstElement *sink;
|
|
|
|
GSource *source;
|
|
|
|
GstBus *bus;
|
|
|
|
|
|
|
|
ctx = g_main_context_new ();
|
|
|
|
loop = g_main_loop_new (ctx, FALSE);
|
|
|
|
|
|
|
|
pipeline = gst_pipeline_new (NULL);
|
|
|
|
src = gst_element_factory_make ("fakesrc", NULL);
|
|
|
|
g_object_set (src, "num-buffers", 2000, NULL);
|
|
|
|
|
|
|
|
sink = gst_element_factory_make ("fakesink", NULL);
|
|
|
|
|
|
|
|
fail_unless (gst_bin_add (GST_BIN (pipeline), src));
|
|
|
|
fail_unless (gst_bin_add (GST_BIN (pipeline), sink));
|
|
|
|
fail_unless (gst_element_link (src, sink));
|
|
|
|
|
|
|
|
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
|
|
|
|
source = gst_bus_create_watch (bus);
|
|
|
|
g_source_attach (source, ctx);
|
|
|
|
g_source_set_callback (source, (GSourceFunc) cb_bus_call, loop, NULL);
|
2011-02-16 16:14:46 +00:00
|
|
|
g_source_unref (source);
|
2009-01-17 21:04:41 +00:00
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
GST_INFO ("starting pipeline");
|
|
|
|
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
|
|
gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
|
|
|
|
|
|
|
|
GST_INFO ("running event loop, ctx=%p", ctx);
|
|
|
|
g_main_loop_run (loop);
|
|
|
|
|
2009-08-10 10:42:25 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
|
2009-01-17 21:04:41 +00:00
|
|
|
/* clean up */
|
|
|
|
if (ctx)
|
|
|
|
g_main_context_unref (ctx);
|
|
|
|
g_main_loop_unref (loop);
|
2009-08-11 03:47:21 +00:00
|
|
|
gst_object_unref (pipeline);
|
2009-01-17 21:04:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2008-02-29 13:59:24 +00:00
|
|
|
static Suite *
|
2006-07-01 20:56:56 +00:00
|
|
|
gst_bus_suite (void)
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
{
|
|
|
|
Suite *s = suite_create ("GstBus");
|
|
|
|
TCase *tc_chain = tcase_create ("stresstest");
|
|
|
|
|
2012-02-27 10:46:08 +00:00
|
|
|
tcase_set_timeout (tc_chain, 60);
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
|
|
|
tcase_add_test (tc_chain, test_hammer_bus);
|
GstBusHandler -> GstBusFunc, return value has the same meaning as any other GSource (FALSE == remove source).
Original commit message from CVS:
* check/gst/gstbin.c: (pop_messages), (GST_START_TEST):
* check/gst/gstbus.c: (message_func_eos), (message_func_app),
(send_messages), (GST_START_TEST), (gstbus_suite):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (run_pipeline):
* check/pipelines/simple_launch_lines.c: (run_pipeline),
(GST_START_TEST):
* gst/gstbus.c: (gst_bus_have_pending), (gst_bus_source_prepare),
(gst_bus_source_check), (gst_bus_source_dispatch),
(gst_bus_create_watch), (gst_bus_add_watch_full),
(gst_bus_add_watch), (poll_func), (poll_timeout), (gst_bus_poll):
* gst/gstbus.h:
* tools/gst-launch.c: (event_loop):
* tools/gst-md5sum.c: (event_loop):
GstBusHandler -> GstBusFunc, return value has the same meaning as
any other GSource (FALSE == remove source).
_add_watch() and _add_watch_full() now take a MessageType mask to
only handle specific types of messages.
_poll() returns the GstMessage instead of the message type to avoid
race conditions.
_have_pending() takes a MessageType mask now too.
Added testsuite for multiple bus watches.
Fix testsuites and applications for new bus API.
2005-09-19 11:18:03 +00:00
|
|
|
tcase_add_test (tc_chain, test_watch);
|
2005-11-10 18:15:24 +00:00
|
|
|
tcase_add_test (tc_chain, test_watch_with_poll);
|
gst/gstbus.c: Make GstBusSource work with non-default main contexts (#562170).
Original commit message from CVS:
* gst/gstbus.c: (gst_bus_dispose), (gst_bus_get_property),
(gst_bus_wakeup_main_context), (gst_bus_set_main_context),
(gst_bus_post), (gst_bus_source_prepare), (gst_bus_source_finalize),
(gst_bus_create_watch):
Make GstBusSource work with non-default main contexts (#562170).
* tests/check/gst/gstbus.c: (message_func_eos), (message_func_app),
(test_watch), (test_watch_with_custom_context), (gst_bus_suite):
Add test case for GstBusSource with a non-default main context.
* tests/check/libs/.cvsignore:
Ignore more.
2008-12-27 17:41:11 +00:00
|
|
|
tcase_add_test (tc_chain, test_watch_with_custom_context);
|
2011-01-31 15:58:18 +00:00
|
|
|
tcase_add_test (tc_chain, test_add_watch_with_custom_context);
|
2014-10-11 17:28:21 +00:00
|
|
|
tcase_add_test (tc_chain, test_remove_watch);
|
2007-02-27 17:22:07 +00:00
|
|
|
tcase_add_test (tc_chain, test_timed_pop);
|
|
|
|
tcase_add_test (tc_chain, test_timed_pop_thread);
|
2007-10-16 20:30:13 +00:00
|
|
|
tcase_add_test (tc_chain, test_timed_pop_filtered);
|
|
|
|
tcase_add_test (tc_chain, test_timed_pop_filtered_with_timeout);
|
2009-01-17 21:04:41 +00:00
|
|
|
tcase_add_test (tc_chain, test_custom_main_context);
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2006-07-01 20:56:56 +00:00
|
|
|
GST_CHECK_MAIN (gst_bus);
|