ext/gnomevfs/gstgnomevfssrc.c: Some cleanups.

Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssrc.c: (audiocast_init),
(audiocast_register_listener), (gst_gnome_vfs_src_start):
Some cleanups.
This commit is contained in:
Wim Taymans 2006-03-09 17:50:59 +00:00
parent f0862d80d9
commit ba3d2db624
2 changed files with 74 additions and 37 deletions

View File

@ -1,3 +1,9 @@
2006-03-09 Wim Taymans <wim@fluendo.com>
* ext/gnomevfs/gstgnomevfssrc.c: (audiocast_init),
(audiocast_register_listener), (gst_gnome_vfs_src_start):
Some cleanups.
2006-03-09 Wim Taymans <wim@fluendo.com> 2006-03-09 Wim Taymans <wim@fluendo.com>
* ext/ogg/gstoggdemux.c: (gst_ogg_demux_activate_chain): * ext/ogg/gstoggdemux.c: (gst_ogg_demux_activate_chain):

View File

@ -528,32 +528,51 @@ audiocast_init (GstGnomeVFSSrc * src)
if (!src->iradio_mode) if (!src->iradio_mode)
return TRUE; return TRUE;
GST_DEBUG_OBJECT (src, "audiocast: registering listener"); GST_DEBUG_OBJECT (src, "audiocast: registering listener");
if (audiocast_register_listener (&src->audiocast_port, if (audiocast_register_listener (&src->audiocast_port,
&src->audiocast_fd) < 0) { &src->audiocast_fd) < 0)
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL), goto no_listener;
("Unable to listen on UDP port %d", src->audiocast_port));
close (src->audiocast_fd);
return FALSE;
}
GST_DEBUG_OBJECT (src, "audiocast: creating pipe"); GST_DEBUG_OBJECT (src, "audiocast: creating pipe");
src->audiocast_notify_queue = NULL; src->audiocast_notify_queue = NULL;
if (pipe (pipefds) < 0) { if (pipe (pipefds) < 0)
close (src->audiocast_fd); goto no_pipe;
return FALSE;
}
src->audiocast_thread_die_infd = pipefds[0]; src->audiocast_thread_die_infd = pipefds[0];
src->audiocast_thread_die_outfd = pipefds[1]; src->audiocast_thread_die_outfd = pipefds[1];
GST_DEBUG_OBJECT (src, "audiocast: creating audiocast thread"); GST_DEBUG_OBJECT (src, "audiocast: creating audiocast thread");
src->audiocast_thread = src->audiocast_thread =
g_thread_create ((GThreadFunc) audiocast_thread_run, src, TRUE, &error); g_thread_create ((GThreadFunc) audiocast_thread_run, src, TRUE, &error);
if (error != NULL) { if (error != NULL)
GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), goto no_thread;
("Unable to create thread: %s", error->message));
return TRUE;
/* ERRORS */
no_listener:
{
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
("Unable to listen on UDP port %d", src->audiocast_port));
return FALSE;
}
no_pipe:
{
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
("Unable to create socketpair"));
close (src->audiocast_fd); close (src->audiocast_fd);
return FALSE; return FALSE;
} }
return TRUE; no_thread:
{
GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL),
("Unable to create thread: %s", error->message));
close (src->audiocast_fd);
close (pipefds[0]);
close (pipefds[1]);
return FALSE;
}
} }
static int static int
@ -586,6 +605,8 @@ audiocast_register_listener (gint * port, gint * fd)
*fd = sock; *fd = sock;
return 0; return 0;
/* ERRORS */
lose_and_close: lose_and_close:
close (sock); close (sock);
lose: lose:
@ -1093,7 +1114,7 @@ gst_gnome_vfs_src_get_size (GstBaseSrc * basesrc, guint64 * size)
return TRUE; return TRUE;
} }
/* open the file, do stuff necessary to go to READY state */ /* open the file, do stuff necessary to go to PAUSED state */
static gboolean static gboolean
gst_gnome_vfs_src_start (GstBaseSrc * basesrc) gst_gnome_vfs_src_start (GstBaseSrc * basesrc)
{ {
@ -1109,31 +1130,13 @@ gst_gnome_vfs_src_start (GstBaseSrc * basesrc)
gst_gnome_vfs_src_push_callbacks (src); gst_gnome_vfs_src_push_callbacks (src);
if (src->uri != NULL) { if (src->uri != NULL) {
/* this can block... */
if ((res = gnome_vfs_open_uri (&src->handle, src->uri, if ((res = gnome_vfs_open_uri (&src->handle, src->uri,
GNOME_VFS_OPEN_READ)) != GNOME_VFS_OK) { GNOME_VFS_OPEN_READ)) != GNOME_VFS_OK)
gchar *filename = gnome_vfs_uri_to_string (src->uri, goto open_failed;
GNOME_VFS_URI_HIDE_PASSWORD);
gst_gnome_vfs_src_pop_callbacks (src);
audiocast_thread_kill (src);
if (res == GNOME_VFS_ERROR_NOT_FOUND ||
res == GNOME_VFS_ERROR_SERVICE_NOT_AVAILABLE) {
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL),
("Could not open vfs file \"%s\" for reading: %s",
filename, gnome_vfs_result_to_string (res)));
} else {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
("Could not open vfs file \"%s\" for reading: %s",
filename, gnome_vfs_result_to_string (res)));
}
g_free (filename);
return FALSE;
}
src->own_handle = TRUE; src->own_handle = TRUE;
} else if (!src->handle) { } else if (!src->handle) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL), ("No filename given")); goto no_filename;
return FALSE;
} else { } else {
src->own_handle = FALSE; src->own_handle = FALSE;
} }
@ -1163,6 +1166,34 @@ gst_gnome_vfs_src_start (GstBaseSrc * basesrc)
} }
return TRUE; return TRUE;
/* ERRORS */
open_failed:
{
gchar *filename = gnome_vfs_uri_to_string (src->uri,
GNOME_VFS_URI_HIDE_PASSWORD);
gst_gnome_vfs_src_pop_callbacks (src);
audiocast_thread_kill (src);
if (res == GNOME_VFS_ERROR_NOT_FOUND ||
res == GNOME_VFS_ERROR_SERVICE_NOT_AVAILABLE) {
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL),
("Could not open vfs file \"%s\" for reading: %s",
filename, gnome_vfs_result_to_string (res)));
} else {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
("Could not open vfs file \"%s\" for reading: %s",
filename, gnome_vfs_result_to_string (res)));
}
g_free (filename);
return FALSE;
}
no_filename:
{
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL), ("No filename given"));
return FALSE;
}
} }
static gboolean static gboolean