ext/dv/gstdvdemux.c: Implement EOS correctly by either posting

Original commit message from CVS:
* ext/dv/gstdvdemux.c: (gst_dvdemux_loop):
Implement EOS correctly by either posting
SEGMENT_DONE or pushing an EOS message depending
on the seek type. Fixes #342592
This commit is contained in:
Wim Taymans 2006-05-24 16:03:40 +00:00
parent e34cbad065
commit 8d05a0f266
2 changed files with 41 additions and 20 deletions

View file

@ -1,3 +1,10 @@
2006-05-24 Wim Taymans <wim@fluendo.com>
* ext/dv/gstdvdemux.c: (gst_dvdemux_loop):
Implement EOS correctly by either posting
SEGMENT_DONE or pushing an EOS message depending
on the seek type. Fixes #342592
2006-05-24 Wim Taymans <wim@fluendo.com>
* gst/law/alaw-decode.c: (gst_alawdec_chain):

View file

@ -1547,7 +1547,7 @@ gst_dvdemux_loop (GstPad * pad)
/* check buffer size, don't want to read small buffers */
if (G_UNLIKELY (GST_BUFFER_SIZE (buffer) < NTSC_BUFFER))
goto pause;
goto small_buffer;
data = GST_BUFFER_DATA (buffer);
@ -1609,15 +1609,12 @@ gst_dvdemux_loop (GstPad * pad)
ret = gst_pad_pull_range (dvdemux->sinkpad,
dvdemux->byte_segment.last_stop, dvdemux->frame_len, &buffer);
if (ret == GST_FLOW_UNEXPECTED)
goto eos;
if (ret != GST_FLOW_OK)
goto pause;
/* check buffer size, don't want to read small buffers */
if (GST_BUFFER_SIZE (buffer) < dvdemux->frame_len)
goto pause;
goto small_buffer;
}
/* and decode the buffer */
ret = gst_dvdemux_demux_frame (dvdemux, buffer);
@ -1627,6 +1624,7 @@ gst_dvdemux_loop (GstPad * pad)
/* and position ourselves for the next buffer */
dvdemux->byte_segment.last_stop += dvdemux->frame_len;
done:
gst_object_unref (dvdemux);
return;
@ -1637,17 +1635,20 @@ parse_header_error:
GST_ELEMENT_ERROR (dvdemux, STREAM, DECODE,
(NULL), ("Error parsing DV header"));
gst_buffer_unref (buffer);
ret = GST_FLOW_ERROR;
/* will stop the task */
goto pause;
}
eos:
{
GST_LOG_OBJECT (dvdemux, "got eos");
dvdemux->running = FALSE;
gst_pad_pause_task (dvdemux->sinkpad);
gst_dvdemux_push_event (dvdemux, gst_event_new_eos ());
/* pause with non-fatal error */
ret = GST_FLOW_WRONG_STATE;
goto pause;
goto done;
}
small_buffer:
{
GST_ELEMENT_ERROR (dvdemux, STREAM, DECODE,
(NULL), ("Error reading buffer"));
gst_buffer_unref (buffer);
dvdemux->running = FALSE;
gst_pad_pause_task (dvdemux->sinkpad);
gst_dvdemux_push_event (dvdemux, gst_event_new_eos ());
goto done;
}
pause:
{
@ -1655,12 +1656,25 @@ pause:
dvdemux->running = FALSE;
gst_pad_pause_task (dvdemux->sinkpad);
if (GST_FLOW_IS_FATAL (ret)) {
/* for fatal errors we post an error message */
GST_ELEMENT_ERROR (dvdemux, STREAM, FAILED,
(NULL), ("streaming stopped, reason %s", gst_flow_get_name (ret)));
gst_dvdemux_push_event (dvdemux, gst_event_new_eos ());
if (ret == GST_FLOW_UNEXPECTED) {
GST_LOG_OBJECT (dvdemux, "got eos");
/* perform EOS logic */
if (dvdemux->time_segment.flags & GST_SEEK_FLAG_SEGMENT) {
gst_element_post_message (GST_ELEMENT (dvdemux),
gst_message_new_segment_done (GST_OBJECT_CAST (dvdemux),
dvdemux->time_segment.format,
dvdemux->time_segment.last_stop));
} else {
gst_dvdemux_push_event (dvdemux, gst_event_new_eos ());
}
} else {
/* for fatal errors we post an error message */
GST_ELEMENT_ERROR (dvdemux, STREAM, FAILED,
(NULL), ("streaming stopped, reason %s", gst_flow_get_name (ret)));
gst_dvdemux_push_event (dvdemux, gst_event_new_eos ());
}
}
gst_object_unref (dvdemux);
goto done;
}
}