From: Alessandro Decina Date: Tue, 19 Aug 2008 17:23:18 +0000 (+0000) Subject: plugins/elements/gstfilesrc.c: Use 64 bit variants of stat functions on win32, to... X-Git-Tag: RELEASE-0_10_21~37 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9693804ba5b0e9d2ad62eb8148546cc4a4a2073b;p=platform%2Fupstream%2Fgstreamer.git 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 * plugins/elements/gstfilesrc.c: Use 64 bit variants of stat functions on win32, to enable support of large files there. Fixes #547277. --- diff --git a/ChangeLog b/ChangeLog index 18a2e39..0287fe4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-08-19 Michael Smith + + Patch by: Alessandro Decina + * 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 * libs/gst/base/gstbasesink.c: (gst_base_sink_render_object), diff --git a/plugins/elements/gstfilesrc.c b/plugins/elements/gstfilesrc.c index a01e610..cf3d5aa 100644 --- a/plugins/elements/gstfilesrc.c +++ b/plugins/elements/gstfilesrc.c @@ -35,6 +35,20 @@ #include #include +#ifdef G_OS_WIN32 +#include /* 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 #include @@ -46,10 +60,6 @@ # include #endif -#ifdef HAVE_WIN32 -# include /* lseek, open, close, read */ -#endif - #include #include @@ -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)