+2005-10-23 Tim-Philipp Müller <tim at centricular dot net>
+
+ * gst/elements/gstfilesink.c: (gst_file_sink_do_seek),
+ (gst_file_sink_get_current_offset):
+ Use fseeko() and ftello() if available. When falling back on
+ lseek() to get the current offset, fflush() first to make sure
+ everything is up-to-date and we get the right offset.
+
2005-10-23 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/base/gstbasesink.c: (gst_base_sink_handle_object):
}
}
+#if HAVE_FSEEKO
+# define __GST_STDIO_SEEK_FUNCTION "fseeko"
+#elif G_OS_UNIX
+# define __GST_STDIO_SEEK_FUNCTION "lseek"
+#else
+# define __GST_STDIO_SEEK_FUNCTION "fseek"
+#endif
+
static void
gst_file_sink_do_seek (GstFileSink * filesink, guint64 new_offset)
{
- GST_DEBUG_OBJECT (filesink, "Seeking to offset %" G_GUINT64_FORMAT,
- new_offset);
+ GST_DEBUG_OBJECT (filesink, "Seeking to offset %" G_GUINT64_FORMAT
+ " using " __GST_STDIO_SEEK_FUNCTION, new_offset);
if (fflush (filesink->file))
goto flush_failed;
-#ifdef G_OS_UNIX
+#if HAVE_FSEEKO
+ if (fseeko (filesink->file, (off_t) new_offset, SEEK_SET) != 0)
+ goto seek_failed;
+#elif G_OS_UNIX
if (lseek (fileno (filesink->file), (off_t) new_offset,
SEEK_SET) == (off_t) - 1)
goto seek_failed;
{
off_t ret;
-#ifdef G_OS_UNIX
+#if HAVE_FTELLO
+ ret = ftello (filesink->file);
+#elif G_OS_UNIX
+ if (fflush (filesink->file)) {
+ GST_DEBUG_OBJECT (filesink, "Flush failed: %s", g_strerror (errno));
+ /* ignore and continue */
+ }
ret = lseek (fileno (filesink->file), 0, SEEK_CUR);
#else
ret = (off_t) ftell (filesink->file);
}
}
+#if HAVE_FSEEKO
+# define __GST_STDIO_SEEK_FUNCTION "fseeko"
+#elif G_OS_UNIX
+# define __GST_STDIO_SEEK_FUNCTION "lseek"
+#else
+# define __GST_STDIO_SEEK_FUNCTION "fseek"
+#endif
+
static void
gst_file_sink_do_seek (GstFileSink * filesink, guint64 new_offset)
{
- GST_DEBUG_OBJECT (filesink, "Seeking to offset %" G_GUINT64_FORMAT,
- new_offset);
+ GST_DEBUG_OBJECT (filesink, "Seeking to offset %" G_GUINT64_FORMAT
+ " using " __GST_STDIO_SEEK_FUNCTION, new_offset);
if (fflush (filesink->file))
goto flush_failed;
-#ifdef G_OS_UNIX
+#if HAVE_FSEEKO
+ if (fseeko (filesink->file, (off_t) new_offset, SEEK_SET) != 0)
+ goto seek_failed;
+#elif G_OS_UNIX
if (lseek (fileno (filesink->file), (off_t) new_offset,
SEEK_SET) == (off_t) - 1)
goto seek_failed;
{
off_t ret;
-#ifdef G_OS_UNIX
+#if HAVE_FTELLO
+ ret = ftello (filesink->file);
+#elif G_OS_UNIX
+ if (fflush (filesink->file)) {
+ GST_DEBUG_OBJECT (filesink, "Flush failed: %s", g_strerror (errno));
+ /* ignore and continue */
+ }
ret = lseek (fileno (filesink->file), 0, SEEK_CUR);
#else
ret = (off_t) ftell (filesink->file);