mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
ext/ogg/gstoggdemux.c: Don't leak events.
Original commit message from CVS: * ext/ogg/gstoggdemux.c: (gst_ogg_pad_src_query), (gst_ogg_demux_receive_event), (gst_ogg_pad_event), (gst_ogg_demux_init), (gst_ogg_demux_finalize), (gst_ogg_demux_sink_event), (gst_ogg_demux_get_data), (gst_ogg_demux_loop): Don't leak events. Remember what error we got when finding chains, if we were shutdown, that would not be an error.
This commit is contained in:
parent
35058f78c1
commit
c4c0040e10
2 changed files with 57 additions and 23 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2006-04-10 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_src_query),
|
||||||
|
(gst_ogg_demux_receive_event), (gst_ogg_pad_event),
|
||||||
|
(gst_ogg_demux_init), (gst_ogg_demux_finalize),
|
||||||
|
(gst_ogg_demux_sink_event), (gst_ogg_demux_get_data),
|
||||||
|
(gst_ogg_demux_loop):
|
||||||
|
Don't leak events.
|
||||||
|
Remember what error we got when finding chains, if we
|
||||||
|
were shutdown, that would not be an error.
|
||||||
|
|
||||||
2006-04-10 Wim Taymans <wim@fluendo.com>
|
2006-04-10 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* gst-libs/gst/audio/gstbaseaudiosink.c:
|
* gst-libs/gst/audio/gstbaseaudiosink.c:
|
||||||
|
|
|
@ -167,6 +167,7 @@ struct _GstOggDemux
|
||||||
GMutex *chain_lock; /* we need the lock to protect the chains */
|
GMutex *chain_lock; /* we need the lock to protect the chains */
|
||||||
GArray *chains; /* list of chains we know */
|
GArray *chains; /* list of chains we know */
|
||||||
GstClockTime total_time;
|
GstClockTime total_time;
|
||||||
|
GstFlowReturn chain_error; /* error we received while finding chains */
|
||||||
|
|
||||||
GstOggChain *current_chain;
|
GstOggChain *current_chain;
|
||||||
GstOggChain *building_chain;
|
GstOggChain *building_chain;
|
||||||
|
@ -391,7 +392,7 @@ gst_ogg_pad_src_query (GstPad * pad, GstQuery * query)
|
||||||
GstOggDemux *ogg;
|
GstOggDemux *ogg;
|
||||||
GstOggPad *cur;
|
GstOggPad *cur;
|
||||||
|
|
||||||
ogg = GST_OGG_DEMUX (GST_PAD_PARENT (pad));
|
ogg = GST_OGG_DEMUX (gst_pad_get_parent (pad));
|
||||||
cur = GST_OGG_PAD (pad);
|
cur = GST_OGG_PAD (pad);
|
||||||
|
|
||||||
switch (GST_QUERY_TYPE (query)) {
|
switch (GST_QUERY_TYPE (query)) {
|
||||||
|
@ -401,12 +402,11 @@ gst_ogg_pad_src_query (GstPad * pad, GstQuery * query)
|
||||||
|
|
||||||
gst_query_parse_duration (query, &format, NULL);
|
gst_query_parse_duration (query, &format, NULL);
|
||||||
/* can only get position in time */
|
/* can only get position in time */
|
||||||
if (format != GST_FORMAT_TIME) {
|
if (format != GST_FORMAT_TIME)
|
||||||
GST_DEBUG_OBJECT (ogg, "only query duration on TIME is supported");
|
goto wrong_format;
|
||||||
res = FALSE;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
/* can only return the total time position */
|
/* can only return the total time position */
|
||||||
|
/* FIXME, return time for this specific stream */
|
||||||
gst_query_set_duration (query, GST_FORMAT_TIME, ogg->total_time);
|
gst_query_set_duration (query, GST_FORMAT_TIME, ogg->total_time);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -415,7 +415,17 @@ gst_ogg_pad_src_query (GstPad * pad, GstQuery * query)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
|
gst_object_unref (ogg);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
|
/* ERRORS */
|
||||||
|
wrong_format:
|
||||||
|
{
|
||||||
|
GST_DEBUG_OBJECT (ogg, "only query duration on TIME is supported");
|
||||||
|
res = FALSE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -428,7 +438,6 @@ gst_ogg_demux_receive_event (GstElement * element, GstEvent * event)
|
||||||
|
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
case GST_EVENT_SEEK:
|
case GST_EVENT_SEEK:
|
||||||
{
|
|
||||||
/* can't seek if we are not seekable, FIXME could pass the
|
/* can't seek if we are not seekable, FIXME could pass the
|
||||||
* seek query upstream after converting it to bytes using
|
* seek query upstream after converting it to bytes using
|
||||||
* the average bitrate of the stream. */
|
* the average bitrate of the stream. */
|
||||||
|
@ -439,13 +448,11 @@ gst_ogg_demux_receive_event (GstElement * element, GstEvent * event)
|
||||||
|
|
||||||
/* now do the seek */
|
/* now do the seek */
|
||||||
res = gst_ogg_demux_perform_seek (ogg, event);
|
res = gst_ogg_demux_perform_seek (ogg, event);
|
||||||
|
gst_event_unref (event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
GST_DEBUG_OBJECT (ogg, "We only handle seek events here");
|
GST_DEBUG_OBJECT (ogg, "We only handle seek events here");
|
||||||
goto error;
|
goto error;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@ -466,12 +473,11 @@ gst_ogg_pad_event (GstPad * pad, GstEvent * event)
|
||||||
GstOggDemux *ogg;
|
GstOggDemux *ogg;
|
||||||
GstOggPad *cur;
|
GstOggPad *cur;
|
||||||
|
|
||||||
ogg = GST_OGG_DEMUX (GST_PAD_PARENT (pad));
|
ogg = GST_OGG_DEMUX (gst_pad_get_parent (pad));
|
||||||
cur = GST_OGG_PAD (pad);
|
cur = GST_OGG_PAD (pad);
|
||||||
|
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
case GST_EVENT_SEEK:
|
case GST_EVENT_SEEK:
|
||||||
{
|
|
||||||
/* can't seek if we are not seekable, FIXME could pass the
|
/* can't seek if we are not seekable, FIXME could pass the
|
||||||
* seek query upstream after converting it to bytes using
|
* seek query upstream after converting it to bytes using
|
||||||
* the average bitrate of the stream. */
|
* the average bitrate of the stream. */
|
||||||
|
@ -482,12 +488,15 @@ gst_ogg_pad_event (GstPad * pad, GstEvent * event)
|
||||||
|
|
||||||
/* now do the seek */
|
/* now do the seek */
|
||||||
res = gst_ogg_demux_perform_seek (ogg, event);
|
res = gst_ogg_demux_perform_seek (ogg, event);
|
||||||
|
gst_event_unref (event);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
res = gst_pad_event_default (pad, event);
|
res = gst_pad_event_default (pad, event);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
done:
|
||||||
|
gst_object_unref (ogg);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
|
@ -495,7 +504,8 @@ error:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (ogg, "error handling event");
|
GST_DEBUG_OBJECT (ogg, "error handling event");
|
||||||
gst_event_unref (event);
|
gst_event_unref (event);
|
||||||
return FALSE;
|
res = FALSE;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1266,7 +1276,7 @@ static GstOggChain *gst_ogg_demux_read_chain (GstOggDemux * ogg);
|
||||||
static gint gst_ogg_demux_read_end_chain (GstOggDemux * ogg,
|
static gint gst_ogg_demux_read_end_chain (GstOggDemux * ogg,
|
||||||
GstOggChain * chain);
|
GstOggChain * chain);
|
||||||
|
|
||||||
static gboolean gst_ogg_demux_handle_event (GstPad * pad, GstEvent * event);
|
static gboolean gst_ogg_demux_sink_event (GstPad * pad, GstEvent * event);
|
||||||
static void gst_ogg_demux_loop (GstOggPad * pad);
|
static void gst_ogg_demux_loop (GstOggPad * pad);
|
||||||
static GstFlowReturn gst_ogg_demux_chain (GstPad * pad, GstBuffer * buffer);
|
static GstFlowReturn gst_ogg_demux_chain (GstPad * pad, GstBuffer * buffer);
|
||||||
static gboolean gst_ogg_demux_sink_activate (GstPad * sinkpad);
|
static gboolean gst_ogg_demux_sink_activate (GstPad * sinkpad);
|
||||||
|
@ -1314,7 +1324,7 @@ gst_ogg_demux_init (GstOggDemux * ogg, GstOggDemuxClass * g_class)
|
||||||
gst_pad_new_from_static_template (&ogg_demux_sink_template_factory,
|
gst_pad_new_from_static_template (&ogg_demux_sink_template_factory,
|
||||||
"sink");
|
"sink");
|
||||||
|
|
||||||
gst_pad_set_event_function (ogg->sinkpad, gst_ogg_demux_handle_event);
|
gst_pad_set_event_function (ogg->sinkpad, gst_ogg_demux_sink_event);
|
||||||
gst_pad_set_chain_function (ogg->sinkpad, gst_ogg_demux_chain);
|
gst_pad_set_chain_function (ogg->sinkpad, gst_ogg_demux_chain);
|
||||||
gst_pad_set_activate_function (ogg->sinkpad, gst_ogg_demux_sink_activate);
|
gst_pad_set_activate_function (ogg->sinkpad, gst_ogg_demux_sink_activate);
|
||||||
gst_pad_set_activatepull_function (ogg->sinkpad,
|
gst_pad_set_activatepull_function (ogg->sinkpad,
|
||||||
|
@ -1338,25 +1348,33 @@ gst_ogg_demux_finalize (GObject * object)
|
||||||
g_mutex_free (ogg->chain_lock);
|
g_mutex_free (ogg->chain_lock);
|
||||||
ogg_sync_clear (&ogg->sync);
|
ogg_sync_clear (&ogg->sync);
|
||||||
|
|
||||||
if (G_OBJECT_CLASS (parent_class)->finalize)
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_ogg_demux_handle_event (GstPad * pad, GstEvent * event)
|
gst_ogg_demux_sink_event (GstPad * pad, GstEvent * event)
|
||||||
{
|
{
|
||||||
GstOggDemux *ogg = GST_OGG_DEMUX (GST_PAD_PARENT (pad));
|
gboolean res;
|
||||||
|
GstOggDemux *ogg;
|
||||||
|
|
||||||
|
ogg = GST_OGG_DEMUX (gst_pad_get_parent (pad));
|
||||||
|
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
case GST_EVENT_NEWSEGMENT:
|
case GST_EVENT_NEWSEGMENT:
|
||||||
|
/* FIXME */
|
||||||
GST_DEBUG_OBJECT (ogg, "got a new segment event");
|
GST_DEBUG_OBJECT (ogg, "got a new segment event");
|
||||||
ogg_sync_reset (&ogg->sync);
|
ogg_sync_reset (&ogg->sync);
|
||||||
gst_event_unref (event);
|
gst_event_unref (event);
|
||||||
|
res = TRUE;
|
||||||
break;
|
break;
|
||||||
|
case GST_EVENT_EOS:
|
||||||
default:
|
default:
|
||||||
return gst_pad_event_default (pad, event);
|
res = gst_pad_event_default (pad, event);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return TRUE;
|
gst_object_unref (ogg);
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* submit the given buffer to the ogg sync.
|
/* submit the given buffer to the ogg sync.
|
||||||
|
@ -1428,6 +1446,7 @@ error:
|
||||||
{
|
{
|
||||||
GST_WARNING_OBJECT (ogg, "got %d (%s) from pull range", ret,
|
GST_WARNING_OBJECT (ogg, "got %d (%s) from pull range", ret,
|
||||||
gst_flow_get_name (ret));
|
gst_flow_get_name (ret));
|
||||||
|
ogg->chain_error = ret;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1801,6 +1820,7 @@ seek_error:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* does not take ownership of the event */
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_ogg_demux_perform_seek (GstOggDemux * ogg, GstEvent * event)
|
gst_ogg_demux_perform_seek (GstOggDemux * ogg, GstEvent * event)
|
||||||
{
|
{
|
||||||
|
@ -2568,6 +2588,7 @@ gst_ogg_demux_loop (GstOggPad * pad)
|
||||||
|
|
||||||
/* this is the only place where we write chains */
|
/* this is the only place where we write chains */
|
||||||
GST_CHAIN_LOCK (ogg);
|
GST_CHAIN_LOCK (ogg);
|
||||||
|
ogg->chain_error = GST_FLOW_OK;
|
||||||
got_chains = gst_ogg_demux_find_chains (ogg);
|
got_chains = gst_ogg_demux_find_chains (ogg);
|
||||||
GST_CHAIN_UNLOCK (ogg);
|
GST_CHAIN_UNLOCK (ogg);
|
||||||
if (!got_chains)
|
if (!got_chains)
|
||||||
|
@ -2583,6 +2604,8 @@ gst_ogg_demux_loop (GstOggPad * pad)
|
||||||
|
|
||||||
/* and seek to configured positions without FLUSH */
|
/* and seek to configured positions without FLUSH */
|
||||||
gst_ogg_demux_perform_seek (ogg, event);
|
gst_ogg_demux_perform_seek (ogg, event);
|
||||||
|
if (event)
|
||||||
|
gst_event_unref (event);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_LOG_OBJECT (ogg, "pull data %lld", ogg->offset);
|
GST_LOG_OBJECT (ogg, "pull data %lld", ogg->offset);
|
||||||
|
@ -2625,7 +2648,7 @@ gst_ogg_demux_loop (GstOggPad * pad)
|
||||||
chain_read_failed:
|
chain_read_failed:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (ogg, STREAM, DEMUX, (NULL), ("could not read chains"));
|
GST_ELEMENT_ERROR (ogg, STREAM, DEMUX, (NULL), ("could not read chains"));
|
||||||
ret = GST_FLOW_ERROR;
|
ret = ogg->chain_error;
|
||||||
goto pause;
|
goto pause;
|
||||||
}
|
}
|
||||||
pause:
|
pause:
|
||||||
|
|
Loading…
Reference in a new issue