gst-plugins-bad: dvbsrc: pass the reason for failed read as GstFlowReturn
Wim Taymans
wtay at kemper.freedesktop.org
Fri Apr 20 06:42:41 PDT 2012
Module: gst-plugins-bad
Branch: master
Commit: a8af5334eb8cad352b0ffa7901a0222082e9227b
URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=a8af5334eb8cad352b0ffa7901a0222082e9227b
Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date: Fri Apr 20 15:05:36 2012 +0200
dvbsrc: pass the reason for failed read as GstFlowReturn
Make the _read_device function return a GstFlowReturn so that we can propagate
this to the caller. This allows us to differentiate between poll errors and
flushing state.
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=674219
---
sys/dvb/gstdvbsrc.c | 40 +++++++++++++++++++++-------------------
1 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/sys/dvb/gstdvbsrc.c b/sys/dvb/gstdvbsrc.c
index c13f336..3fd7963 100644
--- a/sys/dvb/gstdvbsrc.c
+++ b/sys/dvb/gstdvbsrc.c
@@ -897,8 +897,8 @@ gst_dvbsrc_plugin_init (GstPlugin * plugin)
GST_TYPE_DVBSRC);
}
-static GstBuffer *
-gst_dvbsrc_read_device (GstDvbSrc * object, int size)
+static GstFlowReturn
+gst_dvbsrc_read_device (GstDvbSrc * object, int size, GstBuffer ** buffer)
{
gint count = 0;
gint ret_val = 0;
@@ -906,10 +906,10 @@ gst_dvbsrc_read_device (GstDvbSrc * object, int size)
GstClockTime timeout = object->timeout * GST_USECOND;
GstMapInfo map;
- g_return_val_if_fail (GST_IS_BUFFER (buf), NULL);
+ g_return_val_if_fail (GST_IS_BUFFER (buf), GST_FLOW_ERROR);
if (object->fd_dvr < 0)
- return NULL;
+ return GST_FLOW_ERROR;
gst_buffer_map (buf, &map, GST_MAP_WRITE);
while (count < size) {
@@ -943,20 +943,25 @@ gst_dvbsrc_read_device (GstDvbSrc * object, int size)
gst_buffer_unmap (buf, &map);
gst_buffer_resize (buf, 0, count);
- return buf;
+ *buffer = buf;
-stopped:
- GST_DEBUG_OBJECT (object, "stop called");
- gst_buffer_unmap (buf, &map);
- gst_buffer_unref (buf);
- return NULL;
+ return GST_FLOW_OK;
+stopped:
+ {
+ GST_DEBUG_OBJECT (object, "stop called");
+ gst_buffer_unmap (buf, &map);
+ gst_buffer_unref (buf);
+ return GST_FLOW_WRONG_STATE;
+ }
select_error:
- GST_ELEMENT_ERROR (object, RESOURCE, READ, (NULL),
- ("select error %d: %s (%d)", ret_val, g_strerror (errno), errno));
- gst_buffer_unmap (buf, &map);
- gst_buffer_unref (buf);
- return NULL;
+ {
+ GST_ELEMENT_ERROR (object, RESOURCE, READ, (NULL),
+ ("select error %d: %s (%d)", ret_val, g_strerror (errno), errno));
+ gst_buffer_unmap (buf, &map);
+ gst_buffer_unref (buf);
+ return GST_FLOW_ERROR;
+ }
}
static GstFlowReturn
@@ -979,10 +984,7 @@ gst_dvbsrc_create (GstPushSrc * element, GstBuffer ** buf)
if (object->fd_dvr > -1) {
/* --- Read TS from DVR device --- */
GST_DEBUG_OBJECT (object, "Reading from DVR device");
- *buf = gst_dvbsrc_read_device (object, buffer_size);
- if (*buf != NULL) {
- retval = GST_FLOW_OK;
- }
+ retval = gst_dvbsrc_read_device (object, buffer_size, buf);
if (object->stats_interval != 0 &&
++object->stats_counter == object->stats_interval) {
More information about the gstreamer-commits
mailing list