diff options
author | David Schleef <ds@schleef.org> | 2008-02-08 03:44:12 +0000 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2008-02-08 03:44:12 +0000 |
commit | c8ae2ad1caf40a3c15261c2d9600b0b2f883235e (patch) | |
tree | 22efe0ce1913ffcd1a8c64d8876d0cffa7b86363 /gst/multifile/gstmultifilesrc.c | |
parent | 819b139e4e36f8ce3d70acdbcaaec770365de669 (diff) | |
download | gst-plugins-bad-c8ae2ad1caf40a3c15261c2d9600b0b2f883235e.tar.gz gst-plugins-bad-c8ae2ad1caf40a3c15261c2d9600b0b2f883235e.tar.bz2 gst-plugins-bad-c8ae2ad1caf40a3c15261c2d9600b0b2f883235e.zip |
gst/multifile/: Use g_file_[sg]et_contents() instead of using stdio functions.
Original commit message from CVS:
* gst/multifile/gstmultifilesink.c:
* gst/multifile/gstmultifilesrc.c:
Use g_file_[sg]et_contents() instead of using stdio functions.
Should be less error prone.
* tests/check/elements/multifile.c:
Create a temporary directory using standard functions instead of
creating a directory in the current dir.
Diffstat (limited to 'gst/multifile/gstmultifilesrc.c')
-rw-r--r-- | gst/multifile/gstmultifilesrc.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/gst/multifile/gstmultifilesrc.c b/gst/multifile/gstmultifilesrc.c index f2de1b86..4a30a050 100644 --- a/gst/multifile/gstmultifilesrc.c +++ b/gst/multifile/gstmultifilesrc.c @@ -77,7 +77,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_multi_file_src_debug); static const GstElementDetails gst_multi_file_src_details = GST_ELEMENT_DETAILS ("Multi-File Source", "Source/File", - "Read stream from files", + "Read a sequentially named set of files into buffers", "David Schleef <ds@schleef.org>"); enum @@ -267,10 +267,11 @@ gst_multi_file_src_create (GstPushSrc * src, GstBuffer ** buffer) { GstMultiFileSrc *multifilesrc; guint size; + gchar *data; gchar *filename; - FILE *file; GstBuffer *buf; - int ret; + gboolean ret; + GError *error = NULL; multifilesrc = GST_MULTI_FILE_SRC (src); @@ -278,8 +279,8 @@ gst_multi_file_src_create (GstPushSrc * src, GstBuffer ** buffer) GST_DEBUG_OBJECT (multifilesrc, "reading from file \"%s\".", filename); - file = fopen (filename, "rb"); - if (!file) { + ret = g_file_get_contents (filename, &data, &size, &error); + if (!ret) { if (multifilesrc->successful_read) { /* If we've read at least one buffer successfully, not finding the * next file is EOS. */ @@ -290,20 +291,11 @@ gst_multi_file_src_create (GstPushSrc * src, GstBuffer ** buffer) } } - fseek (file, 0, SEEK_END); - size = ftell (file); - fseek (file, 0, SEEK_SET); - - buf = gst_buffer_new_and_alloc (size); - - ret = fread (GST_BUFFER_DATA (buf), size, 1, file); - if (ret < 1) { - goto handle_error; - } - multifilesrc->successful_read = TRUE; multifilesrc->index++; + buf = gst_buffer_new (); + GST_BUFFER_DATA (buf) = (unsigned char *) data; GST_BUFFER_SIZE (buf) = size; GST_BUFFER_OFFSET (buf) = multifilesrc->offset; GST_BUFFER_OFFSET_END (buf) = multifilesrc->offset + size; @@ -312,7 +304,6 @@ gst_multi_file_src_create (GstPushSrc * src, GstBuffer ** buffer) GST_DEBUG_OBJECT (multifilesrc, "read file \"%s\".", filename); - fclose (file); g_free (filename); *buffer = buf; return GST_FLOW_OK; |