#define GST_IS_GNOMEVFSSRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GNOMEVFSSRC))
+static GStaticMutex count_lock = G_STATIC_MUTEX_INIT;
+static gint ref_count = 0;
+
typedef enum {
GST_GNOMEVFSSRC_OPEN = GST_ELEMENT_FLAG_LAST,
static void gst_gnomevfssrc_class_init (GstGnomeVFSSrcClass *klass);
static void gst_gnomevfssrc_init (GstGnomeVFSSrc *gnomevfssrc);
+static void gst_gnomevfssrc_dispose (GObject *object);
static void gst_gnomevfssrc_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec);
"location", ARG_LOCATION, G_PARAM_READWRITE,
NULL);
+ gobject_class->dispose = gst_gnomevfssrc_dispose;
+
gstelement_class->set_property = gst_gnomevfssrc_set_property;
gstelement_class->get_property = gst_gnomevfssrc_get_property;
gstelement_class->change_state = gst_gnomevfssrc_change_state;
- /* gnome vfs engine init */
- if (gnome_vfs_initialized() == FALSE)
- gnome_vfs_init();
}
static void gst_gnomevfssrc_init(GstGnomeVFSSrc *gnomevfssrc)
{
-
gnomevfssrc->srcpad = gst_pad_new("src", GST_PAD_SRC);
gst_pad_set_get_function(gnomevfssrc->srcpad, gst_gnomevfssrc_get);
gst_pad_set_event_function (gnomevfssrc->srcpad,
gnomevfssrc->curoffset = 0;
gnomevfssrc->bytes_per_read = 4096;
gnomevfssrc->new_seek = FALSE;
+
+ g_static_mutex_lock (&count_lock);
+ if (ref_count == 0) {
+ /* gnome vfs engine init */
+ if (gnome_vfs_initialized() == FALSE) {
+ gnome_vfs_init();
+ }
+ }
+ ref_count++;
+ g_static_mutex_unlock (&count_lock);
+}
+
+static void
+gst_gnomevfssrc_dispose (GObject *object)
+{
+ g_static_mutex_lock (&count_lock);
+ ref_count--;
+ if (ref_count == 0) {
+ if (gnome_vfs_initialized() == TRUE) {
+ gnome_vfs_shutdown();
+ }
+ }
+ g_static_mutex_unlock (&count_lock);
+
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
{
GstEvent *event;
+ gst_buffer_unref (buf);
GST_DEBUG (0,"new seek %lld", src->curoffset);
src->new_seek = FALSE;
{
GstEvent *event;
+ gst_buffer_unref (buf);
+ GST_DEBUG (0,"new seek %lld", src->curoffset);
src->new_seek = FALSE;
GST_DEBUG (GST_CAT_EVENT, "gnomevfssrc sending discont");
event = gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset, NULL);
GST_EVENT_DISCONT_FLUSH (event) = src->need_flush;
src->need_flush = FALSE;
+
return GST_BUFFER (event);
}
close(src->fd);
} else {
gnome_vfs_close(src->handle);
+ gnome_vfs_handle_destroy(src->handle);
}
/* zero out a lot of our state */
src->is_local = FALSE;
- g_free(src->uri);
- g_free(src->handle);
+ gnome_vfs_uri_unref(src->uri);
g_free(src->local_name);
src->fd = 0;
src->map = NULL;