configure.ac: Use AC_SYS_LARGEFILE, which will set _FILE_OFFSET_BITS=64 and _LARGEFILE_SOURCE in config.h as required...

Original commit message from CVS:
* configure.ac:
Use AC_SYS_LARGEFILE, which will set _FILE_OFFSET_BITS=64
and _LARGEFILE_SOURCE in config.h as required. Do not
export those flags in our .pc files any longer (#142209).
Remove unused GST_DISABLE_OMEGA_COTHREADS stuff.
* gst/elements/gstfilesink.c: (gst_file_sink_class_init),
(gst_file_sink_do_seek), (gst_file_sink_event),
(gst_file_sink_get_current_offset), (gst_file_sink_render):
Redo seek/tell calls with large file support in mind; add some
debugging messages; add log message that tells us when large
file support is unavailable or not enabled for some reason.
* gst/elements/gstfilesrc.c: (gst_file_src_class_init):
Add log message that tells us when large file support
is unavailable or not enabled for some reason.
This commit is contained in:
Tim-Philipp Müller 2005-07-30 15:00:07 +00:00
parent afbe734024
commit 96e954852f
6 changed files with 147 additions and 64 deletions

View file

@ -1,3 +1,23 @@
2005-07-30 Tim-Philipp Müller <tim at centricular dot net>
* configure.ac:
Use AC_SYS_LARGEFILE, which will set _FILE_OFFSET_BITS=64
and _LARGEFILE_SOURCE in config.h as required. Do not
export those flags in our .pc files any longer (#142209).
Remove unused GST_DISABLE_OMEGA_COTHREADS stuff.
* gst/elements/gstfilesink.c: (gst_file_sink_class_init),
(gst_file_sink_do_seek), (gst_file_sink_event),
(gst_file_sink_get_current_offset), (gst_file_sink_render):
Redo seek/tell calls with large file support in mind; add some
debugging messages; add log message that tells us when large
file support is unavailable or not enabled for some reason.
* gst/elements/gstfilesrc.c: (gst_file_src_class_init):
Add log message that tells us when large file support
is unavailable or not enabled for some reason.
2005-07-29 Wim Taymans <wim@fluendo.com>
* check/gst/gstghostpad.c: (GST_START_TEST), (gst_ghost_pad_suite):

View file

@ -1,3 +1,5 @@
AC_PREREQ(2.52)
AC_INIT
AC_CANONICAL_TARGET
@ -147,41 +149,12 @@ if test x$FLEX_PATH = xno; then
AC_MSG_ERROR(Could not find flex)
fi
dnl
dnl We should really use AC_SYS_LARGEFILE, but the problem is
dnl many of the plugins don't include "config.h". To assure
dnl binary compatibility, it is necessary that all gstreamer
dnl code be compiled with the same sizeof(off_t), so we use
dnl the following crude hack.
dnl
AC_MSG_CHECKING(for large file support)
AC_TRY_RUN([
#define _LARGEFILE_SOURCE
#define _FILE_OFFSET_BITS 64
#include <sys/types.h>
int main () { return !(sizeof(off_t) == 8); }
],
[
AC_MSG_RESULT(yes)
GST_PKG_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
],
[
AC_MSG_RESULT(no)
],
[
AC_MSG_RESULT(no)
])
dnl check for large file support (affected
dnl plugins must include config.h for this)
AC_SYS_LARGEFILE
dnl check for mmap
AC_FUNC_MMAP()
if test "$ac_cv_func_mmap_fixed_mapped" = "yes" ; then
GST_DISABLE_OMEGA_COTHREADS=no
else
GST_DISABLE_OMEGA_COTHREADS=yes
fi
dnl for future --disabling, maybe. Right now, it depends on HAVE_MMAP
AM_CONDITIONAL(GST_DISABLE_OMEGA_COTHREADS, test "x$GST_DISABLE_OMEGA_COTHREADS" = "xyes")
dnl check for makecontext and define HAVE_MAKECONTEXT if we have it
AC_CHECK_MCSC()

View file

@ -135,6 +135,10 @@ gst_file_sink_class_init (GstFileSinkClass * klass)
gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_file_sink_render);
gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_file_sink_event);
if (sizeof (off_t) < 8) {
GST_LOG ("No large file support, sizeof (off_t) = %u", sizeof (off_t));
}
}
static void
@ -282,6 +286,24 @@ gst_file_sink_query (GstPad * pad, GstQuery * query)
}
}
static void
gst_file_sink_do_seek (GstFileSink * filesink, guint64 new_offset)
{
GST_DEBUG_OBJECT (filesink, "Seeking to offset %" G_GUINT64_FORMAT,
new_offset);
#ifdef G_OS_UNIX
if (lseek (fileno (filesink->file), (off_t) new_offset,
SEEK_SET) != (off_t) - 1)
return;
#else
if (fseek (filesink->file, (long) new_offset, SEEK_SET) == 0)
return;
#endif
GST_DEBUG_OBJECT (filesink, "Seeking failed: %s", g_strerror (errno));
}
/* handle events (search) */
static gboolean
gst_file_sink_event (GstBaseSink * sink, GstEvent * event)
@ -303,7 +325,9 @@ gst_file_sink_event (GstBaseSink * sink, GstEvent * event)
NULL);
if (format == GST_FORMAT_BYTES) {
fseek (filesink->file, soffset, SEEK_SET);
gst_file_sink_do_seek (filesink, (guint64) soffset);
} else {
GST_DEBUG ("Ignored NEWSEGMENT event of format %u", (guint) format);
}
break;
}
@ -321,36 +345,53 @@ gst_file_sink_event (GstBaseSink * sink, GstEvent * event)
return TRUE;
}
/**
* gst_file_sink_chain:
* @pad: the pad this filesink is connected to
* @buf: the buffer that has to be absorbed
*
* take the buffer from the pad and write to file if it's open
*/
static gboolean
gst_file_sink_get_current_offset (GstFileSink * filesink, guint64 * p_pos)
{
off_t ret;
#ifdef G_OS_UNIX
ret = lseek (fileno (filesink->file), 0, SEEK_CUR);
#else
ret = (off_t) ftell (filesink->file);
#endif
*p_pos = (guint64) ret;
return (ret != (off_t) - 1);
}
static GstFlowReturn
gst_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
{
GstFileSink *filesink;
guint64 cur_pos;
guint size, back_pending = 0;
size = GST_BUFFER_SIZE (buffer);
filesink = GST_FILE_SINK (sink);
if (ftell (filesink->file) < filesink->data_written)
back_pending = filesink->data_written - ftell (filesink->file);
if (!gst_file_sink_get_current_offset (filesink, &cur_pos))
goto handle_error;
if (fwrite (GST_BUFFER_DATA (buffer), size, 1, filesink->file) != 1) {
GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
(_("Error while writing to file \"%s\"."), filesink->filename),
("%s", g_strerror (errno)));
return GST_FLOW_ERROR;
}
if (cur_pos < filesink->data_written)
back_pending = filesink->data_written - cur_pos;
if (fwrite (GST_BUFFER_DATA (buffer), size, 1, filesink->file) != 1)
goto handle_error;
filesink->data_written += size - back_pending;
return GST_FLOW_OK;
handle_error:
GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
(_("Error while writing to file \"%s\"."), filesink->filename),
("%s", g_strerror (errno)));
return GST_FLOW_ERROR;
}
static GstElementStateReturn

