2014-10-21 08:35:48 +00:00
|
|
|
/* Gnonlin
|
|
|
|
* Copyright (C) <2001> Wim Taymans <wim.taymans@gmail.com>
|
|
|
|
* <2004-2008> Edward Hervey <bilboed@bilboed.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
#include "nle.h"
|
2014-10-21 08:35:48 +00:00
|
|
|
|
|
|
|
/**
|
2014-08-15 13:48:14 +00:00
|
|
|
* SECTION:element-nlesource
|
2014-10-21 08:35:48 +00:00
|
|
|
*
|
2014-08-15 13:48:14 +00:00
|
|
|
* The NleSource encapsulates a pipeline which produces data for processing
|
|
|
|
* in a #NleComposition.
|
2014-10-21 08:35:48 +00:00
|
|
|
*/
|
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
static GstStaticPadTemplate nle_source_src_template =
|
2014-10-21 08:35:48 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
2014-06-24 11:44:13 +00:00
|
|
|
GST_PAD_ALWAYS,
|
2014-10-21 08:35:48 +00:00
|
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
|
2020-05-02 02:56:38 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_REVERSE,
|
|
|
|
PROP_LAST,
|
|
|
|
};
|
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (nlesource);
|
|
|
|
#define GST_CAT_DEFAULT nlesource
|
2014-10-21 08:35:48 +00:00
|
|
|
|
|
|
|
#define _do_init \
|
2014-08-15 13:48:14 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (nlesource, "nlesource", GST_DEBUG_FG_BLUE | GST_DEBUG_BOLD, "GNonLin Source Element");
|
|
|
|
#define nle_source_parent_class parent_class
|
2020-05-02 02:56:38 +00:00
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
struct _NleSourcePrivate
|
2014-10-21 08:35:48 +00:00
|
|
|
{
|
|
|
|
gboolean dispose_has_run;
|
|
|
|
|
|
|
|
gboolean dynamicpads; /* TRUE if the controlled element has dynamic pads */
|
|
|
|
|
|
|
|
gulong padremovedid; /* signal handler for element pad-removed signal */
|
|
|
|
gulong padaddedid; /* signal handler for element pad-added signal */
|
|
|
|
|
|
|
|
gboolean pendingblock; /* We have a pending pad_block */
|
2014-08-25 16:11:52 +00:00
|
|
|
gboolean areblocked; /* We already got blocked */
|
2014-10-21 08:35:48 +00:00
|
|
|
GstPad *ghostedpad; /* Pad (to be) ghosted */
|
|
|
|
GstPad *staticpad; /* The only pad. We keep an extra ref */
|
2014-08-25 16:11:52 +00:00
|
|
|
|
nlesource: Protect seeks from tear down
Otherwise there is a race where we trigger the seek at the exact
same time the composition is being teared down potentially leading
to basesrc restarting its srcpad task which ends up being leaked.
Fixes ges.playback.scrub_backward_seeking.test_title.audio_video.vorbis_theora_ogg
and probably all its friends timeouting with the following stack trace:
(gdb) t a a bt
Thread 4 (Thread 0x7f5962acd700 (LWP 19997)):
#0 0x00007f5976713efd in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f5976a9d3f3 in g_cond_wait (cond=cond@entry=0x7f5938125410, mutex=mutex@entry=0x7f59381253c8) at gthread-posix.c:1402
#2 0x00007f5976c9e26b in gst_task_func (task=0x7f59381253b0 [GstTask]) at ../subprojects/gstreamer/gst/gsttask.c:313
#3 0x00007f5976a7ecb3 in g_thread_pool_thread_proxy (data=<optimized out>) at gthreadpool.c:307
#4 0x00007f5976a7e2aa in g_thread_proxy (data=0x7f5954071d40) at gthread.c:784
#5 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#6 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 3 (Thread 0x7f5963fff700 (LWP 19995)):
#0 0x00007f597670e421 in __GI___poll (fds=0xe32da0, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f5976a553a6 in g_main_context_poll (priority=<optimized out>, n_fds=2, fds=0xe32da0, timeout=<optimized out>, context=0xe31ff0) at gmain.c:4221
#2 0x00007f5976a553a6 in g_main_context_iterate (context=0xe31ff0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3915
#3 0x00007f5976a55762 in g_main_loop_run (loop=0xe32130) at gmain.c:4116
#4 0x00007f59768db10a in gdbus_shared_thread_func (user_data=0xe31fc0) at gdbusprivate.c:275
#5 0x00007f5976a7e2aa in g_thread_proxy (data=0xe1b8a0) at gthread.c:784
#6 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#7 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 2 (Thread 0x7f5968dcc700 (LWP 19994)):
#0 0x00007f597670e421 in __GI___poll (fds=0xe1bcc0, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f5976a553a6 in g_main_context_poll (priority=<optimized out>, n_fds=1, fds=0xe1bcc0, timeout=<optimized out>, context=0xe1b350) at gmain.c:4221
#2 0x00007f5976a553a6 in g_main_context_iterate (context=context@entry=0xe1b350, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3915
#3 0x00007f5976a554d0 in g_main_context_iteration (context=0xe1b350, may_block=may_block@entry=1) at gmain.c:3981
#4 0x00007f5976a55521 in glib_worker_main (data=<optimized out>) at gmain.c:5861
#5 0x00007f5976a7e2aa in g_thread_proxy (data=0xe1b800) at gthread.c:784
#6 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#7 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 1 (Thread 0x7f5975df4fc0 (LWP 19993)):
#0 0x00007f5976713efd in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f5976a9d3f3 in g_cond_wait (cond=cond@entry=0xe34020, mutex=0xe39b80) at gthread-posix.c:1402
#2 0x00007f5976a7f41c in g_thread_pool_free (pool=0xe34000, immediate=0, wait_=<optimized out>) at gthreadpool.c:776
#3 0x00007f5976c9f1ca in default_cleanup (pool=0xe256b0 [GstTaskPool]) at ../subprojects/gstreamer/gst/gsttaskpool.c:89
#4 0x00007f5976c9e32d in init_klass_pool (klass=<optimized out>) at ../subprojects/gstreamer/gst/gsttask.c:161
#5 0x00007f5976c9e502 in gst_task_cleanup_all () at ../subprojects/gstreamer/gst/gsttask.c:381
#6 0x00007f5976c214f4 in gst_deinit () at ../subprojects/gstreamer/gst/gst.c:1095
#7 0x000000000040394f in main (argc=6, argv=<optimized out>) at ../subprojects/gst-editing-services/tools/ges-launch.c:94
2019-03-15 20:07:06 +00:00
|
|
|
GMutex seek_lock;
|
2014-08-25 16:11:52 +00:00
|
|
|
GstEvent *seek_event;
|
2019-06-23 03:49:50 +00:00
|
|
|
guint32 flush_seqnum;
|
2014-08-25 16:11:52 +00:00
|
|
|
gulong probeid;
|
2020-05-02 02:56:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Identity automatically created to handle reverse playback */
|
|
|
|
GstElement *identity;
|
2014-10-21 08:35:48 +00:00
|
|
|
};
|
|
|
|
|
2018-09-06 01:55:02 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (NleSource, nle_source, NLE_TYPE_OBJECT,
|
|
|
|
G_ADD_PRIVATE (NleSource)
|
|
|
|
_do_init);
|
|
|
|
|
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
static gboolean nle_source_prepare (NleObject * object);
|
2014-08-25 16:11:52 +00:00
|
|
|
static gboolean nle_source_send_event (GstElement * element, GstEvent * event);
|
2014-08-15 13:48:14 +00:00
|
|
|
static gboolean nle_source_add_element (GstBin * bin, GstElement * element);
|
|
|
|
static gboolean nle_source_remove_element (GstBin * bin, GstElement * element);
|
|
|
|
static void nle_source_dispose (GObject * object);
|
2014-10-21 08:35:48 +00:00
|
|
|
|
|
|
|
static gboolean
|
2014-08-15 13:48:14 +00:00
|
|
|
nle_source_control_element_func (NleSource * source, GstElement * element);
|
nlesource: Protect seeks from tear down
Otherwise there is a race where we trigger the seek at the exact
same time the composition is being teared down potentially leading
to basesrc restarting its srcpad task which ends up being leaked.
Fixes ges.playback.scrub_backward_seeking.test_title.audio_video.vorbis_theora_ogg
and probably all its friends timeouting with the following stack trace:
(gdb) t a a bt
Thread 4 (Thread 0x7f5962acd700 (LWP 19997)):
#0 0x00007f5976713efd in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f5976a9d3f3 in g_cond_wait (cond=cond@entry=0x7f5938125410, mutex=mutex@entry=0x7f59381253c8) at gthread-posix.c:1402
#2 0x00007f5976c9e26b in gst_task_func (task=0x7f59381253b0 [GstTask]) at ../subprojects/gstreamer/gst/gsttask.c:313
#3 0x00007f5976a7ecb3 in g_thread_pool_thread_proxy (data=<optimized out>) at gthreadpool.c:307
#4 0x00007f5976a7e2aa in g_thread_proxy (data=0x7f5954071d40) at gthread.c:784
#5 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#6 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 3 (Thread 0x7f5963fff700 (LWP 19995)):
#0 0x00007f597670e421 in __GI___poll (fds=0xe32da0, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f5976a553a6 in g_main_context_poll (priority=<optimized out>, n_fds=2, fds=0xe32da0, timeout=<optimized out>, context=0xe31ff0) at gmain.c:4221
#2 0x00007f5976a553a6 in g_main_context_iterate (context=0xe31ff0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3915
#3 0x00007f5976a55762 in g_main_loop_run (loop=0xe32130) at gmain.c:4116
#4 0x00007f59768db10a in gdbus_shared_thread_func (user_data=0xe31fc0) at gdbusprivate.c:275
#5 0x00007f5976a7e2aa in g_thread_proxy (data=0xe1b8a0) at gthread.c:784
#6 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#7 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 2 (Thread 0x7f5968dcc700 (LWP 19994)):
#0 0x00007f597670e421 in __GI___poll (fds=0xe1bcc0, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f5976a553a6 in g_main_context_poll (priority=<optimized out>, n_fds=1, fds=0xe1bcc0, timeout=<optimized out>, context=0xe1b350) at gmain.c:4221
#2 0x00007f5976a553a6 in g_main_context_iterate (context=context@entry=0xe1b350, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3915
#3 0x00007f5976a554d0 in g_main_context_iteration (context=0xe1b350, may_block=may_block@entry=1) at gmain.c:3981
#4 0x00007f5976a55521 in glib_worker_main (data=<optimized out>) at gmain.c:5861
#5 0x00007f5976a7e2aa in g_thread_proxy (data=0xe1b800) at gthread.c:784
#6 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#7 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 1 (Thread 0x7f5975df4fc0 (LWP 19993)):
#0 0x00007f5976713efd in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f5976a9d3f3 in g_cond_wait (cond=cond@entry=0xe34020, mutex=0xe39b80) at gthread-posix.c:1402
#2 0x00007f5976a7f41c in g_thread_pool_free (pool=0xe34000, immediate=0, wait_=<optimized out>) at gthreadpool.c:776
#3 0x00007f5976c9f1ca in default_cleanup (pool=0xe256b0 [GstTaskPool]) at ../subprojects/gstreamer/gst/gsttaskpool.c:89
#4 0x00007f5976c9e32d in init_klass_pool (klass=<optimized out>) at ../subprojects/gstreamer/gst/gsttask.c:161
#5 0x00007f5976c9e502 in gst_task_cleanup_all () at ../subprojects/gstreamer/gst/gsttask.c:381
#6 0x00007f5976c214f4 in gst_deinit () at ../subprojects/gstreamer/gst/gst.c:1095
#7 0x000000000040394f in main (argc=6, argv=<optimized out>) at ../subprojects/gst-editing-services/tools/ges-launch.c:94
2019-03-15 20:07:06 +00:00
|
|
|
static GstStateChangeReturn nle_source_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
2014-10-21 08:35:48 +00:00
|
|
|
|
2020-05-02 02:56:38 +00:00
|
|
|
static gboolean
|
|
|
|
nle_source_commit (NleObject * object, gboolean recurse)
|
|
|
|
{
|
|
|
|
NleSource *self = NLE_SOURCE (object);
|
|
|
|
|
|
|
|
if (!NLE_OBJECT_CLASS (parent_class)->commit (object, recurse))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
self->reverse = self->pending_reverse;
|
|
|
|
g_object_set (self->priv->identity, "single-segment", self->reverse, NULL);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nle_source_get_property (GObject * object, guint property_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
NleSource *self = NLE_SOURCE (object);
|
|
|
|
|
|
|
|
GST_OBJECT_LOCK (self);
|
|
|
|
switch (property_id) {
|
|
|
|
case PROP_REVERSE:
|
|
|
|
g_value_set_boolean (value, self->pending_reverse);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
}
|
|
|
|
GST_OBJECT_UNLOCK (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nle_source_set_property (GObject * object, guint property_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
NleSource *self = NLE_SOURCE (object);
|
|
|
|
|
|
|
|
GST_OBJECT_LOCK (self);
|
|
|
|
switch (property_id) {
|
|
|
|
case PROP_REVERSE:
|
|
|
|
self->pending_reverse = g_value_get_boolean (value);
|
|
|
|
if (self->pending_reverse != self->reverse)
|
|
|
|
nle_object_set_commit_needed ((NleObject *) self);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
}
|
|
|
|
GST_OBJECT_UNLOCK (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-21 08:35:48 +00:00
|
|
|
static void
|
2014-08-15 13:48:14 +00:00
|
|
|
nle_source_class_init (NleSourceClass * klass)
|
2014-10-21 08:35:48 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
GstBinClass *gstbin_class;
|
2014-08-15 13:48:14 +00:00
|
|
|
NleObjectClass *nleobject_class;
|
2014-10-21 08:35:48 +00:00
|
|
|
|
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
|
|
|
gstbin_class = (GstBinClass *) klass;
|
2014-08-15 13:48:14 +00:00
|
|
|
nleobject_class = (NleObjectClass *) klass;
|
2014-10-21 08:35:48 +00:00
|
|
|
|
2020-05-02 02:56:38 +00:00
|
|
|
gobject_class->get_property = nle_source_get_property;
|
|
|
|
gobject_class->set_property = nle_source_set_property;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* NleSource:reverse:
|
|
|
|
* @reverse: Whether to playback the source reverse or not
|
|
|
|
*
|
|
|
|
* Since: 1.26
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class, PROP_REVERSE,
|
|
|
|
g_param_spec_boolean ("reverse", "Reverse",
|
|
|
|
"Whether to playback the source reverse or not", FALSE,
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
2014-10-21 08:35:48 +00:00
|
|
|
gst_element_class_set_static_metadata (gstelement_class, "GNonLin Source",
|
|
|
|
"Filter/Editor",
|
|
|
|
"Manages source elements",
|
|
|
|
"Wim Taymans <wim.taymans@gmail.com>, Edward Hervey <bilboed@bilboed.com>");
|
|
|
|
|
2014-08-25 16:11:52 +00:00
|
|
|
gstelement_class->send_event = GST_DEBUG_FUNCPTR (nle_source_send_event);
|
nlesource: Protect seeks from tear down
Otherwise there is a race where we trigger the seek at the exact
same time the composition is being teared down potentially leading
to basesrc restarting its srcpad task which ends up being leaked.
Fixes ges.playback.scrub_backward_seeking.test_title.audio_video.vorbis_theora_ogg
and probably all its friends timeouting with the following stack trace:
(gdb) t a a bt
Thread 4 (Thread 0x7f5962acd700 (LWP 19997)):
#0 0x00007f5976713efd in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f5976a9d3f3 in g_cond_wait (cond=cond@entry=0x7f5938125410, mutex=mutex@entry=0x7f59381253c8) at gthread-posix.c:1402
#2 0x00007f5976c9e26b in gst_task_func (task=0x7f59381253b0 [GstTask]) at ../subprojects/gstreamer/gst/gsttask.c:313
#3 0x00007f5976a7ecb3 in g_thread_pool_thread_proxy (data=<optimized out>) at gthreadpool.c:307
#4 0x00007f5976a7e2aa in g_thread_proxy (data=0x7f5954071d40) at gthread.c:784
#5 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#6 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 3 (Thread 0x7f5963fff700 (LWP 19995)):
#0 0x00007f597670e421 in __GI___poll (fds=0xe32da0, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f5976a553a6 in g_main_context_poll (priority=<optimized out>, n_fds=2, fds=0xe32da0, timeout=<optimized out>, context=0xe31ff0) at gmain.c:4221
#2 0x00007f5976a553a6 in g_main_context_iterate (context=0xe31ff0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3915
#3 0x00007f5976a55762 in g_main_loop_run (loop=0xe32130) at gmain.c:4116
#4 0x00007f59768db10a in gdbus_shared_thread_func (user_data=0xe31fc0) at gdbusprivate.c:275
#5 0x00007f5976a7e2aa in g_thread_proxy (data=0xe1b8a0) at gthread.c:784
#6 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#7 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 2 (Thread 0x7f5968dcc700 (LWP 19994)):
#0 0x00007f597670e421 in __GI___poll (fds=0xe1bcc0, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f5976a553a6 in g_main_context_poll (priority=<optimized out>, n_fds=1, fds=0xe1bcc0, timeout=<optimized out>, context=0xe1b350) at gmain.c:4221
#2 0x00007f5976a553a6 in g_main_context_iterate (context=context@entry=0xe1b350, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3915
#3 0x00007f5976a554d0 in g_main_context_iteration (context=0xe1b350, may_block=may_block@entry=1) at gmain.c:3981
#4 0x00007f5976a55521 in glib_worker_main (data=<optimized out>) at gmain.c:5861
#5 0x00007f5976a7e2aa in g_thread_proxy (data=0xe1b800) at gthread.c:784
#6 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#7 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 1 (Thread 0x7f5975df4fc0 (LWP 19993)):
#0 0x00007f5976713efd in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f5976a9d3f3 in g_cond_wait (cond=cond@entry=0xe34020, mutex=0xe39b80) at gthread-posix.c:1402
#2 0x00007f5976a7f41c in g_thread_pool_free (pool=0xe34000, immediate=0, wait_=<optimized out>) at gthreadpool.c:776
#3 0x00007f5976c9f1ca in default_cleanup (pool=0xe256b0 [GstTaskPool]) at ../subprojects/gstreamer/gst/gsttaskpool.c:89
#4 0x00007f5976c9e32d in init_klass_pool (klass=<optimized out>) at ../subprojects/gstreamer/gst/gsttask.c:161
#5 0x00007f5976c9e502 in gst_task_cleanup_all () at ../subprojects/gstreamer/gst/gsttask.c:381
#6 0x00007f5976c214f4 in gst_deinit () at ../subprojects/gstreamer/gst/gst.c:1095
#7 0x000000000040394f in main (argc=6, argv=<optimized out>) at ../subprojects/gst-editing-services/tools/ges-launch.c:94
2019-03-15 20:07:06 +00:00
|
|
|
gstelement_class->change_state = GST_DEBUG_FUNCPTR (nle_source_change_state);
|
2014-08-25 16:11:52 +00:00
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
parent_class = g_type_class_ref (NLE_TYPE_OBJECT);
|
2014-10-21 08:35:48 +00:00
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
klass->control_element = GST_DEBUG_FUNCPTR (nle_source_control_element_func);
|
2014-10-21 08:35:48 +00:00
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
nleobject_class->prepare = GST_DEBUG_FUNCPTR (nle_source_prepare);
|
2020-05-02 02:56:38 +00:00
|
|
|
nleobject_class->commit = GST_DEBUG_FUNCPTR (nle_source_commit);
|
2014-10-21 08:35:48 +00:00
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
gstbin_class->add_element = GST_DEBUG_FUNCPTR (nle_source_add_element);
|
|
|
|
gstbin_class->remove_element = GST_DEBUG_FUNCPTR (nle_source_remove_element);
|
2014-10-21 08:35:48 +00:00
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
gobject_class->dispose = GST_DEBUG_FUNCPTR (nle_source_dispose);
|
2014-10-21 08:35:48 +00:00
|
|
|
|
2016-03-06 23:49:14 +00:00
|
|
|
gst_element_class_add_static_pad_template (gstelement_class,
|
|
|
|
&nle_source_src_template);
|
2014-10-21 08:35:48 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-06-23 03:49:50 +00:00
|
|
|
static GstPadProbeReturn
|
|
|
|
srcpad_probe_cb (GstPad * pad, GstPadProbeInfo * info, NleSource * source)
|
|
|
|
{
|
|
|
|
GstEvent *event = info->data;
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_SEEK:
|
|
|
|
GST_OBJECT_LOCK (source);
|
|
|
|
source->priv->flush_seqnum = GST_EVENT_SEQNUM (event);
|
|
|
|
GST_DEBUG_OBJECT (pad, "Seek seqnum: %d", source->priv->flush_seqnum);
|
|
|
|
GST_OBJECT_UNLOCK (source);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GST_PAD_PROBE_OK;
|
|
|
|
}
|
2014-10-21 08:35:48 +00:00
|
|
|
|
|
|
|
static void
|
2014-08-15 13:48:14 +00:00
|
|
|
nle_source_init (NleSource * source)
|
2014-10-21 08:35:48 +00:00
|
|
|
{
|
2020-05-02 02:56:38 +00:00
|
|
|
NleSourcePrivate *priv;
|
|
|
|
NleObject *nleobject = NLE_OBJECT (source);
|
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
GST_OBJECT_FLAG_SET (source, NLE_OBJECT_SOURCE);
|
2014-10-21 08:35:48 +00:00
|
|
|
source->element = NULL;
|
2020-05-02 02:56:38 +00:00
|
|
|
priv = source->priv = nle_source_get_instance_private (source);
|
|
|
|
priv->identity = gst_element_factory_make ("identity", NULL);
|
|
|
|
|
|
|
|
gst_bin_add (GST_BIN (source), priv->identity);
|
|
|
|
nle_object_ghost_pad_set_target (nleobject, nleobject->srcpad,
|
|
|
|
priv->identity->srcpads->data);
|
|
|
|
|
|
|
|
g_mutex_init (&priv->seek_lock);
|
2014-10-21 08:35:48 +00:00
|
|
|
|
2019-06-23 03:49:50 +00:00
|
|
|
gst_pad_add_probe (NLE_OBJECT_SRC (source),
|
|
|
|
GST_PAD_PROBE_TYPE_EVENT_UPSTREAM, (GstPadProbeCallback) srcpad_probe_cb,
|
|
|
|
source, NULL);
|
|
|
|
|
2014-10-21 08:35:48 +00:00
|
|
|
GST_DEBUG_OBJECT (source, "Setting GstBin async-handling to TRUE");
|
|
|
|
g_object_set (G_OBJECT (source), "async-handling", TRUE, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-08-15 13:48:14 +00:00
|
|
|
nle_source_dispose (GObject * object)
|
2014-10-21 08:35:48 +00:00
|
|
|
{
|
2014-08-15 13:48:14 +00:00
|
|
|
NleObject *nleobject = (NleObject *) object;
|
|
|
|
NleSource *source = (NleSource *) object;
|
|
|
|
NleSourcePrivate *priv = source->priv;
|
2020-05-02 02:56:38 +00:00
|
|
|
GstElement *tmpidentity;
|
|
|
|
|
2014-10-21 08:35:48 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (object, "dispose");
|
|
|
|
|
|
|
|
if (priv->dispose_has_run)
|
|
|
|
return;
|
|
|
|
|
2014-09-19 10:29:28 +00:00
|
|
|
GST_OBJECT_LOCK (object);
|
|
|
|
if (priv->probeid) {
|
|
|
|
GST_DEBUG_OBJECT (source, "Removing blocking probe! %lu", priv->probeid);
|
|
|
|
priv->areblocked = FALSE;
|
|
|
|
gst_pad_remove_probe (priv->ghostedpad, priv->probeid);
|
|
|
|
priv->probeid = 0;
|
|
|
|
}
|
|
|
|
GST_OBJECT_UNLOCK (object);
|
|
|
|
|
2020-05-02 02:56:38 +00:00
|
|
|
gst_clear_object (&source->element);
|
|
|
|
tmpidentity = priv->identity;
|
|
|
|
priv->identity = NULL;
|
|
|
|
gst_bin_remove (GST_BIN (source), tmpidentity);
|
2014-10-21 08:35:48 +00:00
|
|
|
|
|
|
|
priv->dispose_has_run = TRUE;
|
2020-05-02 02:56:38 +00:00
|
|
|
nle_object_ghost_pad_set_target (nleobject, nleobject->srcpad, NULL);
|
2014-10-21 08:35:48 +00:00
|
|
|
|
2020-05-02 02:56:38 +00:00
|
|
|
gst_clear_object (&priv->staticpad);
|
2014-10-21 08:35:48 +00:00
|
|
|
|
nlesource: Protect seeks from tear down
Otherwise there is a race where we trigger the seek at the exact
same time the composition is being teared down potentially leading
to basesrc restarting its srcpad task which ends up being leaked.
Fixes ges.playback.scrub_backward_seeking.test_title.audio_video.vorbis_theora_ogg
and probably all its friends timeouting with the following stack trace:
(gdb) t a a bt
Thread 4 (Thread 0x7f5962acd700 (LWP 19997)):
#0 0x00007f5976713efd in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f5976a9d3f3 in g_cond_wait (cond=cond@entry=0x7f5938125410, mutex=mutex@entry=0x7f59381253c8) at gthread-posix.c:1402
#2 0x00007f5976c9e26b in gst_task_func (task=0x7f59381253b0 [GstTask]) at ../subprojects/gstreamer/gst/gsttask.c:313
#3 0x00007f5976a7ecb3 in g_thread_pool_thread_proxy (data=<optimized out>) at gthreadpool.c:307
#4 0x00007f5976a7e2aa in g_thread_proxy (data=0x7f5954071d40) at gthread.c:784
#5 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#6 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 3 (Thread 0x7f5963fff700 (LWP 19995)):
#0 0x00007f597670e421 in __GI___poll (fds=0xe32da0, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f5976a553a6 in g_main_context_poll (priority=<optimized out>, n_fds=2, fds=0xe32da0, timeout=<optimized out>, context=0xe31ff0) at gmain.c:4221
#2 0x00007f5976a553a6 in g_main_context_iterate (context=0xe31ff0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3915
#3 0x00007f5976a55762 in g_main_loop_run (loop=0xe32130) at gmain.c:4116
#4 0x00007f59768db10a in gdbus_shared_thread_func (user_data=0xe31fc0) at gdbusprivate.c:275
#5 0x00007f5976a7e2aa in g_thread_proxy (data=0xe1b8a0) at gthread.c:784
#6 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#7 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 2 (Thread 0x7f5968dcc700 (LWP 19994)):
#0 0x00007f597670e421 in __GI___poll (fds=0xe1bcc0, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f5976a553a6 in g_main_context_poll (priority=<optimized out>, n_fds=1, fds=0xe1bcc0, timeout=<optimized out>, context=0xe1b350) at gmain.c:4221
#2 0x00007f5976a553a6 in g_main_context_iterate (context=context@entry=0xe1b350, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3915
#3 0x00007f5976a554d0 in g_main_context_iteration (context=0xe1b350, may_block=may_block@entry=1) at gmain.c:3981
#4 0x00007f5976a55521 in glib_worker_main (data=<optimized out>) at gmain.c:5861
#5 0x00007f5976a7e2aa in g_thread_proxy (data=0xe1b800) at gthread.c:784
#6 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#7 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 1 (Thread 0x7f5975df4fc0 (LWP 19993)):
#0 0x00007f5976713efd in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f5976a9d3f3 in g_cond_wait (cond=cond@entry=0xe34020, mutex=0xe39b80) at gthread-posix.c:1402
#2 0x00007f5976a7f41c in g_thread_pool_free (pool=0xe34000, immediate=0, wait_=<optimized out>) at gthreadpool.c:776
#3 0x00007f5976c9f1ca in default_cleanup (pool=0xe256b0 [GstTaskPool]) at ../subprojects/gstreamer/gst/gsttaskpool.c:89
#4 0x00007f5976c9e32d in init_klass_pool (klass=<optimized out>) at ../subprojects/gstreamer/gst/gsttask.c:161
#5 0x00007f5976c9e502 in gst_task_cleanup_all () at ../subprojects/gstreamer/gst/gsttask.c:381
#6 0x00007f5976c214f4 in gst_deinit () at ../subprojects/gstreamer/gst/gst.c:1095
#7 0x000000000040394f in main (argc=6, argv=<optimized out>) at ../subprojects/gst-editing-services/tools/ges-launch.c:94
2019-03-15 20:07:06 +00:00
|
|
|
g_mutex_lock (&priv->seek_lock);
|
2020-05-02 02:56:38 +00:00
|
|
|
gst_clear_event (&priv->seek_event);
|
nlesource: Protect seeks from tear down
Otherwise there is a race where we trigger the seek at the exact
same time the composition is being teared down potentially leading
to basesrc restarting its srcpad task which ends up being leaked.
Fixes ges.playback.scrub_backward_seeking.test_title.audio_video.vorbis_theora_ogg
and probably all its friends timeouting with the following stack trace:
(gdb) t a a bt
Thread 4 (Thread 0x7f5962acd700 (LWP 19997)):
#0 0x00007f5976713efd in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f5976a9d3f3 in g_cond_wait (cond=cond@entry=0x7f5938125410, mutex=mutex@entry=0x7f59381253c8) at gthread-posix.c:1402
#2 0x00007f5976c9e26b in gst_task_func (task=0x7f59381253b0 [GstTask]) at ../subprojects/gstreamer/gst/gsttask.c:313
#3 0x00007f5976a7ecb3 in g_thread_pool_thread_proxy (data=<optimized out>) at gthreadpool.c:307
#4 0x00007f5976a7e2aa in g_thread_proxy (data=0x7f5954071d40) at gthread.c:784
#5 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#6 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 3 (Thread 0x7f5963fff700 (LWP 19995)):
#0 0x00007f597670e421 in __GI___poll (fds=0xe32da0, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f5976a553a6 in g_main_context_poll (priority=<optimized out>, n_fds=2, fds=0xe32da0, timeout=<optimized out>, context=0xe31ff0) at gmain.c:4221
#2 0x00007f5976a553a6 in g_main_context_iterate (context=0xe31ff0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3915
#3 0x00007f5976a55762 in g_main_loop_run (loop=0xe32130) at gmain.c:4116
#4 0x00007f59768db10a in gdbus_shared_thread_func (user_data=0xe31fc0) at gdbusprivate.c:275
#5 0x00007f5976a7e2aa in g_thread_proxy (data=0xe1b8a0) at gthread.c:784
#6 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#7 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 2 (Thread 0x7f5968dcc700 (LWP 19994)):
#0 0x00007f597670e421 in __GI___poll (fds=0xe1bcc0, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f5976a553a6 in g_main_context_poll (priority=<optimized out>, n_fds=1, fds=0xe1bcc0, timeout=<optimized out>, context=0xe1b350) at gmain.c:4221
#2 0x00007f5976a553a6 in g_main_context_iterate (context=context@entry=0xe1b350, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3915
#3 0x00007f5976a554d0 in g_main_context_iteration (context=0xe1b350, may_block=may_block@entry=1) at gmain.c:3981
#4 0x00007f5976a55521 in glib_worker_main (data=<optimized out>) at gmain.c:5861
#5 0x00007f5976a7e2aa in g_thread_proxy (data=0xe1b800) at gthread.c:784
#6 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#7 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 1 (Thread 0x7f5975df4fc0 (LWP 19993)):
#0 0x00007f5976713efd in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f5976a9d3f3 in g_cond_wait (cond=cond@entry=0xe34020, mutex=0xe39b80) at gthread-posix.c:1402
#2 0x00007f5976a7f41c in g_thread_pool_free (pool=0xe34000, immediate=0, wait_=<optimized out>) at gthreadpool.c:776
#3 0x00007f5976c9f1ca in default_cleanup (pool=0xe256b0 [GstTaskPool]) at ../subprojects/gstreamer/gst/gsttaskpool.c:89
#4 0x00007f5976c9e32d in init_klass_pool (klass=<optimized out>) at ../subprojects/gstreamer/gst/gsttask.c:161
#5 0x00007f5976c9e502 in gst_task_cleanup_all () at ../subprojects/gstreamer/gst/gsttask.c:381
#6 0x00007f5976c214f4 in gst_deinit () at ../subprojects/gstreamer/gst/gst.c:1095
#7 0x000000000040394f in main (argc=6, argv=<optimized out>) at ../subprojects/gst-editing-services/tools/ges-launch.c:94
2019-03-15 20:07:06 +00:00
|
|
|
g_mutex_unlock (&priv->seek_lock);
|
2019-02-05 08:29:00 +00:00
|
|
|
|
2014-10-21 08:35:48 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
element_pad_added_cb (GstElement * element G_GNUC_UNUSED, GstPad * pad,
|
2014-08-15 13:48:14 +00:00
|
|
|
NleSource * source)
|
2014-10-21 08:35:48 +00:00
|
|
|
{
|
|
|
|
GstCaps *srccaps;
|
2014-08-15 13:48:14 +00:00
|
|
|
NleSourcePrivate *priv = source->priv;
|
|
|
|
NleObject *nleobject = (NleObject *) source;
|
2014-10-21 08:35:48 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (source, "pad %s:%s", GST_DEBUG_PAD_NAME (pad));
|
|
|
|
|
2014-07-15 12:59:54 +00:00
|
|
|
if (priv->ghostedpad) {
|
|
|
|
GST_DEBUG_OBJECT (source,
|
|
|
|
"We already have a target, not doing anything with %s:%s",
|
|
|
|
GST_DEBUG_PAD_NAME (pad));
|
|
|
|
|
2014-10-21 08:35:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: pass filter caps to query_caps directly */
|
|
|
|
srccaps = gst_pad_query_caps (pad, NULL);
|
2014-08-15 13:48:14 +00:00
|
|
|
if (nleobject->caps && !gst_caps_can_intersect (srccaps, nleobject->caps)) {
|
2014-10-21 08:35:48 +00:00
|
|
|
gst_caps_unref (srccaps);
|
|
|
|
GST_DEBUG_OBJECT (source, "Pad doesn't have valid caps, ignoring");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gst_caps_unref (srccaps);
|
|
|
|
|
2020-05-02 02:56:38 +00:00
|
|
|
if (gst_pad_link (pad, priv->identity->sinkpads->data) != GST_PAD_LINK_OK) {
|
|
|
|
GST_ERROR_OBJECT (source, "Could not link pads: %" GST_PTR_FORMAT
|
|
|
|
" and %" GST_PTR_FORMAT, pad, priv->identity->sinkpads->data);
|
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (source, "Linked pads: %" GST_PTR_FORMAT
|
|
|
|
" and %" GST_PTR_FORMAT, pad, priv->identity->sinkpads->data);
|
|
|
|
priv->ghostedpad = pad;
|
|
|
|
}
|
2014-10-21 08:35:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
element_pad_removed_cb (GstElement * element G_GNUC_UNUSED, GstPad * pad,
|
2014-08-15 13:48:14 +00:00
|
|
|
NleSource * source)
|
2014-10-21 08:35:48 +00:00
|
|
|
{
|
2014-08-15 13:48:14 +00:00
|
|
|
NleSourcePrivate *priv = source->priv;
|
2014-10-21 08:35:48 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (source, "pad %s:%s (controlled pad %s:%s)",
|
|
|
|
GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (priv->ghostedpad));
|
|
|
|
|
|
|
|
if (pad == priv->ghostedpad) {
|
|
|
|
GST_DEBUG_OBJECT (source,
|
|
|
|
"The removed pad is the controlled pad, clearing up");
|
|
|
|
|
2014-06-24 11:44:13 +00:00
|
|
|
GST_DEBUG_OBJECT (source, "Clearing up ghostpad");
|
2014-10-21 08:35:48 +00:00
|
|
|
|
2020-05-02 02:56:38 +00:00
|
|
|
if (priv->identity && !gst_pad_unlink (pad, priv->identity->sinkpads->data))
|
|
|
|
GST_ERROR_OBJECT (source, "Could not unlink pads: %" GST_PTR_FORMAT
|
|
|
|
" and %" GST_PTR_FORMAT, pad, priv->identity->sinkpads->data);
|
2014-10-21 08:35:48 +00:00
|
|
|
priv->ghostedpad = NULL;
|
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (source, "The removed pad is NOT our controlled pad");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
compare_src_pad (GValue * item, GstCaps * caps)
|
|
|
|
{
|
|
|
|
gint ret = 1;
|
|
|
|
GstPad *pad = g_value_get_object (item);
|
|
|
|
GstCaps *padcaps;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (pad, "Trying pad for caps %" GST_PTR_FORMAT, caps);
|
|
|
|
|
|
|
|
/* FIXME: can pass the filter caps right away.. */
|
|
|
|
padcaps = gst_pad_query_caps (pad, NULL);
|
|
|
|
|
|
|
|
if (gst_caps_can_intersect (padcaps, caps))
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
gst_caps_unref (padcaps);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
get_valid_src_pad
|
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
Returns True if there's a src pad compatible with the NleObject caps in the
|
2014-10-21 08:35:48 +00:00
|
|
|
given element. Fills in pad if so. The returned pad has an incremented refcount
|
|
|
|
*/
|
|
|
|
|
|
|
|
static gboolean
|
2014-08-15 13:48:14 +00:00
|
|
|
get_valid_src_pad (NleSource * source, GstElement * element, GstPad ** pad)
|
2014-10-21 08:35:48 +00:00
|
|
|
{
|
|
|
|
gboolean res = FALSE;
|
|
|
|
GstIterator *srcpads;
|
|
|
|
GValue item = { 0, };
|
|
|
|
|
|
|
|
g_return_val_if_fail (pad, FALSE);
|
|
|
|
|
|
|
|
srcpads = gst_element_iterate_src_pads (element);
|
|
|
|
if (gst_iterator_find_custom (srcpads, (GCompareFunc) compare_src_pad, &item,
|
2014-08-15 13:48:14 +00:00
|
|
|
NLE_OBJECT (source)->caps)) {
|
2014-10-21 08:35:48 +00:00
|
|
|
*pad = g_value_get_object (&item);
|
|
|
|
gst_object_ref (*pad);
|
|
|
|
g_value_reset (&item);
|
|
|
|
res = TRUE;
|
|
|
|
}
|
|
|
|
gst_iterator_free (srcpads);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* has_dynamic_pads
|
|
|
|
* Returns TRUE if the element has only dynamic pads.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
has_dynamic_srcpads (GstElement * element)
|
|
|
|
{
|
|
|
|
gboolean ret = TRUE;
|
|
|
|
GList *templates;
|
|
|
|
GstPadTemplate *template;
|
|
|
|
|
|
|
|
templates =
|
|
|
|
gst_element_class_get_pad_template_list (GST_ELEMENT_GET_CLASS (element));
|
|
|
|
|
|
|
|
while (templates) {
|
|
|
|
template = (GstPadTemplate *) templates->data;
|
|
|
|
|
|
|
|
if ((GST_PAD_TEMPLATE_DIRECTION (template) == GST_PAD_SRC)
|
|
|
|
&& (GST_PAD_TEMPLATE_PRESENCE (template) == GST_PAD_ALWAYS)) {
|
|
|
|
ret = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
templates = templates->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2014-08-15 13:48:14 +00:00
|
|
|
nle_source_control_element_func (NleSource * source, GstElement * element)
|
2014-10-21 08:35:48 +00:00
|
|
|
{
|
2014-08-15 13:48:14 +00:00
|
|
|
NleSourcePrivate *priv = source->priv;
|
2014-10-21 08:35:48 +00:00
|
|
|
GstPad *pad = NULL;
|
|
|
|
|
2020-05-02 02:56:38 +00:00
|
|
|
if (element == priv->identity)
|
|
|
|
return TRUE;
|
|
|
|
|
2014-10-21 08:35:48 +00:00
|
|
|
g_return_val_if_fail (source->element == NULL, FALSE);
|
|
|
|
|
2020-07-03 21:59:49 +00:00
|
|
|
GST_DEBUG_OBJECT (source, "element: %" GST_PTR_FORMAT ", source->element:%"
|
|
|
|
GST_PTR_FORMAT, element, source->element);
|
2014-10-21 08:35:48 +00:00
|
|
|
|
|
|
|
source->element = element;
|
|
|
|
gst_object_ref (element);
|
|
|
|
|
|
|
|
if (get_valid_src_pad (source, source->element, &pad)) {
|
|
|
|
priv->staticpad = pad;
|
2020-05-02 02:56:38 +00:00
|
|
|
if (gst_pad_link (pad, priv->identity->sinkpads->data) != GST_PAD_LINK_OK) {
|
|
|
|
GST_ERROR_OBJECT (source, "Could not link pads: %" GST_PTR_FORMAT
|
|
|
|
" and %" GST_PTR_FORMAT, pad, priv->identity->sinkpads->data);
|
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (source, "Linked pads: %" GST_PTR_FORMAT
|
|
|
|
" and %" GST_PTR_FORMAT, pad, priv->identity->sinkpads->data);
|
|
|
|
}
|
2014-10-21 08:35:48 +00:00
|
|
|
priv->dynamicpads = FALSE;
|
|
|
|
} else {
|
|
|
|
priv->dynamicpads = has_dynamic_srcpads (element);
|
|
|
|
GST_DEBUG_OBJECT (source, "No valid source pad yet, dynamicpads:%d",
|
|
|
|
priv->dynamicpads);
|
|
|
|
if (priv->dynamicpads) {
|
|
|
|
/* connect to pad-added/removed signals */
|
|
|
|
priv->padremovedid = g_signal_connect
|
|
|
|
(G_OBJECT (element), "pad-removed",
|
|
|
|
G_CALLBACK (element_pad_removed_cb), source);
|
|
|
|
priv->padaddedid =
|
|
|
|
g_signal_connect (G_OBJECT (element), "pad-added",
|
|
|
|
G_CALLBACK (element_pad_added_cb), source);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2014-08-15 13:48:14 +00:00
|
|
|
nle_source_add_element (GstBin * bin, GstElement * element)
|
2014-10-21 08:35:48 +00:00
|
|
|
{
|
2014-08-15 13:48:14 +00:00
|
|
|
NleSource *source = (NleSource *) bin;
|
2014-10-21 08:35:48 +00:00
|
|
|
gboolean pret;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (source, "Adding element %s", GST_ELEMENT_NAME (element));
|
|
|
|
|
2014-06-24 10:52:24 +00:00
|
|
|
if (source->element) {
|
2014-08-15 13:48:14 +00:00
|
|
|
GST_WARNING_OBJECT (bin, "NleSource can only handle one element at a time");
|
2014-10-21 08:35:48 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* call parent add_element */
|
|
|
|
pret = GST_BIN_CLASS (parent_class)->add_element (bin, element);
|
|
|
|
|
2014-06-24 10:52:24 +00:00
|
|
|
if (pret) {
|
2014-08-15 13:48:14 +00:00
|
|
|
nle_source_control_element_func (source, element);
|
2014-10-21 08:35:48 +00:00
|
|
|
}
|
|
|
|
return pret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2014-08-15 13:48:14 +00:00
|
|
|
nle_source_remove_element (GstBin * bin, GstElement * element)
|
2014-10-21 08:35:48 +00:00
|
|
|
{
|
2014-08-15 13:48:14 +00:00
|
|
|
NleSource *source = (NleSource *) bin;
|
|
|
|
NleObject *nleobject = (NleObject *) element;
|
|
|
|
NleSourcePrivate *priv = source->priv;
|
2014-10-21 08:35:48 +00:00
|
|
|
gboolean pret;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (source, "Removing element %s", GST_ELEMENT_NAME (element));
|
|
|
|
|
|
|
|
/* try to remove it */
|
|
|
|
pret = GST_BIN_CLASS (parent_class)->remove_element (bin, element);
|
|
|
|
|
|
|
|
if ((!source->element) || (source->element != element)) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pret) {
|
2014-08-15 13:48:14 +00:00
|
|
|
nle_object_ghost_pad_set_target (NLE_OBJECT (source), nleobject->srcpad,
|
2014-06-24 11:44:13 +00:00
|
|
|
NULL);
|
2014-10-21 08:35:48 +00:00
|
|
|
|
|
|
|
/* remove signal handlers */
|
|
|
|
if (priv->padremovedid) {
|
|
|
|
g_signal_handler_disconnect (source->element, priv->padremovedid);
|
|
|
|
priv->padremovedid = 0;
|
|
|
|
}
|
|
|
|
if (priv->padaddedid) {
|
|
|
|
g_signal_handler_disconnect (source->element, priv->padaddedid);
|
|
|
|
priv->padaddedid = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->dynamicpads = FALSE;
|
|
|
|
gst_object_unref (element);
|
|
|
|
source->element = NULL;
|
|
|
|
}
|
|
|
|
return pret;
|
|
|
|
}
|
|
|
|
|
2014-08-25 16:11:52 +00:00
|
|
|
static gboolean
|
|
|
|
nle_source_send_event (GstElement * element, GstEvent * event)
|
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
|
|
|
NleSource *source = (NleSource *) element;
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_SEEK:
|
nlesource: Protect seeks from tear down
Otherwise there is a race where we trigger the seek at the exact
same time the composition is being teared down potentially leading
to basesrc restarting its srcpad task which ends up being leaked.
Fixes ges.playback.scrub_backward_seeking.test_title.audio_video.vorbis_theora_ogg
and probably all its friends timeouting with the following stack trace:
(gdb) t a a bt
Thread 4 (Thread 0x7f5962acd700 (LWP 19997)):
#0 0x00007f5976713efd in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f5976a9d3f3 in g_cond_wait (cond=cond@entry=0x7f5938125410, mutex=mutex@entry=0x7f59381253c8) at gthread-posix.c:1402
#2 0x00007f5976c9e26b in gst_task_func (task=0x7f59381253b0 [GstTask]) at ../subprojects/gstreamer/gst/gsttask.c:313
#3 0x00007f5976a7ecb3 in g_thread_pool_thread_proxy (data=<optimized out>) at gthreadpool.c:307
#4 0x00007f5976a7e2aa in g_thread_proxy (data=0x7f5954071d40) at gthread.c:784
#5 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#6 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 3 (Thread 0x7f5963fff700 (LWP 19995)):
#0 0x00007f597670e421 in __GI___poll (fds=0xe32da0, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f5976a553a6 in g_main_context_poll (priority=<optimized out>, n_fds=2, fds=0xe32da0, timeout=<optimized out>, context=0xe31ff0) at gmain.c:4221
#2 0x00007f5976a553a6 in g_main_context_iterate (context=0xe31ff0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3915
#3 0x00007f5976a55762 in g_main_loop_run (loop=0xe32130) at gmain.c:4116
#4 0x00007f59768db10a in gdbus_shared_thread_func (user_data=0xe31fc0) at gdbusprivate.c:275
#5 0x00007f5976a7e2aa in g_thread_proxy (data=0xe1b8a0) at gthread.c:784
#6 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#7 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 2 (Thread 0x7f5968dcc700 (LWP 19994)):
#0 0x00007f597670e421 in __GI___poll (fds=0xe1bcc0, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f5976a553a6 in g_main_context_poll (priority=<optimized out>, n_fds=1, fds=0xe1bcc0, timeout=<optimized out>, context=0xe1b350) at gmain.c:4221
#2 0x00007f5976a553a6 in g_main_context_iterate (context=context@entry=0xe1b350, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3915
#3 0x00007f5976a554d0 in g_main_context_iteration (context=0xe1b350, may_block=may_block@entry=1) at gmain.c:3981
#4 0x00007f5976a55521 in glib_worker_main (data=<optimized out>) at gmain.c:5861
#5 0x00007f5976a7e2aa in g_thread_proxy (data=0xe1b800) at gthread.c:784
#6 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#7 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 1 (Thread 0x7f5975df4fc0 (LWP 19993)):
#0 0x00007f5976713efd in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f5976a9d3f3 in g_cond_wait (cond=cond@entry=0xe34020, mutex=0xe39b80) at gthread-posix.c:1402
#2 0x00007f5976a7f41c in g_thread_pool_free (pool=0xe34000, immediate=0, wait_=<optimized out>) at gthreadpool.c:776
#3 0x00007f5976c9f1ca in default_cleanup (pool=0xe256b0 [GstTaskPool]) at ../subprojects/gstreamer/gst/gsttaskpool.c:89
#4 0x00007f5976c9e32d in init_klass_pool (klass=<optimized out>) at ../subprojects/gstreamer/gst/gsttask.c:161
#5 0x00007f5976c9e502 in gst_task_cleanup_all () at ../subprojects/gstreamer/gst/gsttask.c:381
#6 0x00007f5976c214f4 in gst_deinit () at ../subprojects/gstreamer/gst/gst.c:1095
#7 0x000000000040394f in main (argc=6, argv=<optimized out>) at ../subprojects/gst-editing-services/tools/ges-launch.c:94
2019-03-15 20:07:06 +00:00
|
|
|
g_mutex_lock (&source->priv->seek_lock);
|
2020-02-06 15:39:12 +00:00
|
|
|
gst_event_replace (&source->priv->seek_event, event);
|
nlesource: Protect seeks from tear down
Otherwise there is a race where we trigger the seek at the exact
same time the composition is being teared down potentially leading
to basesrc restarting its srcpad task which ends up being leaked.
Fixes ges.playback.scrub_backward_seeking.test_title.audio_video.vorbis_theora_ogg
and probably all its friends timeouting with the following stack trace:
(gdb) t a a bt
Thread 4 (Thread 0x7f5962acd700 (LWP 19997)):
#0 0x00007f5976713efd in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f5976a9d3f3 in g_cond_wait (cond=cond@entry=0x7f5938125410, mutex=mutex@entry=0x7f59381253c8) at gthread-posix.c:1402
#2 0x00007f5976c9e26b in gst_task_func (task=0x7f59381253b0 [GstTask]) at ../subprojects/gstreamer/gst/gsttask.c:313
#3 0x00007f5976a7ecb3 in g_thread_pool_thread_proxy (data=<optimized out>) at gthreadpool.c:307
#4 0x00007f5976a7e2aa in g_thread_proxy (data=0x7f5954071d40) at gthread.c:784
#5 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#6 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 3 (Thread 0x7f5963fff700 (LWP 19995)):
#0 0x00007f597670e421 in __GI___poll (fds=0xe32da0, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f5976a553a6 in g_main_context_poll (priority=<optimized out>, n_fds=2, fds=0xe32da0, timeout=<optimized out>, context=0xe31ff0) at gmain.c:4221
#2 0x00007f5976a553a6 in g_main_context_iterate (context=0xe31ff0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3915
#3 0x00007f5976a55762 in g_main_loop_run (loop=0xe32130) at gmain.c:4116
#4 0x00007f59768db10a in gdbus_shared_thread_func (user_data=0xe31fc0) at gdbusprivate.c:275
#5 0x00007f5976a7e2aa in g_thread_proxy (data=0xe1b8a0) at gthread.c:784
#6 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#7 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 2 (Thread 0x7f5968dcc700 (LWP 19994)):
#0 0x00007f597670e421 in __GI___poll (fds=0xe1bcc0, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f5976a553a6 in g_main_context_poll (priority=<optimized out>, n_fds=1, fds=0xe1bcc0, timeout=<optimized out>, context=0xe1b350) at gmain.c:4221
#2 0x00007f5976a553a6 in g_main_context_iterate (context=context@entry=0xe1b350, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3915
#3 0x00007f5976a554d0 in g_main_context_iteration (context=0xe1b350, may_block=may_block@entry=1) at gmain.c:3981
#4 0x00007f5976a55521 in glib_worker_main (data=<optimized out>) at gmain.c:5861
#5 0x00007f5976a7e2aa in g_thread_proxy (data=0xe1b800) at gthread.c:784
#6 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#7 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 1 (Thread 0x7f5975df4fc0 (LWP 19993)):
#0 0x00007f5976713efd in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f5976a9d3f3 in g_cond_wait (cond=cond@entry=0xe34020, mutex=0xe39b80) at gthread-posix.c:1402
#2 0x00007f5976a7f41c in g_thread_pool_free (pool=0xe34000, immediate=0, wait_=<optimized out>) at gthreadpool.c:776
#3 0x00007f5976c9f1ca in default_cleanup (pool=0xe256b0 [GstTaskPool]) at ../subprojects/gstreamer/gst/gsttaskpool.c:89
#4 0x00007f5976c9e32d in init_klass_pool (klass=<optimized out>) at ../subprojects/gstreamer/gst/gsttask.c:161
#5 0x00007f5976c9e502 in gst_task_cleanup_all () at ../subprojects/gstreamer/gst/gsttask.c:381
#6 0x00007f5976c214f4 in gst_deinit () at ../subprojects/gstreamer/gst/gst.c:1095
#7 0x000000000040394f in main (argc=6, argv=<optimized out>) at ../subprojects/gst-editing-services/tools/ges-launch.c:94
2019-03-15 20:07:06 +00:00
|
|
|
g_mutex_unlock (&source->priv->seek_lock);
|
2014-08-25 16:11:52 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = GST_ELEMENT_CLASS (parent_class)->send_event (element, event);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2019-03-15 21:31:30 +00:00
|
|
|
static void
|
|
|
|
ghost_seek_pad (GstElement * source, gpointer user_data)
|
2014-08-25 16:11:52 +00:00
|
|
|
{
|
2019-03-15 21:31:30 +00:00
|
|
|
NleSourcePrivate *priv = NLE_SOURCE (source)->priv;
|
2014-08-25 16:11:52 +00:00
|
|
|
|
2020-02-06 15:39:12 +00:00
|
|
|
g_assert (!NLE_OBJECT (source)->in_composition);
|
nlesource: Protect seeks from tear down
Otherwise there is a race where we trigger the seek at the exact
same time the composition is being teared down potentially leading
to basesrc restarting its srcpad task which ends up being leaked.
Fixes ges.playback.scrub_backward_seeking.test_title.audio_video.vorbis_theora_ogg
and probably all its friends timeouting with the following stack trace:
(gdb) t a a bt
Thread 4 (Thread 0x7f5962acd700 (LWP 19997)):
#0 0x00007f5976713efd in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f5976a9d3f3 in g_cond_wait (cond=cond@entry=0x7f5938125410, mutex=mutex@entry=0x7f59381253c8) at gthread-posix.c:1402
#2 0x00007f5976c9e26b in gst_task_func (task=0x7f59381253b0 [GstTask]) at ../subprojects/gstreamer/gst/gsttask.c:313
#3 0x00007f5976a7ecb3 in g_thread_pool_thread_proxy (data=<optimized out>) at gthreadpool.c:307
#4 0x00007f5976a7e2aa in g_thread_proxy (data=0x7f5954071d40) at gthread.c:784
#5 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#6 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 3 (Thread 0x7f5963fff700 (LWP 19995)):
#0 0x00007f597670e421 in __GI___poll (fds=0xe32da0, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f5976a553a6 in g_main_context_poll (priority=<optimized out>, n_fds=2, fds=0xe32da0, timeout=<optimized out>, context=0xe31ff0) at gmain.c:4221
#2 0x00007f5976a553a6 in g_main_context_iterate (context=0xe31ff0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3915
#3 0x00007f5976a55762 in g_main_loop_run (loop=0xe32130) at gmain.c:4116
#4 0x00007f59768db10a in gdbus_shared_thread_func (user_data=0xe31fc0) at gdbusprivate.c:275
#5 0x00007f5976a7e2aa in g_thread_proxy (data=0xe1b8a0) at gthread.c:784
#6 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#7 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 2 (Thread 0x7f5968dcc700 (LWP 19994)):
#0 0x00007f597670e421 in __GI___poll (fds=0xe1bcc0, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f5976a553a6 in g_main_context_poll (priority=<optimized out>, n_fds=1, fds=0xe1bcc0, timeout=<optimized out>, context=0xe1b350) at gmain.c:4221
#2 0x00007f5976a553a6 in g_main_context_iterate (context=context@entry=0xe1b350, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3915
#3 0x00007f5976a554d0 in g_main_context_iteration (context=0xe1b350, may_block=may_block@entry=1) at gmain.c:3981
#4 0x00007f5976a55521 in glib_worker_main (data=<optimized out>) at gmain.c:5861
#5 0x00007f5976a7e2aa in g_thread_proxy (data=0xe1b800) at gthread.c:784
#6 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#7 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 1 (Thread 0x7f5975df4fc0 (LWP 19993)):
#0 0x00007f5976713efd in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f5976a9d3f3 in g_cond_wait (cond=cond@entry=0xe34020, mutex=0xe39b80) at gthread-posix.c:1402
#2 0x00007f5976a7f41c in g_thread_pool_free (pool=0xe34000, immediate=0, wait_=<optimized out>) at gthreadpool.c:776
#3 0x00007f5976c9f1ca in default_cleanup (pool=0xe256b0 [GstTaskPool]) at ../subprojects/gstreamer/gst/gsttaskpool.c:89
#4 0x00007f5976c9e32d in init_klass_pool (klass=<optimized out>) at ../subprojects/gstreamer/gst/gsttask.c:161
#5 0x00007f5976c9e502 in gst_task_cleanup_all () at ../subprojects/gstreamer/gst/gsttask.c:381
#6 0x00007f5976c214f4 in gst_deinit () at ../subprojects/gstreamer/gst/gst.c:1095
#7 0x000000000040394f in main (argc=6, argv=<optimized out>) at ../subprojects/gst-editing-services/tools/ges-launch.c:94
2019-03-15 20:07:06 +00:00
|
|
|
g_mutex_lock (&priv->seek_lock);
|
2014-08-25 16:11:52 +00:00
|
|
|
if (priv->seek_event) {
|
|
|
|
GstEvent *seek_event = priv->seek_event;
|
|
|
|
priv->seek_event = NULL;
|
|
|
|
|
2019-06-23 03:49:50 +00:00
|
|
|
GST_INFO_OBJECT (source, "Sending seek: %" GST_PTR_FORMAT, seek_event);
|
|
|
|
GST_OBJECT_LOCK (source);
|
|
|
|
priv->flush_seqnum = GST_EVENT_SEQNUM (seek_event);
|
|
|
|
GST_OBJECT_UNLOCK (source);
|
2014-08-25 16:11:52 +00:00
|
|
|
if (!(gst_pad_send_event (priv->ghostedpad, seek_event)))
|
|
|
|
GST_ELEMENT_ERROR (source, RESOURCE, SEEK,
|
|
|
|
(NULL), ("Sending initial seek to upstream element failed"));
|
|
|
|
}
|
nlesource: Protect seeks from tear down
Otherwise there is a race where we trigger the seek at the exact
same time the composition is being teared down potentially leading
to basesrc restarting its srcpad task which ends up being leaked.
Fixes ges.playback.scrub_backward_seeking.test_title.audio_video.vorbis_theora_ogg
and probably all its friends timeouting with the following stack trace:
(gdb) t a a bt
Thread 4 (Thread 0x7f5962acd700 (LWP 19997)):
#0 0x00007f5976713efd in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f5976a9d3f3 in g_cond_wait (cond=cond@entry=0x7f5938125410, mutex=mutex@entry=0x7f59381253c8) at gthread-posix.c:1402
#2 0x00007f5976c9e26b in gst_task_func (task=0x7f59381253b0 [GstTask]) at ../subprojects/gstreamer/gst/gsttask.c:313
#3 0x00007f5976a7ecb3 in g_thread_pool_thread_proxy (data=<optimized out>) at gthreadpool.c:307
#4 0x00007f5976a7e2aa in g_thread_proxy (data=0x7f5954071d40) at gthread.c:784
#5 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#6 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 3 (Thread 0x7f5963fff700 (LWP 19995)):
#0 0x00007f597670e421 in __GI___poll (fds=0xe32da0, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f5976a553a6 in g_main_context_poll (priority=<optimized out>, n_fds=2, fds=0xe32da0, timeout=<optimized out>, context=0xe31ff0) at gmain.c:4221
#2 0x00007f5976a553a6 in g_main_context_iterate (context=0xe31ff0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3915
#3 0x00007f5976a55762 in g_main_loop_run (loop=0xe32130) at gmain.c:4116
#4 0x00007f59768db10a in gdbus_shared_thread_func (user_data=0xe31fc0) at gdbusprivate.c:275
#5 0x00007f5976a7e2aa in g_thread_proxy (data=0xe1b8a0) at gthread.c:784
#6 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#7 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 2 (Thread 0x7f5968dcc700 (LWP 19994)):
#0 0x00007f597670e421 in __GI___poll (fds=0xe1bcc0, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f5976a553a6 in g_main_context_poll (priority=<optimized out>, n_fds=1, fds=0xe1bcc0, timeout=<optimized out>, context=0xe1b350) at gmain.c:4221
#2 0x00007f5976a553a6 in g_main_context_iterate (context=context@entry=0xe1b350, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3915
#3 0x00007f5976a554d0 in g_main_context_iteration (context=0xe1b350, may_block=may_block@entry=1) at gmain.c:3981
#4 0x00007f5976a55521 in glib_worker_main (data=<optimized out>) at gmain.c:5861
#5 0x00007f5976a7e2aa in g_thread_proxy (data=0xe1b800) at gthread.c:784
#6 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#7 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 1 (Thread 0x7f5975df4fc0 (LWP 19993)):
#0 0x00007f5976713efd in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f5976a9d3f3 in g_cond_wait (cond=cond@entry=0xe34020, mutex=0xe39b80) at gthread-posix.c:1402
#2 0x00007f5976a7f41c in g_thread_pool_free (pool=0xe34000, immediate=0, wait_=<optimized out>) at gthreadpool.c:776
#3 0x00007f5976c9f1ca in default_cleanup (pool=0xe256b0 [GstTaskPool]) at ../subprojects/gstreamer/gst/gsttaskpool.c:89
#4 0x00007f5976c9e32d in init_klass_pool (klass=<optimized out>) at ../subprojects/gstreamer/gst/gsttask.c:161
#5 0x00007f5976c9e502 in gst_task_cleanup_all () at ../subprojects/gstreamer/gst/gsttask.c:381
#6 0x00007f5976c214f4 in gst_deinit () at ../subprojects/gstreamer/gst/gst.c:1095
#7 0x000000000040394f in main (argc=6, argv=<optimized out>) at ../subprojects/gst-editing-services/tools/ges-launch.c:94
2019-03-15 20:07:06 +00:00
|
|
|
g_mutex_unlock (&priv->seek_lock);
|
2014-08-25 16:11:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstPadProbeReturn
|
2019-06-23 03:49:50 +00:00
|
|
|
pad_brobe_cb (GstPad * pad, GstPadProbeInfo * info, NleSource * source)
|
2014-08-25 16:11:52 +00:00
|
|
|
{
|
2019-06-23 03:49:50 +00:00
|
|
|
NleSourcePrivate *priv = source->priv;
|
|
|
|
GstPadProbeReturn res = GST_PAD_PROBE_OK;
|
|
|
|
|
2019-03-15 21:31:30 +00:00
|
|
|
GST_OBJECT_LOCK (source);
|
2020-02-06 15:39:12 +00:00
|
|
|
if (!priv->areblocked && priv->seek_event) {
|
2014-08-25 16:11:52 +00:00
|
|
|
GST_INFO_OBJECT (pad, "Blocked now, launching seek");
|
2019-06-23 03:49:50 +00:00
|
|
|
priv->areblocked = TRUE;
|
2019-03-15 21:31:30 +00:00
|
|
|
gst_element_call_async (GST_ELEMENT (source), ghost_seek_pad, NULL, NULL);
|
2019-06-23 03:49:50 +00:00
|
|
|
GST_OBJECT_UNLOCK (source);
|
|
|
|
|
|
|
|
return GST_PAD_PROBE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (priv->probeid && GST_EVENT_SEQNUM (info->data) == priv->flush_seqnum) {
|
|
|
|
priv->flush_seqnum = GST_SEQNUM_INVALID;
|
|
|
|
priv->areblocked = FALSE;
|
|
|
|
priv->probeid = 0;
|
|
|
|
res = GST_PAD_PROBE_REMOVE;
|
|
|
|
} else {
|
|
|
|
res = GST_PAD_PROBE_DROP;
|
|
|
|
GST_DEBUG_OBJECT (source, "Dropping %" GST_PTR_FORMAT " - %d ? %d",
|
|
|
|
info->data, GST_EVENT_SEQNUM (info->data), priv->flush_seqnum);
|
2014-08-25 16:11:52 +00:00
|
|
|
}
|
2019-03-15 21:31:30 +00:00
|
|
|
GST_OBJECT_UNLOCK (source);
|
2014-08-25 16:11:52 +00:00
|
|
|
|
2019-06-23 03:49:50 +00:00
|
|
|
return res;
|
2014-08-25 16:11:52 +00:00
|
|
|
}
|
|
|
|
|
2014-10-21 08:35:48 +00:00
|
|
|
static gboolean
|
2014-08-15 13:48:14 +00:00
|
|
|
nle_source_prepare (NleObject * object)
|
2014-10-21 08:35:48 +00:00
|
|
|
{
|
2014-07-15 12:59:54 +00:00
|
|
|
GstPad *pad;
|
2014-08-15 13:48:14 +00:00
|
|
|
NleSource *source = NLE_SOURCE (object);
|
|
|
|
NleSourcePrivate *priv = source->priv;
|
2014-10-21 08:35:48 +00:00
|
|
|
GstElement *parent =
|
|
|
|
(GstElement *) gst_element_get_parent ((GstElement *) object);
|
|
|
|
|
|
|
|
if (!source->element) {
|
|
|
|
GST_WARNING_OBJECT (source,
|
2014-08-15 13:48:14 +00:00
|
|
|
"NleSource doesn't have an element to control !");
|
2014-06-24 11:44:13 +00:00
|
|
|
if (parent)
|
|
|
|
gst_object_unref (parent);
|
2014-10-21 08:35:48 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2014-07-15 12:59:54 +00:00
|
|
|
if (!priv->staticpad && !(get_valid_src_pad (source, source->element, &pad))) {
|
|
|
|
GST_DEBUG_OBJECT (source, "Couldn't find a valid source pad");
|
2016-09-21 22:23:56 +00:00
|
|
|
gst_object_unref (parent);
|
|
|
|
return FALSE;
|
2020-02-06 15:39:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (priv->staticpad)
|
|
|
|
pad = gst_object_ref (priv->staticpad);
|
|
|
|
priv->ghostedpad = pad;
|
|
|
|
|
|
|
|
if (object->in_composition == FALSE) {
|
2020-02-19 02:08:53 +00:00
|
|
|
GstClockTime start =
|
|
|
|
GST_CLOCK_TIME_IS_VALID (object->inpoint) ? object->inpoint : 0;
|
|
|
|
GstClockTime stop = GST_CLOCK_TIME_NONE;
|
|
|
|
|
|
|
|
if (GST_CLOCK_TIME_IS_VALID (object->inpoint)
|
|
|
|
&& GST_CLOCK_TIME_IS_VALID (object->duration) && object->duration)
|
|
|
|
stop = object->inpoint + object->duration;
|
|
|
|
|
2020-02-06 15:39:12 +00:00
|
|
|
g_mutex_lock (&source->priv->seek_lock);
|
2020-05-02 02:56:38 +00:00
|
|
|
source->priv->seek_event = gst_event_new_seek (source->reverse ? -1.0 : 1.0,
|
|
|
|
GST_FORMAT_TIME,
|
2020-02-06 15:39:12 +00:00
|
|
|
GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH,
|
2020-02-19 02:08:53 +00:00
|
|
|
GST_SEEK_TYPE_SET, start, GST_SEEK_TYPE_SET, stop);
|
2020-02-06 15:39:12 +00:00
|
|
|
g_mutex_unlock (&source->priv->seek_lock);
|
2014-09-19 10:29:28 +00:00
|
|
|
GST_OBJECT_LOCK (source);
|
2014-08-25 16:11:52 +00:00
|
|
|
priv->probeid = gst_pad_add_probe (pad,
|
2019-06-23 03:49:50 +00:00
|
|
|
GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM | GST_PAD_PROBE_TYPE_EVENT_FLUSH |
|
|
|
|
GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, (GstPadProbeCallback) pad_brobe_cb,
|
|
|
|
source, NULL);
|
2014-09-19 10:29:28 +00:00
|
|
|
GST_OBJECT_UNLOCK (source);
|
2014-10-21 08:35:48 +00:00
|
|
|
}
|
|
|
|
|
2020-02-06 15:39:12 +00:00
|
|
|
GST_LOG_OBJECT (source, "srcpad:%p, dynamicpads:%d",
|
|
|
|
object->srcpad, priv->dynamicpads);
|
|
|
|
|
|
|
|
gst_object_unref (pad);
|
2014-10-21 08:35:48 +00:00
|
|
|
gst_object_unref (parent);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
nlesource: Protect seeks from tear down
Otherwise there is a race where we trigger the seek at the exact
same time the composition is being teared down potentially leading
to basesrc restarting its srcpad task which ends up being leaked.
Fixes ges.playback.scrub_backward_seeking.test_title.audio_video.vorbis_theora_ogg
and probably all its friends timeouting with the following stack trace:
(gdb) t a a bt
Thread 4 (Thread 0x7f5962acd700 (LWP 19997)):
#0 0x00007f5976713efd in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f5976a9d3f3 in g_cond_wait (cond=cond@entry=0x7f5938125410, mutex=mutex@entry=0x7f59381253c8) at gthread-posix.c:1402
#2 0x00007f5976c9e26b in gst_task_func (task=0x7f59381253b0 [GstTask]) at ../subprojects/gstreamer/gst/gsttask.c:313
#3 0x00007f5976a7ecb3 in g_thread_pool_thread_proxy (data=<optimized out>) at gthreadpool.c:307
#4 0x00007f5976a7e2aa in g_thread_proxy (data=0x7f5954071d40) at gthread.c:784
#5 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#6 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 3 (Thread 0x7f5963fff700 (LWP 19995)):
#0 0x00007f597670e421 in __GI___poll (fds=0xe32da0, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f5976a553a6 in g_main_context_poll (priority=<optimized out>, n_fds=2, fds=0xe32da0, timeout=<optimized out>, context=0xe31ff0) at gmain.c:4221
#2 0x00007f5976a553a6 in g_main_context_iterate (context=0xe31ff0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3915
#3 0x00007f5976a55762 in g_main_loop_run (loop=0xe32130) at gmain.c:4116
#4 0x00007f59768db10a in gdbus_shared_thread_func (user_data=0xe31fc0) at gdbusprivate.c:275
#5 0x00007f5976a7e2aa in g_thread_proxy (data=0xe1b8a0) at gthread.c:784
#6 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#7 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 2 (Thread 0x7f5968dcc700 (LWP 19994)):
#0 0x00007f597670e421 in __GI___poll (fds=0xe1bcc0, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f5976a553a6 in g_main_context_poll (priority=<optimized out>, n_fds=1, fds=0xe1bcc0, timeout=<optimized out>, context=0xe1b350) at gmain.c:4221
#2 0x00007f5976a553a6 in g_main_context_iterate (context=context@entry=0xe1b350, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3915
#3 0x00007f5976a554d0 in g_main_context_iteration (context=0xe1b350, may_block=may_block@entry=1) at gmain.c:3981
#4 0x00007f5976a55521 in glib_worker_main (data=<optimized out>) at gmain.c:5861
#5 0x00007f5976a7e2aa in g_thread_proxy (data=0xe1b800) at gthread.c:784
#6 0x00007f59767ea58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#7 0x00007f59767196a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 1 (Thread 0x7f5975df4fc0 (LWP 19993)):
#0 0x00007f5976713efd in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f5976a9d3f3 in g_cond_wait (cond=cond@entry=0xe34020, mutex=0xe39b80) at gthread-posix.c:1402
#2 0x00007f5976a7f41c in g_thread_pool_free (pool=0xe34000, immediate=0, wait_=<optimized out>) at gthreadpool.c:776
#3 0x00007f5976c9f1ca in default_cleanup (pool=0xe256b0 [GstTaskPool]) at ../subprojects/gstreamer/gst/gsttaskpool.c:89
#4 0x00007f5976c9e32d in init_klass_pool (klass=<optimized out>) at ../subprojects/gstreamer/gst/gsttask.c:161
#5 0x00007f5976c9e502 in gst_task_cleanup_all () at ../subprojects/gstreamer/gst/gsttask.c:381
#6 0x00007f5976c214f4 in gst_deinit () at ../subprojects/gstreamer/gst/gst.c:1095
#7 0x000000000040394f in main (argc=6, argv=<optimized out>) at ../subprojects/gst-editing-services/tools/ges-launch.c:94
2019-03-15 20:07:06 +00:00
|
|
|
|
|
|
|
static GstStateChangeReturn
|
|
|
|
nle_source_change_state (GstElement * element, GstStateChange transition)
|
|
|
|
{
|
|
|
|
NleSourcePrivate *priv = NLE_SOURCE (element)->priv;
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
|
|
|
g_mutex_lock (&priv->seek_lock);
|
|
|
|
gst_clear_event (&priv->seek_event);
|
|
|
|
g_mutex_unlock (&priv->seek_lock);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
|
|
|
}
|