Add "handle" argument, which takes a GnomeVFSHandle directly.

Original commit message from CVS:
Add "handle" argument, which takes a GnomeVFSHandle directly.
This commit is contained in:
Colin Walters 2003-12-23 03:49:27 +00:00
parent 00e3d21803
commit a5b7982494

View file

@ -156,6 +156,7 @@ enum {
enum { enum {
ARG_0, ARG_0,
ARG_HANDLE,
ARG_LOCATION, ARG_LOCATION,
ARG_BYTESPERREAD, ARG_BYTESPERREAD,
ARG_IRADIO_MODE, ARG_IRADIO_MODE,
@ -246,6 +247,13 @@ static void gst_gnomevfssrc_class_init(GstGnomeVFSSrcClass *klass)
gobject_class->dispose = gst_gnomevfssrc_dispose; gobject_class->dispose = gst_gnomevfssrc_dispose;
g_object_class_install_property (gobject_class,
ARG_HANDLE,
g_param_spec_pointer ("handle",
"GnomeVFSHandle",
"Handle for GnomeVFS",
G_PARAM_READWRITE));
/* icecast stuff */ /* icecast stuff */
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
ARG_IRADIO_MODE, ARG_IRADIO_MODE,
@ -412,6 +420,9 @@ static void gst_gnomevfssrc_set_property(GObject *object, guint prop_id, const G
gst_gnomevfssrc_open_file(src); gst_gnomevfssrc_open_file(src);
} }
break; break;
case ARG_HANDLE:
src->handle = g_value_get_pointer (value);
break;
case ARG_BYTESPERREAD: case ARG_BYTESPERREAD:
src->bytes_per_read = g_value_get_int (value); src->bytes_per_read = g_value_get_int (value);
break; break;
@ -440,6 +451,9 @@ static void gst_gnomevfssrc_get_property(GObject *object, guint prop_id, GValue
case ARG_BYTESPERREAD: case ARG_BYTESPERREAD:
g_value_set_int (value, src->bytes_per_read); g_value_set_int (value, src->bytes_per_read);
break; break;
case ARG_HANDLE:
g_value_set_pointer (value, src->handle);
break;
case ARG_IRADIO_MODE: case ARG_IRADIO_MODE:
g_value_set_boolean (value, src->iradio_mode); g_value_set_boolean (value, src->iradio_mode);
break; break;
@ -510,16 +524,8 @@ static int audiocast_init(GstGnomeVFSSrc *src)
if (!src->iradio_mode) if (!src->iradio_mode)
return TRUE; return TRUE;
GST_DEBUG ("audiocast: registering listener"); GST_DEBUG ("audiocast: registering listener");
if (audiocast_register_listener(&src->audiocast_port, &src->audiocast_fd) < 0) if (audiocast_register_listener(&src->audiocast_port, &src->audiocast_fd) < 0) {
{ gst_element_error(GST_ELEMENT(src), "unable to register UDP port");
char *escaped;
escaped = gnome_vfs_unescape_string_for_display (src->filename);
gst_element_error(GST_ELEMENT(src),
"opening vfs file \"%s\" (%s)",
escaped,
"unable to register UDP port");
g_free (escaped);
close(src->audiocast_fd); close(src->audiocast_fd);
return FALSE; return FALSE;
} }
@ -535,13 +541,8 @@ static int audiocast_init(GstGnomeVFSSrc *src)
GST_DEBUG ("audiocast: creating audiocast thread"); GST_DEBUG ("audiocast: creating audiocast thread");
src->audiocast_thread = g_thread_create((GThreadFunc) audiocast_thread_run, src, TRUE, &error); src->audiocast_thread = g_thread_create((GThreadFunc) audiocast_thread_run, src, TRUE, &error);
if (error != NULL) { if (error != NULL) {
char *escaped;
escaped = gnome_vfs_unescape_string_for_display (src->filename);
gst_element_error(GST_ELEMENT(src), gst_element_error(GST_ELEMENT(src),
"opening vfs file \"%s\" (unable to create thread: %s)", "unable to create thread: %s", error->message);
escaped,
error->message);
g_free (escaped);
close(src->audiocast_fd); close(src->audiocast_fd);
return FALSE; return FALSE;
} }
@ -1043,12 +1044,14 @@ static gboolean gst_gnomevfssrc_open_file(GstGnomeVFSSrc *src)
g_return_val_if_fail(!GST_FLAG_IS_SET(src, GST_GNOMEVFSSRC_OPEN), g_return_val_if_fail(!GST_FLAG_IS_SET(src, GST_GNOMEVFSSRC_OPEN),
FALSE); FALSE);
/* create the uri */ if (src->filename) {
src->uri = gnome_vfs_uri_new(src->filename); /* create the uri */
if (!src->uri) { src->uri = gnome_vfs_uri_new(src->filename);
gst_element_error(GST_ELEMENT(src), "creating uri \"%s\" (%s)", if (!src->uri) {
src->filename, strerror (errno)); gst_element_error(GST_ELEMENT(src), "creating uri \"%s\" (%s)",
return FALSE; src->filename, strerror (errno));
return FALSE;
}
} }
if (!audiocast_init(src)) if (!audiocast_init(src))
@ -1056,10 +1059,12 @@ static gboolean gst_gnomevfssrc_open_file(GstGnomeVFSSrc *src)
gst_gnomevfssrc_push_callbacks (src); gst_gnomevfssrc_push_callbacks (src);
result = gnome_vfs_open_uri(&(src->handle), src->uri, if (src->filename)
GNOME_VFS_OPEN_READ); result = gnome_vfs_open_uri(&(src->handle), src->uri,
if (result != GNOME_VFS_OK) GNOME_VFS_OPEN_READ);
{ else
result = GNOME_VFS_OK;
if (result != GNOME_VFS_OK) {
char *escaped; char *escaped;
gst_gnomevfssrc_pop_callbacks (src); gst_gnomevfssrc_pop_callbacks (src);
@ -1113,10 +1118,12 @@ static void gst_gnomevfssrc_close_file(GstGnomeVFSSrc *src)
gst_gnomevfssrc_pop_callbacks (src); gst_gnomevfssrc_pop_callbacks (src);
audiocast_thread_kill(src); audiocast_thread_kill(src);
gnome_vfs_close(src->handle); if (src->filename) {
gnome_vfs_close(src->handle);
gnome_vfs_uri_unref(src->uri);
gnome_vfs_uri_unref(src->uri);
}
src->size = 0; src->size = 0;
src->curoffset = 0; src->curoffset = 0;
src->new_seek = FALSE; src->new_seek = FALSE;