View file

@ -207,6 +207,10 @@ gst_file_src_class_init (GstFileSrcClass * klass)
gstbasesrc_class->is_seekable = GST_DEBUG_FUNCPTR (gst_file_src_is_seekable);
gstbasesrc_class->get_size = GST_DEBUG_FUNCPTR (gst_file_src_get_size);
gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_file_src_create);
if (sizeof (off_t) < 8) {
GST_LOG ("No large file support, sizeof (off_t) = %u!", sizeof (off_t));
}
}
static void

View file

@ -135,6 +135,10 @@ gst_file_sink_class_init (GstFileSinkClass * klass)
gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_file_sink_render);
gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_file_sink_event);
if (sizeof (off_t) < 8) {
GST_LOG ("No large file support, sizeof (off_t) = %u", sizeof (off_t));
}
}
static void
@ -282,6 +286,24 @@ gst_file_sink_query (GstPad * pad, GstQuery * query)
}
}
static void
gst_file_sink_do_seek (GstFileSink * filesink, guint64 new_offset)
{
GST_DEBUG_OBJECT (filesink, "Seeking to offset %" G_GUINT64_FORMAT,
new_offset);
#ifdef G_OS_UNIX
if (lseek (fileno (filesink->file), (off_t) new_offset,
SEEK_SET) != (off_t) - 1)
return;
#else
if (fseek (filesink->file, (long) new_offset, SEEK_SET) == 0)
return;
#endif
GST_DEBUG_OBJECT (filesink, "Seeking failed: %s", g_strerror (errno));
}
/* handle events (search) */
static gboolean
gst_file_sink_event (GstBaseSink * sink, GstEvent * event)
@ -303,7 +325,9 @@ gst_file_sink_event (GstBaseSink * sink, GstEvent * event)
NULL);
if (format == GST_FORMAT_BYTES) {
fseek (filesink->file, soffset, SEEK_SET);
gst_file_sink_do_seek (filesink, (guint64) soffset);
} else {
GST_DEBUG ("Ignored NEWSEGMENT event of format %u", (guint) format);
}
break;
}
@ -321,36 +345,53 @@ gst_file_sink_event (GstBaseSink * sink, GstEvent * event)
return TRUE;
}
/**
* gst_file_sink_chain:
* @pad: the pad this filesink is connected to
* @buf: the buffer that has to be absorbed
*
* take the buffer from the pad and write to file if it's open
*/
static gboolean
gst_file_sink_get_current_offset (GstFileSink * filesink, guint64 * p_pos)
{
off_t ret;
#ifdef G_OS_UNIX
ret = lseek (fileno (filesink->file), 0, SEEK_CUR);
#else
ret = (off_t) ftell (filesink->file);
#endif
*p_pos = (guint64) ret;
return (ret != (off_t) - 1);
}
static GstFlowReturn
gst_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
{
GstFileSink *filesink;
guint64 cur_pos;
guint size, back_pending = 0;
size = GST_BUFFER_SIZE (buffer);
filesink = GST_FILE_SINK (sink);
if (ftell (filesink->file) < filesink->data_written)
back_pending = filesink->data_written - ftell (filesink->file);
if (!gst_file_sink_get_current_offset (filesink, &cur_pos))
goto handle_error;
if (fwrite (GST_BUFFER_DATA (buffer), size, 1, filesink->file) != 1) {
GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
(_("Error while writing to file \"%s\"."), filesink->filename),
("%s", g_strerror (errno)));
return GST_FLOW_ERROR;
}
if (cur_pos < filesink->data_written)
back_pending = filesink->data_written - cur_pos;
if (fwrite (GST_BUFFER_DATA (buffer), size, 1, filesink->file) != 1)
goto handle_error;
filesink->data_written += size - back_pending;
return GST_FLOW_OK;
handle_error:
GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
(_("Error while writing to file \"%s\"."), filesink->filename),
("%s", g_strerror (errno)));
return GST_FLOW_ERROR;
}
static GstElementStateReturn

View file

@ -207,6 +207,10 @@ gst_file_src_class_init (GstFileSrcClass * klass)
gstbasesrc_class->is_seekable = GST_DEBUG_FUNCPTR (gst_file_src_is_seekable);
gstbasesrc_class->get_size = GST_DEBUG_FUNCPTR (gst_file_src_get_size);
gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_file_src_create);
if (sizeof (off_t) < 8) {
GST_LOG ("No large file support, sizeof (off_t) = %u!", sizeof (off_t));
}
}
static void