plugins/elements/gstfilesrc.c: Use 64 bit variants of stat functions on win32, to enable support of large files there.

Original commit message from CVS:
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.
This commit is contained in:
Alessandro Decina 2008-08-19 17:23:18 +00:00 committed by Michael Smith
parent e93b94afdf
commit 9693804ba5
2 changed files with 52 additions and 5 deletions

View file

@ -1,3 +1,11 @@
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),

View file

@ -35,6 +35,20 @@
#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>
@ -46,10 +60,6 @@
# include <sys/mman.h>
#endif
#ifdef HAVE_WIN32
# include <io.h> /* lseek, open, close, read */
#endif
#include <errno.h>
#include <string.h>
@ -74,6 +84,34 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
#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
@ -909,7 +947,7 @@ gst_file_src_start (GstBaseSrc * basesrc)
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;
@ -1086,6 +1124,7 @@ gst_file_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
return TRUE;
} else {
location = gst_uri_get_location (uri);
GST_LOG_OBJECT (src, "Location '%s' found from uri '%s'", location, uri);
}
if (!location)