filesink: Remove buffer, deprecate line-buffer mode and don't use fflush()
[platform/upstream/gstreamer.git] / plugins / elements / gstfdsrc.c
index cebca21..6d61efe 100644 (file)
@@ -22,6 +22,7 @@
  */
 /**
  * SECTION:element-fdsrc
+ * @title: fdsrc
  * @see_also: #GstFdSink
  *
  * Read data from a unix file descriptor.
  * if no data was received in the given timeout.
  *
  * The message's structure contains one field:
- * <itemizedlist>
- * <listitem>
- *   <para>
- *   #guint64
- *   <classname>&quot;timeout&quot;</classname>: the timeout in microseconds that
+ *
+ * * #guint64 `timeout`: the timeout in microseconds that
  *   expired when waiting for data.
- *   </para>
- * </listitem>
- * </itemizedlist>
  *
- * <refsect2>
- * <title>Example launch line</title>
+ * ## Example launch line
  * |[
  * echo "Hello GStreamer" | gst-launch-1.0 -v fdsrc ! fakesink dump=true
  * ]| A simple pipeline to read from the standard input and dump the data
  * with a fakesink as hex ascii block.
- * </refsect2>
+ *
  */
 
 #ifdef HAVE_CONFIG_H
@@ -64,8 +58,6 @@
 #include <io.h>                 /* lseek, open, close, read */
 #undef lseek
 #define lseek _lseeki64
-#undef off_t
-#define off_t guint64
 #endif
 
 #include <sys/stat.h>
 
 #include "gstfdsrc.h"
 
+#ifdef __BIONIC__               /* Android */
+#if defined(__ANDROID_API__) && __ANDROID_API__ >= 21
+#undef fstat
+#define fstat fstat64
+#endif
+#endif
+
 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
@@ -169,8 +168,7 @@ gst_fd_src_class_init (GstFdSrcClass * klass)
       "Filedescriptor Source",
       "Source/File",
       "Read from a file descriptor", "Erik Walthinsen <omega@cse.ogi.edu>");
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&srctemplate));
+  gst_element_class_add_static_pad_template (gstelement_class, &srctemplate);
 
   gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_fd_src_start);
   gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_fd_src_stop);
@@ -441,7 +439,8 @@ gst_fd_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
   if (G_UNLIKELY (buf == NULL))
     goto alloc_failed;
 
-  gst_buffer_map (buf, &info, GST_MAP_WRITE);
+  if (!gst_buffer_map (buf, &info, GST_MAP_WRITE))
+    goto buffer_read_error;
 
   do {
     readbytes = read (src->fd, info.data, blocksize);
@@ -503,6 +502,12 @@ read_error:
     gst_buffer_unref (buf);
     return GST_FLOW_ERROR;
   }
+buffer_read_error:
+  {
+    GST_ELEMENT_ERROR (src, RESOURCE, WRITE, (NULL), ("Can't write to buffer"));
+    gst_buffer_unref (buf);
+    return GST_FLOW_ERROR;
+  }
 }
 
 static gboolean