Commit 70fbbf75 authored by Wim Taymans's avatar Wim Taymans
Browse files

ext/ogg/gstoggdemux.c: Clear chains in READY

Original commit message from CVS:
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_submit_packet),
(gst_ogg_demux_activate_chain), (gst_ogg_demux_chain),
(gst_ogg_demux_clear_chains), (gst_ogg_demux_change_state):
Clear chains in READY
Queue packets until the chain is activated.
parent 5474600d
2005-05-26 Wim Taymans <wim@fluendo.com>
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_submit_packet),
(gst_ogg_demux_activate_chain), (gst_ogg_demux_chain),
(gst_ogg_demux_clear_chains), (gst_ogg_demux_change_state):
Clear chains in READY
Queue packets until the chain is activated.
2005-05-25 Wim Taymans <wim@fluendo.com> 2005-05-25 Wim Taymans <wim@fluendo.com>
   
* gst-libs/gst/audio/gstaudiosink.c: * gst-libs/gst/audio/gstaudiosink.c:
......
...@@ -664,12 +664,17 @@ gst_ogg_pad_submit_packet (GstOggPad * pad, ogg_packet * packet) ...@@ -664,12 +664,17 @@ gst_ogg_pad_submit_packet (GstOggPad * pad, ogg_packet * packet)
GST_DEBUG_OBJECT (ogg, GST_DEBUG_OBJECT (ogg,
"%p could not get buffer from peer %08lx, packetno %lld", pad, "%p could not get buffer from peer %08lx, packetno %lld", pad,
pad->serialno, pad->packetno); pad->serialno, pad->packetno);
buf = gst_buffer_new_and_alloc (packet->bytes);
memcpy (buf->data, packet->packet, packet->bytes); /* if we are still building a chain, we have to queue this buffer and
pad->offset = packet->granulepos; * push it when we activate the chain */
GST_BUFFER_OFFSET (buf) = -1; if (ogg->building_chain) {
GST_BUFFER_OFFSET_END (buf) = packet->granulepos; buf = gst_buffer_new_and_alloc (packet->bytes);
pad->headers = g_list_append (pad->headers, buf); memcpy (buf->data, packet->packet, packet->bytes);
pad->offset = packet->granulepos;
GST_BUFFER_OFFSET (buf) = -1;
GST_BUFFER_OFFSET_END (buf) = packet->granulepos;
pad->headers = g_list_append (pad->headers, buf);
}
} }
} else { } else {
/* initialize our internal decoder with packets */ /* initialize our internal decoder with packets */
...@@ -1159,6 +1164,7 @@ static gboolean ...@@ -1159,6 +1164,7 @@ static gboolean
gst_ogg_demux_activate_chain (GstOggDemux * ogg, GstOggChain * chain) gst_ogg_demux_activate_chain (GstOggDemux * ogg, GstOggChain * chain)
{ {
gint i; gint i;
GstFlowReturn ret;
if (chain == ogg->current_chain) if (chain == ogg->current_chain)
return TRUE; return TRUE;
...@@ -1176,7 +1182,9 @@ gst_ogg_demux_activate_chain (GstOggDemux * ogg, GstOggChain * chain) ...@@ -1176,7 +1182,9 @@ gst_ogg_demux_activate_chain (GstOggDemux * ogg, GstOggChain * chain)
for (headers = pad->headers; headers; headers = g_list_next (headers)) { for (headers = pad->headers; headers; headers = g_list_next (headers)) {
GstBuffer *buffer = GST_BUFFER (headers->data); GstBuffer *buffer = GST_BUFFER (headers->data);
gst_pad_push (GST_PAD_CAST (pad), buffer); ret = gst_pad_push (GST_PAD_CAST (pad), buffer);
if (ret != GST_FLOW_OK)
goto flow_error;
} }
} }
gst_element_no_more_pads (GST_ELEMENT (ogg)); gst_element_no_more_pads (GST_ELEMENT (ogg));
...@@ -1184,6 +1192,11 @@ gst_ogg_demux_activate_chain (GstOggDemux * ogg, GstOggChain * chain) ...@@ -1184,6 +1192,11 @@ gst_ogg_demux_activate_chain (GstOggDemux * ogg, GstOggChain * chain)
ogg->current_chain = chain; ogg->current_chain = chain;
return TRUE; return TRUE;
flow_error:
{
return FALSE;
}
} }
static gboolean static gboolean
...@@ -1838,7 +1851,7 @@ gst_ogg_demux_chain (GstPad * pad, GstBuffer * buffer) ...@@ -1838,7 +1851,7 @@ gst_ogg_demux_chain (GstPad * pad, GstBuffer * buffer)
/* see if we know about the chain already */ /* see if we know about the chain already */
chain = gst_ogg_demux_find_chain (ogg, serialno); chain = gst_ogg_demux_find_chain (ogg, serialno);
if (chain) { if (chain) {
/* we do, activate it */ /* we do, activate it as it means we have a non-header */
gst_ogg_demux_activate_chain (ogg, chain); gst_ogg_demux_activate_chain (ogg, chain);
pad = gst_ogg_demux_find_pad (ogg, serialno); pad = gst_ogg_demux_find_pad (ogg, serialno);
} else { } else {
...@@ -1952,6 +1965,23 @@ pause: ...@@ -1952,6 +1965,23 @@ pause:
return; return;
} }
static void
gst_ogg_demux_clear_chains (GstOggDemux * ogg)
{
gint i;
gst_ogg_demux_deactivate_current_chain (ogg);
GST_CHAIN_LOCK (ogg);
for (i = 0; i < ogg->chains->len; i++) {
GstOggChain *chain = g_array_index (ogg->chains, GstOggChain *, i);
gst_ogg_chain_free (chain);
}
ogg->chains = g_array_set_size (ogg->chains, 0);
GST_CHAIN_UNLOCK (ogg);
}
static gboolean static gboolean
gst_ogg_demux_sink_activate (GstPad * sinkpad, GstActivateMode mode) gst_ogg_demux_sink_activate (GstPad * sinkpad, GstActivateMode mode)
{ {
...@@ -2009,6 +2039,7 @@ gst_ogg_demux_change_state (GstElement * element) ...@@ -2009,6 +2039,7 @@ gst_ogg_demux_change_state (GstElement * element)
case GST_STATE_PLAYING_TO_PAUSED: case GST_STATE_PLAYING_TO_PAUSED:
break; break;
case GST_STATE_PAUSED_TO_READY: case GST_STATE_PAUSED_TO_READY:
gst_ogg_demux_clear_chains (ogg);
break; break;
case GST_STATE_READY_TO_NULL: case GST_STATE_READY_TO_NULL:
ogg_sync_clear (&ogg->sync); ogg_sync_clear (&ogg->sync);
......
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