From 90355128b51d3ff5fe53fae6313dd7ffc3ea019e Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 28 Dec 2001 20:20:26 +0000 Subject: [PATCH] - Removed deprecated buffer flags. Original commit message from CVS: - Removed deprecated buffer flags. - removed gst_element_signal_eos, replaced with gst_element_set_eos to set the object to PAUSED, signal an eos event etc.. - small updates to documentation - repair some plugins --- gst/cothreads.c | 7 +++++++ gst/elements/gstfakesrc.c | 2 +- gst/elements/gstfdsrc.c | 9 +++------ gst/elements/gstfilesrc.c | 4 ++-- gst/elements/gstmultidisksrc.c | 2 +- gst/elements/gstmultifilesrc.c | 2 +- gst/elements/gststatistics.c | 2 +- gst/gstbuffer.h | 3 --- gst/gstelement.c | 31 ++++++++++++++++++------------ gst/gstelement.h | 2 +- gst/gstelementfactory.c | 2 +- gst/gstpad.c | 7 +++---- gst/gstqueue.c | 2 +- gst/gstscheduler.c | 5 ++++- gst/gstthread.c | 3 +-- plugins/elements/gstfakesrc.c | 2 +- plugins/elements/gstfdsrc.c | 9 +++------ plugins/elements/gstfilesrc.c | 4 ++-- plugins/elements/gstmultidisksrc.c | 2 +- plugins/elements/gstmultifilesrc.c | 2 +- plugins/elements/gstqueue.c | 2 +- plugins/elements/gststatistics.c | 2 +- 22 files changed, 56 insertions(+), 50 deletions(-) diff --git a/gst/cothreads.c b/gst/cothreads.c index a37ea45715..4908ed0ca0 100644 --- a/gst/cothreads.c +++ b/gst/cothreads.c @@ -110,6 +110,7 @@ cothread_context_init (void) /** * cothread_context_free: + * @ctx: the cothread context to free * * Free the cothread context. */ @@ -270,6 +271,12 @@ cothread_setfunc (cothread_state * thread, cothread_func func, int argc, char ** thread->pc = (void *) func; } +/** + * cothread_stop: + * @thread: the cothread to stop + * + * Stop the cothread and reset the stack and program counter. + */ void cothread_stop (cothread_state * thread) { diff --git a/gst/elements/gstfakesrc.c b/gst/elements/gstfakesrc.c index 1f870311d0..2946b61307 100644 --- a/gst/elements/gstfakesrc.c +++ b/gst/elements/gstfakesrc.c @@ -649,7 +649,7 @@ gst_fakesrc_get(GstPad *pad) } if (src->rt_num_buffers == 0) { - gst_element_set_state (GST_ELEMENT (src), GST_STATE_PAUSED); + gst_element_set_eos (GST_ELEMENT (src)); return GST_BUFFER(gst_event_new (GST_EVENT_EOS)); } else { diff --git a/gst/elements/gstfdsrc.c b/gst/elements/gstfdsrc.c index eea8df430d..acb738eb86 100644 --- a/gst/elements/gstfdsrc.c +++ b/gst/elements/gstfdsrc.c @@ -199,15 +199,12 @@ gst_fdsrc_get(GstPad *pad) /* read it in from the file */ readbytes = read(src->fd,GST_BUFFER_DATA(buf),src->bytes_per_read); + /* if nothing was read, we're in eos */ if (readbytes == 0) { - return NULL; + gst_element_set_eos (GST_ELEMENT (src)); + return GST_BUFFER (gst_event_new (GST_EVENT_EOS)); } - /* if we didn't get as many bytes as we asked for, we're at EOF */ - if (readbytes < src->bytes_per_read) { - /* set the buffer's EOF bit here */ - GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS); - } GST_BUFFER_OFFSET(buf) = src->curoffset; GST_BUFFER_SIZE(buf) = readbytes; src->curoffset += readbytes; diff --git a/gst/elements/gstfilesrc.c b/gst/elements/gstfilesrc.c index bda732e0e1..2d9541e8ab 100644 --- a/gst/elements/gstfilesrc.c +++ b/gst/elements/gstfilesrc.c @@ -444,7 +444,7 @@ gst_filesrc_get (GstPad *pad) /* check for EOF */ if (src->curoffset == src->filelen) { - gst_element_set_state (GST_ELEMENT (src), GST_STATE_PAUSED); + gst_element_set_eos (GST_ELEMENT (src)); return GST_BUFFER (gst_event_new(GST_EVENT_EOS)); } @@ -498,7 +498,7 @@ gst_filesrc_get (GstPad *pad) region.size = readsize; map = g_tree_search (src->map_regions, (GCompareFunc) gst_filesrc_search_region_match, - ®ion); + (gpointer)®ion); /* if we found an exact match, subbuffer it */ if (map != NULL) { diff --git a/gst/elements/gstmultidisksrc.c b/gst/elements/gstmultidisksrc.c index 15892cccea..3e83f9ef34 100644 --- a/gst/elements/gstmultidisksrc.c +++ b/gst/elements/gstmultidisksrc.c @@ -228,7 +228,7 @@ gst_multidisksrc_get (GstPad *pad) GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DONTFREE); if (src->new_seek) { - GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLUSH); + /* fixme, do something here */ src->new_seek = FALSE; } diff --git a/gst/elements/gstmultifilesrc.c b/gst/elements/gstmultifilesrc.c index 15892cccea..3e83f9ef34 100644 --- a/gst/elements/gstmultifilesrc.c +++ b/gst/elements/gstmultifilesrc.c @@ -228,7 +228,7 @@ gst_multidisksrc_get (GstPad *pad) GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DONTFREE); if (src->new_seek) { - GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLUSH); + /* fixme, do something here */ src->new_seek = FALSE; } diff --git a/gst/elements/gststatistics.c b/gst/elements/gststatistics.c index fbfdbd9a2a..913b53beff 100644 --- a/gst/elements/gststatistics.c +++ b/gst/elements/gststatistics.c @@ -284,7 +284,7 @@ gst_statistics_chain (GstPad *pad, GstBuffer *buf) GstEvent *event = GST_EVENT (buf); statistics->stats.events += 1; if (GST_EVENT_TYPE(event) == GST_EVENT_EOS) { - gst_element_set_state (GST_ELEMENT (statistics), GST_STATE_PAUSED); + gst_element_set_eos (GST_ELEMENT (statistics)); if (statistics->update_on_eos) { update = TRUE; } diff --git a/gst/gstbuffer.h b/gst/gstbuffer.h index 89af2ccd52..ac5287271f 100644 --- a/gst/gstbuffer.h +++ b/gst/gstbuffer.h @@ -85,9 +85,6 @@ typedef enum { GST_BUFFER_ORIGINAL, GST_BUFFER_DONTFREE, - GST_BUFFER_FLUSH, - GST_BUFFER_EOS, - GST_BUFFER_DISCONTINUOUS, } GstBufferFlags; diff --git a/gst/gstelement.c b/gst/gstelement.c index 679fb960fc..25001d392f 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -790,7 +790,8 @@ gst_element_message (GstElement *element, const gchar *type, const gchar *info, /** * gst_element_error: * @element: Element with the error - * @error: String describing the error + * @error: A printf-like string describing the error + * @...: optional arguments for the string * * This function is used internally by elements to signal an error * condition. It results in the "error" signal. @@ -930,7 +931,6 @@ gst_element_set_state (GstElement *element, GstElementState state) /* g_print("gst_element_set_state(\"%s\",%08lx)\n", */ /* element->name,state); */ - g_return_val_if_fail (element != NULL, GST_STATE_FAILURE); g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE); GST_DEBUG_ELEMENT (GST_CAT_STATES,element, "setting state from %s to %s\n", @@ -985,7 +985,6 @@ gst_element_change_state (GstElement *element) GstElementState old_state; GstObject *parent; - g_return_val_if_fail (element != NULL, GST_STATE_FAILURE); g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE); old_state = GST_STATE (element); @@ -1038,7 +1037,6 @@ gst_element_get_factory (GstElement *element) { GstElementClass *oclass; - g_return_val_if_fail (element != NULL, NULL); g_return_val_if_fail (GST_IS_ELEMENT (element), NULL); oclass = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS(element)); @@ -1313,7 +1311,10 @@ void gst_element_set_sched (GstElement *element, GstScheduler *sched) { - GST_INFO_ELEMENT (GST_CAT_PARENTAGE, element, "setting scheduler to %p",sched); + g_return_if_fail (GST_IS_ELEMENT (element)); + + GST_INFO_ELEMENT (GST_CAT_PARENTAGE, element, "setting scheduler to %p", sched); + element->sched = sched; } @@ -1328,6 +1329,8 @@ gst_element_set_sched (GstElement *element, GstScheduler* gst_element_get_sched (GstElement *element) { + g_return_val_if_fail (GST_IS_ELEMENT (element), NULL); + return element->sched; } @@ -1348,26 +1351,30 @@ void gst_element_set_loop_function(GstElement *element, GstElementLoopFunction loop) { + g_return_if_fail (GST_IS_ELEMENT (element)); + /* set the loop function */ element->loopfunc = loop; /* set the NEW_LOOPFUNC flag so everyone knows to go try again */ - GST_FLAG_SET(element,GST_ELEMENT_NEW_LOOPFUNC); + GST_FLAG_SET (element, GST_ELEMENT_NEW_LOOPFUNC); } /** - * gst_element_signal_eos: - * @element: element to trigger the eos signal of + * gst_element_set_eos: + * @element: element to set to the EOS state * - * Throws the eos signal to indicate that the end of the stream is reached. + * Perform the actions needed to bring the element in the EOS state. */ void -gst_element_signal_eos (GstElement *element) +gst_element_set_eos (GstElement *element) { - g_return_if_fail (element != NULL); g_return_if_fail (GST_IS_ELEMENT (element)); - GST_DEBUG(GST_CAT_EVENT, "signaling EOS on element %s\n",GST_OBJECT_NAME(element)); + GST_DEBUG (GST_CAT_EVENT, "setting EOS on element %s\n", GST_OBJECT_NAME (element)); + + gst_element_set_state (element, GST_STATE_PAUSED); + g_signal_emit (G_OBJECT (element), gst_element_signals[EOS], 0); } diff --git a/gst/gstelement.h b/gst/gstelement.h index fa8fd48ee3..f05656d608 100644 --- a/gst/gstelement.h +++ b/gst/gstelement.h @@ -205,7 +205,7 @@ 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_signal_eos (GstElement *element); +void gst_element_set_eos (GstElement *element); void gst_element_send_event (GstElement *element, GstEvent *event); diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index 03c4517a74..b35e1c2fcd 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -251,7 +251,7 @@ gst_elementfactory_create (GstElementFactory *factory, GST_DEBUG (GST_CAT_ELEMENTFACTORY,"class %s\n", GST_OBJECT_NAME (factory)); oclass->elementfactory = factory; - // copy pad template pointers to the element class + /* copy pad template pointers to the element class */ oclass->padtemplates = g_list_copy(factory->padtemplates); oclass->numpadtemplates = factory->numpadtemplates; } diff --git a/gst/gstpad.c b/gst/gstpad.c index 847eb9d50f..f0cd7de158 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -726,7 +726,7 @@ gst_pad_get_padtemplate (GstPad *pad) } -/* +/** * gst_pad_set_sched: * @pad: the pad to set the scheduler for * @sched: The scheduler to set @@ -1583,8 +1583,7 @@ gst_pad_pullregion (GstPad *pad, GstRegionType type, guint64 offset, guint64 len } } /* FIXME */ - while (result && ! GST_BUFFER_FLAG_IS_SET (result, GST_BUFFER_EOS) - && !(GST_BUFFER_OFFSET (result) == offset && + while (result && !(GST_BUFFER_OFFSET (result) == offset && GST_BUFFER_SIZE (result) == len)); return result; @@ -2038,7 +2037,7 @@ gst_pad_event_default (GstPad *pad, GstEvent *event) switch (GST_EVENT_TYPE (event)) { case GST_EVENT_EOS: - gst_element_set_state (element, GST_STATE_PAUSED); + gst_element_set_eos (element); gst_pad_event_default_dispatch (pad, element, event); gst_event_free (event); /* we have to try to schedule another element because this one is disabled */ diff --git a/gst/gstqueue.c b/gst/gstqueue.c index 3020513121..be3abf9e66 100644 --- a/gst/gstqueue.c +++ b/gst/gstqueue.c @@ -488,7 +488,7 @@ restart: switch (GST_EVENT_TYPE(event)) { case GST_EVENT_EOS: GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "queue \"%s\" eos\n", GST_ELEMENT_NAME (queue)); - gst_element_set_state (GST_ELEMENT (queue), GST_STATE_PAUSED); + gst_element_set_eos (GST_ELEMENT (queue)); break; default: break; diff --git a/gst/gstscheduler.c b/gst/gstscheduler.c index c08cbbb567..66ec27fca5 100644 --- a/gst/gstscheduler.c +++ b/gst/gstscheduler.c @@ -180,6 +180,9 @@ gst_scheduler_add_element (GstScheduler *sched, GstElement *element) * @transition: the state transition * * Tell the scheduler that an element changed its state. + * + * Returns: a GstElementStateReturn indicating success or failure + * of the state transition. */ GstElementStateReturn gst_scheduler_state_transition (GstScheduler *sched, GstElement *element, gint transition) @@ -285,7 +288,7 @@ gst_scheduler_yield (GstScheduler *sched, GstElement *element) * * Tell the scheduler to interrupt execution of this element. * - * Retruns: TRUE if the element should return NULL from the chain/get + * Returns: TRUE if the element should return NULL from the chain/get * function. */ gboolean diff --git a/gst/gstthread.c b/gst/gstthread.c index 7743f52a36..ae29844aeb 100644 --- a/gst/gstthread.c +++ b/gst/gstthread.c @@ -310,8 +310,7 @@ gst_thread_change_state (GstElement * element) break; case GST_STATE_PLAYING_TO_PAUSED: { - //GList *elements = (element->sched)->elements; - GList *elements = gst_bin_get_list(GST_BIN (thread)); + GList *elements = gst_bin_get_list (GST_BIN (thread)); THR_INFO ("pausing thread"); diff --git a/plugins/elements/gstfakesrc.c b/plugins/elements/gstfakesrc.c index 1f870311d0..2946b61307 100644 --- a/plugins/elements/gstfakesrc.c +++ b/plugins/elements/gstfakesrc.c @@ -649,7 +649,7 @@ gst_fakesrc_get(GstPad *pad) } if (src->rt_num_buffers == 0) { - gst_element_set_state (GST_ELEMENT (src), GST_STATE_PAUSED); + gst_element_set_eos (GST_ELEMENT (src)); return GST_BUFFER(gst_event_new (GST_EVENT_EOS)); } else { diff --git a/plugins/elements/gstfdsrc.c b/plugins/elements/gstfdsrc.c index eea8df430d..acb738eb86 100644 --- a/plugins/elements/gstfdsrc.c +++ b/plugins/elements/gstfdsrc.c @@ -199,15 +199,12 @@ gst_fdsrc_get(GstPad *pad) /* read it in from the file */ readbytes = read(src->fd,GST_BUFFER_DATA(buf),src->bytes_per_read); + /* if nothing was read, we're in eos */ if (readbytes == 0) { - return NULL; + gst_element_set_eos (GST_ELEMENT (src)); + return GST_BUFFER (gst_event_new (GST_EVENT_EOS)); } - /* if we didn't get as many bytes as we asked for, we're at EOF */ - if (readbytes < src->bytes_per_read) { - /* set the buffer's EOF bit here */ - GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS); - } GST_BUFFER_OFFSET(buf) = src->curoffset; GST_BUFFER_SIZE(buf) = readbytes; src->curoffset += readbytes; diff --git a/plugins/elements/gstfilesrc.c b/plugins/elements/gstfilesrc.c index bda732e0e1..2d9541e8ab 100644 --- a/plugins/elements/gstfilesrc.c +++ b/plugins/elements/gstfilesrc.c @@ -444,7 +444,7 @@ gst_filesrc_get (GstPad *pad) /* check for EOF */ if (src->curoffset == src->filelen) { - gst_element_set_state (GST_ELEMENT (src), GST_STATE_PAUSED); + gst_element_set_eos (GST_ELEMENT (src)); return GST_BUFFER (gst_event_new(GST_EVENT_EOS)); } @@ -498,7 +498,7 @@ gst_filesrc_get (GstPad *pad) region.size = readsize; map = g_tree_search (src->map_regions, (GCompareFunc) gst_filesrc_search_region_match, - ®ion); + (gpointer)®ion); /* if we found an exact match, subbuffer it */ if (map != NULL) { diff --git a/plugins/elements/gstmultidisksrc.c b/plugins/elements/gstmultidisksrc.c index 15892cccea..3e83f9ef34 100644 --- a/plugins/elements/gstmultidisksrc.c +++ b/plugins/elements/gstmultidisksrc.c @@ -228,7 +228,7 @@ gst_multidisksrc_get (GstPad *pad) GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DONTFREE); if (src->new_seek) { - GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLUSH); + /* fixme, do something here */ src->new_seek = FALSE; } diff --git a/plugins/elements/gstmultifilesrc.c b/plugins/elements/gstmultifilesrc.c index 15892cccea..3e83f9ef34 100644 --- a/plugins/elements/gstmultifilesrc.c +++ b/plugins/elements/gstmultifilesrc.c @@ -228,7 +228,7 @@ gst_multidisksrc_get (GstPad *pad) GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DONTFREE); if (src->new_seek) { - GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLUSH); + /* fixme, do something here */ src->new_seek = FALSE; } diff --git a/plugins/elements/gstqueue.c b/plugins/elements/gstqueue.c index 3020513121..be3abf9e66 100644 --- a/plugins/elements/gstqueue.c +++ b/plugins/elements/gstqueue.c @@ -488,7 +488,7 @@ restart: switch (GST_EVENT_TYPE(event)) { case GST_EVENT_EOS: GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "queue \"%s\" eos\n", GST_ELEMENT_NAME (queue)); - gst_element_set_state (GST_ELEMENT (queue), GST_STATE_PAUSED); + gst_element_set_eos (GST_ELEMENT (queue)); break; default: break; diff --git a/plugins/elements/gststatistics.c b/plugins/elements/gststatistics.c index fbfdbd9a2a..913b53beff 100644 --- a/plugins/elements/gststatistics.c +++ b/plugins/elements/gststatistics.c @@ -284,7 +284,7 @@ gst_statistics_chain (GstPad *pad, GstBuffer *buf) GstEvent *event = GST_EVENT (buf); statistics->stats.events += 1; if (GST_EVENT_TYPE(event) == GST_EVENT_EOS) { - gst_element_set_state (GST_ELEMENT (statistics), GST_STATE_PAUSED); + gst_element_set_eos (GST_ELEMENT (statistics)); if (statistics->update_on_eos) { update = TRUE; }