[gst-cvs] gstreamer: win32: fix seeking in files >4GB

Wim Taymans wtay at kemper.freedesktop.org
Fri Mar 20 06:14:26 PDT 2009


Module: gstreamer
Branch: master
Commit: ef5be3788204b795bd9004ae0f7e4d525c172cff
URL:    http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=ef5be3788204b795bd9004ae0f7e4d525c172cff

Author: LRN <lrn1986 at gmail dot com>
Date:   Fri Mar 20 14:12:55 2009 +0100

win32: fix seeking in files >4GB

Use 64-bit functions on windows to implement seeking in files bigger
than 4GB.
Fixes #575988

---

 plugins/elements/gstfdsink.c   |    9 +++++++++
 plugins/elements/gstfdsrc.c    |    9 +++++++++
 plugins/elements/gstfilesink.c |   19 ++++++++++++++-----
 3 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/plugins/elements/gstfdsink.c b/plugins/elements/gstfdsink.c
index 203afa0..ace6777 100644
--- a/plugins/elements/gstfdsink.c
+++ b/plugins/elements/gstfdsink.c
@@ -40,6 +40,15 @@
 #include "../../gst/gst-i18n-lib.h"
 
 #include <sys/types.h>
+
+#ifdef G_OS_WIN32
+#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 <sys/socket.h>
 #include <fcntl.h>
diff --git a/plugins/elements/gstfdsrc.c b/plugins/elements/gstfdsrc.c
index 37c0f07..fee6901 100644
--- a/plugins/elements/gstfdsrc.c
+++ b/plugins/elements/gstfdsrc.c
@@ -61,6 +61,15 @@
 #include "gst/gst_private.h"
 
 #include <sys/types.h>
+
+#ifdef G_OS_WIN32
+#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 <sys/socket.h>
 #include <fcntl.h>
diff --git a/plugins/elements/gstfilesink.c b/plugins/elements/gstfilesink.c
index 92abe6e..b540940 100644
--- a/plugins/elements/gstfilesink.c
+++ b/plugins/elements/gstfilesink.c
@@ -41,8 +41,17 @@
 #include <errno.h>
 #include "gstfilesink.h"
 #include <string.h>
-#include <sys/stat.h>
 #include <sys/types.h>
+
+#ifdef G_OS_WIN32
+#include <io.h>                 /* lseek, open, close, read */
+#undef lseek
+#define lseek _lseeki64
+#undef off_t
+#define off_t guint64
+#endif
+
+#include <sys/stat.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
@@ -421,7 +430,7 @@ gst_file_sink_query (GstPad * pad, GstQuery * query)
 
 #ifdef HAVE_FSEEKO
 # define __GST_STDIO_SEEK_FUNCTION "fseeko"
-#elif defined (G_OS_UNIX)
+#elif defined (G_OS_UNIX) || defined (G_OS_WIN32)
 # define __GST_STDIO_SEEK_FUNCTION "lseek"
 #else
 # define __GST_STDIO_SEEK_FUNCTION "fseek"
@@ -439,7 +448,7 @@ gst_file_sink_do_seek (GstFileSink * filesink, guint64 new_offset)
 #ifdef HAVE_FSEEKO
   if (fseeko (filesink->file, (off_t) new_offset, SEEK_SET) != 0)
     goto seek_failed;
-#elif defined (G_OS_UNIX)
+#elif defined (G_OS_UNIX) || defined (G_OS_WIN32)
   if (lseek (fileno (filesink->file), (off_t) new_offset,
           SEEK_SET) == (off_t) - 1)
     goto seek_failed;
@@ -537,11 +546,11 @@ flush_failed:
 static gboolean
 gst_file_sink_get_current_offset (GstFileSink * filesink, guint64 * p_pos)
 {
-  off_t ret;
+  off_t ret = -1;
 
 #ifdef HAVE_FTELLO
   ret = ftello (filesink->file);
-#elif defined (G_OS_UNIX)
+#elif defined (G_OS_UNIX) || defined (G_OS_WIN32)
   if (fflush (filesink->file)) {
     GST_DEBUG_OBJECT (filesink, "Flush failed: %s", g_strerror (errno));
     /* ignore and continue */





More information about the Gstreamer-commits mailing list