diff options
author | Sebastian Dröge <slomo@circular-chaos.org> | 2007-11-07 11:48:09 +0000 |
---|---|---|
committer | Sebastian Dröge <slomo@circular-chaos.org> | 2007-11-07 11:48:09 +0000 |
commit | 3b310c00eb22d59e2a19d84707c4d8f7dec5b434 (patch) | |
tree | 2e2a70f4bc4e80c2fe254955f41c1485ff3f1b13 /ext/gio/gstgiosink.c | |
parent | 1407259dbc44b0cf23c9e72770c990e5f8cac680 (diff) | |
download | gst-plugins-bad-3b310c00eb22d59e2a19d84707c4d8f7dec5b434.tar.gz gst-plugins-bad-3b310c00eb22d59e2a19d84707c4d8f7dec5b434.tar.bz2 gst-plugins-bad-3b310c00eb22d59e2a19d84707c4d8f7dec5b434.zip |
ext/gio/gstgio.c: Remove nowadays unnecessary workaround for a crash.
Original commit message from CVS:
* ext/gio/gstgio.c: (plugin_init):
Remove nowadays unnecessary workaround for a crash.
* ext/gio/gstgiosink.c: (gst_gio_sink_finalize),
(gst_gio_sink_start), (gst_gio_sink_stop),
(gst_gio_sink_unlock_stop):
* ext/gio/gstgiosink.h:
* ext/gio/gstgiosrc.c: (gst_gio_src_finalize), (gst_gio_src_start),
(gst_gio_src_stop), (gst_gio_src_unlock_stop):
* ext/gio/gstgiosrc.h:
Make the finalize function safer, clean up everything that could stay
around.
Reset the cancellable instead of creating a new one after cancelling
some operation.
Don't store the GFile in the element, it's only necessary for creating
the streams.
Diffstat (limited to 'ext/gio/gstgiosink.c')
-rw-r--r-- | ext/gio/gstgiosink.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/ext/gio/gstgiosink.c b/ext/gio/gstgiosink.c index a676ea6a..8929bd9d 100644 --- a/ext/gio/gstgiosink.c +++ b/ext/gio/gstgiosink.c @@ -135,12 +135,20 @@ gst_gio_sink_finalize (GObject * object) { GstGioSink *sink = GST_GIO_SINK (object); - g_object_unref (sink->cancel); + if (sink->cancel) { + g_object_unref (sink->cancel); + sink->cancel = NULL; + } - if (sink->file) - g_object_unref (sink->file); + if (sink->stream) { + g_object_unref (sink->stream); + sink->stream = NULL; + } - g_free (sink->location); + if (sink->location) { + g_free (sink->location); + sink->location = NULL; + } GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); } @@ -186,6 +194,7 @@ static gboolean gst_gio_sink_start (GstBaseSink * base_sink) { GstGioSink *sink = GST_GIO_SINK (base_sink); + GFile *file; gboolean success; GError *err = NULL; @@ -195,18 +204,20 @@ gst_gio_sink_start (GstBaseSink * base_sink) return FALSE; } - sink->file = g_file_new_for_uri (sink->location); + file = g_file_new_for_uri (sink->location); - if (sink->file == NULL) { + if (file == NULL) { GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL), ("Malformed URI or protocol not supported (%s)", sink->location)); return FALSE; } sink->stream = - g_file_create (sink->file, G_FILE_CREATE_FLAGS_NONE, sink->cancel, &err); + g_file_create (file, G_FILE_CREATE_FLAGS_NONE, sink->cancel, &err); success = (sink->stream != NULL); + g_object_unref (file); + if (!success && !gst_gio_error (sink, "g_file_create", &err, NULL)) { /*if (GST_GIO_ERROR_MATCHES (err, EXISTS)) */ @@ -224,12 +235,8 @@ gst_gio_sink_start (GstBaseSink * base_sink) g_clear_error (&err); } - if (!success) { - g_object_unref (sink->file); - sink->file = NULL; - + if (!success) return FALSE; - } sink->position = 0; @@ -245,11 +252,6 @@ gst_gio_sink_stop (GstBaseSink * base_sink) gboolean success = TRUE; GError *err = NULL; - if (sink->file != NULL) { - g_object_unref (sink->file); - sink->file = NULL; - } - if (sink->stream != NULL) { /* FIXME: In case that the call below would block, there is no one to * trigger the cancellation! */ @@ -289,10 +291,9 @@ gst_gio_sink_unlock_stop (GstBaseSink * base_sink) { GstGioSink *sink = GST_GIO_SINK (base_sink); - GST_LOG_OBJECT (sink, "restoring cancellable"); + GST_LOG_OBJECT (sink, "resetting cancellable"); - g_object_unref (sink->cancel); - sink->cancel = g_cancellable_new (); + g_cancellable_reset (sink->cancel); return TRUE; } |