summaryrefslogtreecommitdiffstats
path: root/ext/dv
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2006-05-24 16:03:40 +0000
committerWim Taymans <wim.taymans@gmail.com>2006-05-24 16:03:40 +0000
commit8d05a0f266d26059f1972d871aa1b1d3e2fdd752 (patch)
tree6de802d6e6617bd9b6b623d68e39a4219f6c6f2a /ext/dv
parente34cbad0658d931241dae14b78ba514707b089eb (diff)
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
Diffstat (limited to 'ext/dv')
-rw-r--r--ext/dv/gstdvdemux.c50
1 files changed, 32 insertions, 18 deletions
diff --git a/ext/dv/gstdvdemux.c b/ext/dv/gstdvdemux.c
index 55a41251..890e65e1 100644
--- a/ext/dv/gstdvdemux.c
+++ b/ext/dv/gstdvdemux.c
@@ -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;
+ dvdemux->running = FALSE;
+ gst_pad_pause_task (dvdemux->sinkpad);
+ gst_dvdemux_push_event (dvdemux, gst_event_new_eos ());
+ goto done;
}
-eos:
+small_buffer:
{
- GST_LOG_OBJECT (dvdemux, "got eos");
+ 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 ());
- /* pause with non-fatal error */
- ret = GST_FLOW_WRONG_STATE;
- goto pause;
+ 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;
}
}