GNOME Bugzilla – Bug 547277
filesrc detect if a file is seekable using SEEK_SET and not SEEK_END
Last modified: 2008-08-19 17:25:18 UTC
Under windows playing a matroska file of 4695522630 bytes fails as filesrc thinks that the file is not seekable. Filesrc uses this code to determine if a file is seekable: off_t res = lseek (src->fd, 0, SEEK_END); if (res < 0) { GST_LOG_OBJECT (src, "disabling seeking, not in mmap mode and lseek " "failed: %s", g_strerror (errno)); src->seekable = FALSE; } else { src->seekable = TRUE; } In windows with such matroska file lseek fails with Invalid argument. Changing the lseek call to lseek (src->fd, stat_results.st_size, SEEK_SET) works.
Created attachment 116337 [details] [review] Change lseek to work under windows
Created attachment 116368 [details] [review] Add large file support
Ok it seems it was a more general issue. Under linux, glibc uses lseek64 lstat64 etc automatically if the kernel supports large files. In windows the 64 bit variants have to be used explicitly. With the patch applied, I can play and seek in a matroska file big 4695522630 bytes. With only the first (broken) patch I couldn't seek as lseek was failing.
Code looks fine. Before committing, please add a comment explaining that this is because these functions default to 32-bit-only on windows, and perhaps something explaining what #undef _INC_STAT_INL is all about - I have no idea what that's for.
the #undef _INC_STAT_INL is so that stat.h doesn't alias stat*() to _stat*() and so I don't have to #undef stat*() one by one.
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.