mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-22 14:06:23 +00:00
gst/elements/gstfilesink.c: Use fseeko() and ftello() if available. When falling back on lseek() to get the current o...
Original commit message from CVS: * 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.
This commit is contained in:
parent
013e3acc3d
commit
7d5fda88d4
3 changed files with 50 additions and 8 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
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>
|
2005-10-23 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
* gst/base/gstbasesink.c: (gst_base_sink_handle_object):
|
* gst/base/gstbasesink.c: (gst_base_sink_handle_object):
|
||||||
|
|
|
@ -298,16 +298,27 @@ gst_file_sink_query (GstPad * pad, GstQuery * query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#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
|
static void
|
||||||
gst_file_sink_do_seek (GstFileSink * filesink, guint64 new_offset)
|
gst_file_sink_do_seek (GstFileSink * filesink, guint64 new_offset)
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (filesink, "Seeking to offset %" G_GUINT64_FORMAT,
|
GST_DEBUG_OBJECT (filesink, "Seeking to offset %" G_GUINT64_FORMAT
|
||||||
new_offset);
|
" using " __GST_STDIO_SEEK_FUNCTION, new_offset);
|
||||||
|
|
||||||
if (fflush (filesink->file))
|
if (fflush (filesink->file))
|
||||||
goto flush_failed;
|
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,
|
if (lseek (fileno (filesink->file), (off_t) new_offset,
|
||||||
SEEK_SET) == (off_t) - 1)
|
SEEK_SET) == (off_t) - 1)
|
||||||
goto seek_failed;
|
goto seek_failed;
|
||||||
|
@ -377,7 +388,13 @@ gst_file_sink_get_current_offset (GstFileSink * filesink, guint64 * p_pos)
|
||||||
{
|
{
|
||||||
off_t ret;
|
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);
|
ret = lseek (fileno (filesink->file), 0, SEEK_CUR);
|
||||||
#else
|
#else
|
||||||
ret = (off_t) ftell (filesink->file);
|
ret = (off_t) ftell (filesink->file);
|
||||||
|
|
|
@ -298,16 +298,27 @@ gst_file_sink_query (GstPad * pad, GstQuery * query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#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
|
static void
|
||||||
gst_file_sink_do_seek (GstFileSink * filesink, guint64 new_offset)
|
gst_file_sink_do_seek (GstFileSink * filesink, guint64 new_offset)
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (filesink, "Seeking to offset %" G_GUINT64_FORMAT,
|
GST_DEBUG_OBJECT (filesink, "Seeking to offset %" G_GUINT64_FORMAT
|
||||||
new_offset);
|
" using " __GST_STDIO_SEEK_FUNCTION, new_offset);
|
||||||
|
|
||||||
if (fflush (filesink->file))
|
if (fflush (filesink->file))
|
||||||
goto flush_failed;
|
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,
|
if (lseek (fileno (filesink->file), (off_t) new_offset,
|
||||||
SEEK_SET) == (off_t) - 1)
|
SEEK_SET) == (off_t) - 1)
|
||||||
goto seek_failed;
|
goto seek_failed;
|
||||||
|
@ -377,7 +388,13 @@ gst_file_sink_get_current_offset (GstFileSink * filesink, guint64 * p_pos)
|
||||||
{
|
{
|
||||||
off_t ret;
|
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);
|
ret = lseek (fileno (filesink->file), 0, SEEK_CUR);
|
||||||
#else
|
#else
|
||||||
ret = (off_t) ftell (filesink->file);
|
ret = (off_t) ftell (filesink->file);
|
||||||
|
|
Loading…
Reference in a new issue