mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
A very small change to make eos somewhat work. no inner bins are checked.
Original commit message from CVS: A very small change to make eos somewhat work. no inner bins are checked. When an element fires EOS, the chain with that element is removed from the scheduler (marked inactive). If all chains are inactive, the bin fires EOS.
This commit is contained in:
parent
de4b9f654e
commit
fdaa2307da
7 changed files with 176 additions and 202 deletions
|
@ -263,7 +263,7 @@ cothread_switch (cothread_state *thread)
|
|||
if (current == thread) goto selfswitch;
|
||||
|
||||
// find the number of the thread to switch to
|
||||
GST_INFO (GST_CAT_COTHREAD_SWITCH,"switching from cothread %d to to cothread #%d\n",
|
||||
GST_INFO (GST_CAT_COTHREAD_SWITCH,"switching from cothread %d to to cothread #%d",
|
||||
ctx->current,thread->threadnum);
|
||||
ctx->current = thread->threadnum;
|
||||
|
||||
|
|
33
gst/gstbin.c
33
gst/gstbin.c
|
@ -711,6 +711,7 @@ gst_bin_iterate_func (GstBin *bin)
|
|||
GList *pads;
|
||||
GstPad *pad;
|
||||
GstBuffer *buf = NULL;
|
||||
gint num_scheduled = 0;
|
||||
|
||||
GST_DEBUG_ENTER("(\"%s\")", gst_element_get_name (GST_ELEMENT (bin)));
|
||||
|
||||
|
@ -724,6 +725,8 @@ gst_bin_iterate_func (GstBin *bin)
|
|||
chain = (_GstBinChain *)(chains->data);
|
||||
chains = g_list_next (chains);
|
||||
|
||||
if (!chain->need_scheduling) continue;
|
||||
|
||||
if (chain->need_cothreads) {
|
||||
// all we really have to do is switch to the first child
|
||||
// FIXME this should be lots more intelligent about where to start
|
||||
|
@ -767,33 +770,13 @@ gst_bin_iterate_func (GstBin *bin)
|
|||
}
|
||||
}
|
||||
}
|
||||
num_scheduled++;
|
||||
}
|
||||
|
||||
if (!num_scheduled) {
|
||||
gst_element_signal_eos (GST_ELEMENT (bin));
|
||||
}
|
||||
|
||||
GST_DEBUG_LEAVE("(%s)", gst_element_get_name (GST_ELEMENT (bin)));
|
||||
}
|
||||
|
||||
static void
|
||||
gst_bin_eos_func (GstBin *bin, GstElement *element)
|
||||
{
|
||||
gst_element_signal_eos (GST_ELEMENT (bin));
|
||||
}
|
||||
|
||||
void
|
||||
gst_bin_add_eos_provider (GstBin *bin, GstElement *element)
|
||||
{
|
||||
g_return_if_fail (bin != NULL);
|
||||
g_return_if_fail (GST_IS_BIN (bin));
|
||||
|
||||
bin->eos_providers = g_list_prepend (bin->eos_providers, element);
|
||||
gtk_signal_connect_object (GTK_OBJECT (element), "eos", gst_bin_eos_func, GTK_OBJECT (bin));
|
||||
}
|
||||
|
||||
void
|
||||
gst_bin_remove_eos_provider (GstBin *bin, GstElement *element)
|
||||
{
|
||||
g_return_if_fail (bin != NULL);
|
||||
g_return_if_fail (GST_IS_BIN (bin));
|
||||
|
||||
bin->eos_providers = g_list_remove (bin->eos_providers, element);
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,7 @@ struct __GstBinChain {
|
|||
GList *entries;
|
||||
|
||||
gboolean need_cothreads;
|
||||
gboolean need_scheduling;
|
||||
};
|
||||
|
||||
|
||||
|
@ -120,11 +121,6 @@ void gst_bin_add (GstBin *bin,
|
|||
void gst_bin_remove (GstBin *bin,
|
||||
GstElement *element);
|
||||
|
||||
void gst_bin_add_eos_provider (GstBin *bin,
|
||||
GstElement *element);
|
||||
void gst_bin_remove_eos_provider (GstBin *bin,
|
||||
GstElement *element);
|
||||
|
||||
/* retrieve a single element or the list of children */
|
||||
GstElement* gst_bin_get_by_name (GstBin *bin,
|
||||
const gchar *name);
|
||||
|
|
|
@ -1020,19 +1020,3 @@ gst_element_signal_eos (GstElement *element)
|
|||
gtk_signal_emit (GTK_OBJECT (element), gst_element_signals[EOS]);
|
||||
}
|
||||
|
||||
void
|
||||
gst_element_announce_eos (GstElement *element, gboolean success)
|
||||
{
|
||||
g_return_if_fail (element != NULL);
|
||||
g_return_if_fail (GST_IS_ELEMENT (element));
|
||||
|
||||
GST_DEBUG(GST_CAT_ELEMENT_PADS,"element '%s' announce eos\n", gst_element_get_name (element));
|
||||
|
||||
if (success) {
|
||||
gst_bin_add_eos_provider (GST_BIN (gst_element_get_manager (element)), element);
|
||||
}
|
||||
else {
|
||||
gst_bin_remove_eos_provider (GST_BIN (gst_element_get_manager (element)), element);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -110,12 +110,16 @@ typedef enum {
|
|||
/* the element has to be scheduled as a cothread for any sanity */
|
||||
GST_ELEMENT_USE_COTHREAD,
|
||||
|
||||
// if this element is in EOS
|
||||
GST_ELEMENT_EOS,
|
||||
|
||||
/* use some padding for future expansion */
|
||||
GST_ELEMENT_FLAG_LAST = GST_OBJECT_FLAG_LAST + 8,
|
||||
} GstElementFlags;
|
||||
|
||||
#define GST_ELEMENT_IS_THREAD_SUGGESTED(obj) (GST_FLAG_IS_SET(obj,GST_ELEMENT_THREAD_SUGGESTED))
|
||||
#define GST_ELEMENT_IS_COTHREAD_STOPPING(obj) (GST_FLAG_IS_SET(obj,GST_ELEMENT_COTHREAD_STOPPING))
|
||||
#define GST_ELEMENT_IS_EOS(obj) (GST_FLAG_IS_SET(obj,GST_ELEMENT_EOS))
|
||||
|
||||
|
||||
typedef struct _GstElement GstElement;
|
||||
|
@ -215,7 +219,6 @@ void gst_element_connect (GstElement *src, const gchar *srcpadname,
|
|||
void gst_element_disconnect (GstElement *src, const gchar *srcpadname,
|
||||
GstElement *dest, const gchar *destpadname);
|
||||
|
||||
void gst_element_announce_eos (GstElement *element, gboolean success);
|
||||
void gst_element_signal_eos (GstElement *element);
|
||||
|
||||
|
||||
|
|
|
@ -1175,10 +1175,7 @@ gst_pad_set_eos(GstPad *pad)
|
|||
|
||||
GST_INFO (GST_CAT_PADS,"attempting to set EOS on src pad %s:%s",GST_DEBUG_PAD_NAME(pad));
|
||||
|
||||
gst_element_announce_eos (GST_ELEMENT (pad->parent), TRUE);
|
||||
|
||||
if (!gst_pad_eos(GST_REAL_PAD(pad))) {
|
||||
gst_element_announce_eos (GST_ELEMENT (pad->parent), FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -303,7 +303,9 @@ gst_schedule_chained_chain (GstBin *bin, _GstBinChain *chain) {
|
|||
}
|
||||
}
|
||||
|
||||
static void gst_bin_schedule_cleanup(GstBin *bin) {
|
||||
static void
|
||||
gst_bin_schedule_cleanup (GstBin *bin)
|
||||
{
|
||||
GList *chains;
|
||||
_GstBinChain *chain;
|
||||
|
||||
|
@ -322,6 +324,13 @@ static void gst_bin_schedule_cleanup(GstBin *bin) {
|
|||
bin->chains = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_scheduler_handle_eos (GstElement *element, _GstBinChain *chain)
|
||||
{
|
||||
GST_DEBUG (0,"chain removed from scheduler, EOS from element \"%s\"\n", gst_element_get_name (element));
|
||||
chain->need_scheduling = FALSE;
|
||||
}
|
||||
|
||||
void gst_bin_schedule_func(GstBin *bin) {
|
||||
GList *elements;
|
||||
GstElement *element;
|
||||
|
@ -361,6 +370,7 @@ void gst_bin_schedule_func(GstBin *bin) {
|
|||
|
||||
// create a chain structure
|
||||
chain = g_new0 (_GstBinChain, 1);
|
||||
chain->need_scheduling = TRUE;
|
||||
|
||||
// for each pending element, walk the pipeline
|
||||
do {
|
||||
|
@ -372,6 +382,7 @@ void gst_bin_schedule_func(GstBin *bin) {
|
|||
GST_DEBUG (0,"adding '%s' to chain\n",gst_element_get_name(element));
|
||||
chain->elements = g_list_prepend (chain->elements, element);
|
||||
chain->num_elements++;
|
||||
gtk_signal_connect (GTK_OBJECT (element), "eos", gst_scheduler_handle_eos, chain);
|
||||
// set the cothreads flag as appropriate
|
||||
if (GST_FLAG_IS_SET (element, GST_ELEMENT_USE_COTHREAD))
|
||||
chain->need_cothreads = TRUE;
|
||||
|
|
Loading…
Reference in a new issue