Commit ffea638f authored by Wim Taymans's avatar Wim Taymans

ext/gnomevfs/gstgnomevfssrc.*: Don't cache file sizes. Fixes #341078.

Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnome_vfs_src_get_size),
(gst_gnome_vfs_src_start), (gst_gnome_vfs_src_stop):
* ext/gnomevfs/gstgnomevfssrc.h:
Don't cache file sizes. Fixes #341078.
parent 5b1cd740
2007-03-22 Wim Taymans <wim@fluendo.com>
* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnome_vfs_src_get_size),
(gst_gnome_vfs_src_start), (gst_gnome_vfs_src_stop):
* ext/gnomevfs/gstgnomevfssrc.h:
Don't cache file sizes. Fixes #341078.
2007-03-21 Tim-Philipp Müller <tim at centricular dot net>
* gst/playback/gstplaybin.c: (add_sink):
......@@ -770,15 +770,40 @@ static gboolean
gst_gnome_vfs_src_get_size (GstBaseSrc * basesrc, guint64 * size)
{
GstGnomeVFSSrc *src;
GnomeVFSFileInfo *info;
GnomeVFSFileInfoOptions options;
GnomeVFSResult res;
src = GST_GNOME_VFS_SRC (basesrc);
GST_DEBUG_OBJECT (src, "size %" G_GUINT64_FORMAT, src->size);
*size = -1;
info = gnome_vfs_file_info_new ();
options = GNOME_VFS_FILE_INFO_DEFAULT | GNOME_VFS_FILE_INFO_FOLLOW_LINKS;
res = gnome_vfs_get_file_info_from_handle (src->handle, info, options);
if (res == GNOME_VFS_OK) {
if ((info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) != 0) {
*size = info->size;
GST_DEBUG_OBJECT (src, "from handle: %" G_GUINT64_FORMAT " bytes", *size);
} else if (src->own_handle && gnome_vfs_uri_is_local (src->uri)) {
GST_DEBUG_OBJECT (src,
"file size not known, file local, trying fallback");
res = gnome_vfs_get_file_info_uri (src->uri, info, options);
if (res == GNOME_VFS_OK &&
(info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) != 0) {
*size = info->size;
GST_DEBUG_OBJECT (src, "from uri: %" G_GUINT64_FORMAT " bytes", *size);
}
}
} else {
GST_WARNING_OBJECT (src, "getting info failed: %s",
gnome_vfs_result_to_string (res));
}
gnome_vfs_file_info_unref (info);
if (src->size == (GnomeVFSFileSize) - 1)
return FALSE;
GST_DEBUG_OBJECT (src, "return size %" G_GUINT64_FORMAT, *size);
*size = src->size;
if (*size == (GnomeVFSFileSize) - 1)
return FALSE;
return TRUE;
}
......@@ -787,9 +812,7 @@ gst_gnome_vfs_src_get_size (GstBaseSrc * basesrc, guint64 * size)
static gboolean
gst_gnome_vfs_src_start (GstBaseSrc * basesrc)
{
GnomeVFSFileInfoOptions options;
GnomeVFSResult res;
GnomeVFSFileInfo *info;
GstGnomeVFSSrc *src;
src = GST_GNOME_VFS_SRC (basesrc);
......@@ -811,31 +834,6 @@ gst_gnome_vfs_src_start (GstBaseSrc * basesrc)
src->own_handle = FALSE;
}
src->size = (GnomeVFSFileSize) - 1;
info = gnome_vfs_file_info_new ();
options = GNOME_VFS_FILE_INFO_DEFAULT | GNOME_VFS_FILE_INFO_FOLLOW_LINKS;
res = gnome_vfs_get_file_info_from_handle (src->handle, info, options);
if (res == GNOME_VFS_OK) {
if ((info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) != 0) {
src->size = info->size;
GST_DEBUG_OBJECT (src, "size: %" G_GUINT64_FORMAT " bytes", src->size);
} else if (src->own_handle && gnome_vfs_uri_is_local (src->uri)) {
GST_DEBUG_OBJECT (src, "file size not known, trying fallback");
res = gnome_vfs_get_file_info_uri (src->uri, info, options);
if (res == GNOME_VFS_OK &&
(info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) != 0) {
src->size = info->size;
GST_DEBUG_OBJECT (src, "size: %" G_GUINT64_FORMAT " bytes", src->size);
}
}
if (src->size == (GnomeVFSFileSize) - 1)
GST_DEBUG_OBJECT (src, "file size not known");
} else {
GST_WARNING_OBJECT (src, "getting info failed: %s",
gnome_vfs_result_to_string (res));
}
gnome_vfs_file_info_unref (info);
if (gnome_vfs_seek (src->handle, GNOME_VFS_SEEK_CURRENT, 0)
== GNOME_VFS_OK) {
src->seekable = TRUE;
......@@ -887,7 +885,6 @@ gst_gnome_vfs_src_stop (GstBaseSrc * basesrc)
gnome_vfs_close (src->handle);
src->handle = NULL;
}
src->size = (GnomeVFSFileSize) - 1;
src->curoffset = 0;
if (src->icy_caps) {
......
......@@ -60,7 +60,6 @@ struct _GstGnomeVFSSrc
gchar *uri_name;
GnomeVFSHandle *handle;
gboolean own_handle;
GnomeVFSFileSize size; /* -1 = unknown */
GnomeVFSFileOffset curoffset; /* current offset in file */
gboolean seekable;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment