+2008-08-19 Michael Smith <msmith@songbirdnest.com>
+
+ Patch by: Alessandro Decina <alessandro@nnva.org>
+ * plugins/elements/gstfilesrc.c:
+ Use 64 bit variants of stat functions on win32, to enable support
+ of large files there.
+ Fixes #547277.
+
2008-08-19 Wim Taymans <wim.taymans@collabora.co.uk>
* libs/gst/base/gstbasesink.c: (gst_base_sink_render_object),
#include <stdio.h>
#include <sys/types.h>
+#ifdef G_OS_WIN32
+#include <io.h> /* lseek, open, close, read */
+/* On win32, stat* default to 32 bit; we need the 64-bit
+ * variants, so explicitly define it that way. */
+#define stat __stat64
+#define fstat _fstat64
+#undef lseek
+#define lseek _lseeki64
+#undef off_t
+#define off_t guint64
+/* Prevent stat.h from defining the stat* functions as
+ * _stat*, since we're explicitly overriding that */
+#undef _INC_STAT_INL
+#endif
#include <sys/stat.h>
#include <fcntl.h>
# include <sys/mman.h>
#endif
-#ifdef HAVE_WIN32
-# include <io.h> /* lseek, open, close, read */
-#endif
-
#include <errno.h>
#include <string.h>
#define O_BINARY (0)
#endif
+/* Copy of glib's g_open due to win32 libc/cross-DLL brokenness: we can't
+ * use the 'file descriptor' opened in glib (and returned from this function)
+ * in this library, as they may have unrelated C runtimes. */
+int
+gst_open (const gchar * filename, int flags, int mode)
+{
+#ifdef G_OS_WIN32
+ wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
+ int retval;
+ int save_errno;
+
+ if (wfilename == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ retval = _wopen (wfilename, flags, mode);
+ save_errno = errno;
+
+ g_free (wfilename);
+
+ errno = save_errno;
+ return retval;
+#else
+ return open (filename, flags, mode);
+#endif
+}
+
/**********************************************************************
* GStreamer Default File Source
GST_INFO_OBJECT (src, "opening file %s", src->filename);
/* open the file */
- src->fd = open (src->filename, O_RDONLY | O_BINARY);
+ src->fd = gst_open (src->filename, O_RDONLY | O_BINARY, 0);
if (src->fd < 0)
goto open_failed;
return TRUE;
} else {
location = gst_uri_get_location (uri);
+ GST_LOG_OBJECT (src, "Location '%s' found from uri '%s'", location, uri);
}
if (!location)