Commit fdaa2307 authored by Wim Taymans's avatar Wim Taymans

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.
parent de4b9f65
......@@ -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;
......
This diff is collapsed.
......@@ -86,18 +86,18 @@ struct _GstBinClass {
GstElementClass parent_class;
/* signals */
void (*object_added) (GstObject *object, GstObject *child);
void (*object_removed) (GstObject *object, GstObject *child);
void (*object_added) (GstObject *object, GstObject *child);
void (*object_removed) (GstObject *object, GstObject *child);
/* change the state of elements of the given type */
gboolean (*change_state_type) (GstBin *bin,
GstElementState state,
GtkType type);
gboolean (*change_state_type) (GstBin *bin,
GstElementState state,
GtkType type);
/* create a plan for the execution of the bin */
void (*create_plan) (GstBin *bin);
void (*schedule) (GstBin *bin);
void (*create_plan) (GstBin *bin);
void (*schedule) (GstBin *bin);
/* run a full iteration of operation */
void (*iterate) (GstBin *bin);
void (*iterate) (GstBin *bin);
};
struct __GstBinChain {
......@@ -107,22 +107,18 @@ struct __GstBinChain {
GList *entries;
gboolean need_cothreads;
};
gboolean need_scheduling;
};
GtkType gst_bin_get_type (void);
GtkType gst_bin_get_type (void);
GstElement* gst_bin_new (const gchar *name);
#define gst_bin_destroy(bin) gst_object_destroy(GST_OBJECT(bin))
#define gst_bin_destroy(bin) gst_object_destroy(GST_OBJECT(bin))
/* add and remove elements from the bin */
void gst_bin_add (GstBin *bin,
GstElement *element);
void gst_bin_remove (GstBin *bin,
GstElement *element);
void gst_bin_add_eos_provider (GstBin *bin,
void gst_bin_add (GstBin *bin,
GstElement *element);
void gst_bin_remove_eos_provider (GstBin *bin,
void gst_bin_remove (GstBin *bin,
GstElement *element);
/* retrieve a single element or the list of children */
......@@ -130,16 +126,16 @@ GstElement* gst_bin_get_by_name (GstBin *bin,
const gchar *name);
GList* gst_bin_get_list (GstBin *bin);
void gst_bin_create_plan (GstBin *bin);
void gst_bin_schedule (GstBin *bin);
gboolean gst_bin_set_state_type (GstBin *bin,
void gst_bin_create_plan (GstBin *bin);
void gst_bin_schedule (GstBin *bin);
gboolean gst_bin_set_state_type (GstBin *bin,
GstElementState state,
GtkType type);
void gst_bin_iterate (GstBin *bin);
void gst_bin_iterate (GstBin *bin);
/* hack FIXME */
void gst_bin_use_cothreads (GstBin *bin,
void gst_bin_use_cothreads (GstBin *bin,
gboolean enabled);
#ifdef __cplusplus
......@@ -147,5 +143,5 @@ void gst_bin_use_cothreads (GstBin *bin,
#endif /* __cplusplus */
#endif /* __GST_BIN_H__ */
#endif /* __GST_BIN_H__ */
This diff is collapsed.
......@@ -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;
}
......
......@@ -62,7 +62,7 @@ gst_bin_chain_wrapper (int argc,char *argv[])
pads = element->pads;
while (pads) {
pad = GST_PAD (pads->data);
pads = g_list_next (pads);
pads = g_list_next (pads);
if (!GST_IS_REAL_PAD(pad)) continue;
realpad = GST_REAL_PAD(pad);
if (GST_RPAD_DIRECTION(realpad) == GST_PAD_SINK) {
......@@ -75,7 +75,7 @@ gst_bin_chain_wrapper (int argc,char *argv[])
}
} while (!GST_ELEMENT_IS_COTHREAD_STOPPING(element));
GST_FLAG_UNSET(element,GST_ELEMENT_COTHREAD_STOPPING);
GST_DEBUG_LEAVE("(%d,'%s')",argc,name);
return 0;
}
......@@ -88,7 +88,7 @@ gst_bin_src_wrapper (int argc,char *argv[])
GstRealPad *realpad;
GstBuffer *buf;
G_GNUC_UNUSED const gchar *name = gst_element_get_name (element);
GST_DEBUG_ENTER("(%d,\"%s\")",argc,name);
do {
......@@ -121,7 +121,7 @@ gst_bin_src_wrapper (int argc,char *argv[])
GST_DEBUG_LEAVE("");
return 0;
}
static void
gst_bin_pushfunc_proxy (GstPad *pad, GstBuffer *buf)
{
......@@ -149,9 +149,9 @@ gst_bin_pullfunc_proxy (GstPad *pad)
GST_DEBUG (0,"done switching\n");
buf = GST_RPAD_BUFPEN(pad);
GST_RPAD_BUFPEN(pad) = NULL;
return buf;
return buf;
}
static GstBuffer *
gst_bin_chainfunc_proxy (GstPad *pad)
{
......@@ -159,7 +159,7 @@ gst_bin_chainfunc_proxy (GstPad *pad)
// GstBuffer *buf;
return NULL;
}
// FIXME!!!
static void
gst_bin_pullregionfunc_proxy (GstPad *pad,
......@@ -168,12 +168,12 @@ gst_bin_pullregionfunc_proxy (GstPad *pad,
{
// region_struct region;
cothread_state *threadstate;
GST_DEBUG_ENTER("%s:%s,%ld,%ld",GST_DEBUG_PAD_NAME(pad),offset,size);
// region.offset = offset;
// region.size = size;
// threadstate = GST_ELEMENT(pad->parent)->threadstate;
// cothread_set_data (threadstate, "region", &region);
cothread_switch (threadstate);
......@@ -194,7 +194,7 @@ gst_schedule_cothreaded_chain (GstBin *bin, _GstBinChain *chain) {
// first create thread context
if (bin->threadcontext == NULL) {
GST_DEBUG (0,"initializing cothread context\n");
bin->threadcontext = cothread_init ();
bin->threadcontext = cothread_init ();
}
// walk through all the chain's elements
......@@ -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;
......@@ -380,7 +391,7 @@ void gst_bin_schedule_func(GstBin *bin) {
// if we're managed by the current bin, and we're not decoupled,
// go find all the peers and add them to the list of elements to check
if ((element->manager == GST_ELEMENT(bin)) &&
if ((element->manager == GST_ELEMENT(bin)) &&
!GST_FLAG_IS_SET (element, GST_ELEMENT_DECOUPLED)) {
// remove ourselves from the outer list of all managed elements
// GST_DEBUG (0,"removing '%s' from list of possible elements\n",gst_element_get_name(element));
......@@ -400,7 +411,7 @@ void gst_bin_schedule_func(GstBin *bin) {
if (!GST_IS_REAL_PAD(pad)) continue;
GST_DEBUG (0,"have pad %s:%s\n",GST_DEBUG_PAD_NAME(pad));
if (GST_RPAD_PEER(pad) == NULL) GST_ERROR(pad,"peer is null!");
if (GST_RPAD_PEER(pad) == NULL) GST_ERROR(pad,"peer is null!");
g_assert(GST_RPAD_PEER(pad) != NULL);
g_assert(GST_PAD(GST_RPAD_PEER(pad))->parent != NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment