mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 22:36:33 +00:00
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.
This commit is contained in:
parent
13d89656c0
commit
cf7dfb868e
5 changed files with 41 additions and 48 deletions
|
@ -189,13 +189,6 @@ plugin_init (GstPlugin * plugin)
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_gio_debug, "gio", 0, "GIO elements");
|
GST_DEBUG_CATEGORY_INIT (gst_gio_debug, "gio", 0, "GIO elements");
|
||||||
|
|
||||||
/* FIXME: This is needed to prevent a crash. Needs further investigation
|
|
||||||
* probably. */
|
|
||||||
if (g_vfs_get_default () == NULL) {
|
|
||||||
GST_WARNING ("Failed to initialize default VFS, not registering plugin");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME: Rank is MARGINAL for now, should be at least SECONDARY+1 in the future
|
/* FIXME: Rank is MARGINAL for now, should be at least SECONDARY+1 in the future
|
||||||
* to replace gnomevfssink/src. For testing purposes PRIMARY+1 one makes sense
|
* to replace gnomevfssink/src. For testing purposes PRIMARY+1 one makes sense
|
||||||
* so it gets autoplugged and preferred over filesrc/sink. */
|
* so it gets autoplugged and preferred over filesrc/sink. */
|
||||||
|
|
|
@ -135,12 +135,20 @@ gst_gio_sink_finalize (GObject * object)
|
||||||
{
|
{
|
||||||
GstGioSink *sink = GST_GIO_SINK (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)
|
if (sink->stream) {
|
||||||
g_object_unref (sink->file);
|
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));
|
GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
|
||||||
}
|
}
|
||||||
|
@ -186,6 +194,7 @@ static gboolean
|
||||||
gst_gio_sink_start (GstBaseSink * base_sink)
|
gst_gio_sink_start (GstBaseSink * base_sink)
|
||||||
{
|
{
|
||||||
GstGioSink *sink = GST_GIO_SINK (base_sink);
|
GstGioSink *sink = GST_GIO_SINK (base_sink);
|
||||||
|
GFile *file;
|
||||||
gboolean success;
|
gboolean success;
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
|
|
||||||
|
@ -195,18 +204,20 @@ gst_gio_sink_start (GstBaseSink * base_sink)
|
||||||
return FALSE;
|
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),
|
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL),
|
||||||
("Malformed URI or protocol not supported (%s)", sink->location));
|
("Malformed URI or protocol not supported (%s)", sink->location));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
sink->stream =
|
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);
|
success = (sink->stream != NULL);
|
||||||
|
|
||||||
|
g_object_unref (file);
|
||||||
|
|
||||||
if (!success && !gst_gio_error (sink, "g_file_create", &err, NULL)) {
|
if (!success && !gst_gio_error (sink, "g_file_create", &err, NULL)) {
|
||||||
|
|
||||||
/*if (GST_GIO_ERROR_MATCHES (err, EXISTS)) */
|
/*if (GST_GIO_ERROR_MATCHES (err, EXISTS)) */
|
||||||
|
@ -224,12 +235,8 @@ gst_gio_sink_start (GstBaseSink * base_sink)
|
||||||
g_clear_error (&err);
|
g_clear_error (&err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success) {
|
if (!success)
|
||||||
g_object_unref (sink->file);
|
|
||||||
sink->file = NULL;
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
sink->position = 0;
|
sink->position = 0;
|
||||||
|
|
||||||
|
@ -245,11 +252,6 @@ gst_gio_sink_stop (GstBaseSink * base_sink)
|
||||||
gboolean success = TRUE;
|
gboolean success = TRUE;
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
|
|
||||||
if (sink->file != NULL) {
|
|
||||||
g_object_unref (sink->file);
|
|
||||||
sink->file = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sink->stream != NULL) {
|
if (sink->stream != NULL) {
|
||||||
/* FIXME: In case that the call below would block, there is no one to
|
/* FIXME: In case that the call below would block, there is no one to
|
||||||
* trigger the cancellation! */
|
* trigger the cancellation! */
|
||||||
|
@ -289,10 +291,9 @@ gst_gio_sink_unlock_stop (GstBaseSink * base_sink)
|
||||||
{
|
{
|
||||||
GstGioSink *sink = GST_GIO_SINK (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);
|
g_cancellable_reset (sink->cancel);
|
||||||
sink->cancel = g_cancellable_new ();
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,6 @@ struct _GstGioSink
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
GCancellable *cancel;
|
GCancellable *cancel;
|
||||||
GFile *file;
|
|
||||||
gchar *location;
|
gchar *location;
|
||||||
guint64 position;
|
guint64 position;
|
||||||
GFileOutputStream *stream;
|
GFileOutputStream *stream;
|
||||||
|
|
|
@ -128,12 +128,20 @@ gst_gio_src_finalize (GObject * object)
|
||||||
{
|
{
|
||||||
GstGioSrc *src = GST_GIO_SRC (object);
|
GstGioSrc *src = GST_GIO_SRC (object);
|
||||||
|
|
||||||
g_object_unref (src->cancel);
|
if (src->cancel) {
|
||||||
|
g_object_unref (src->cancel);
|
||||||
|
src->cancel = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (src->file)
|
if (src->stream) {
|
||||||
g_object_unref (src->file);
|
g_object_unref (src->stream);
|
||||||
|
src->stream = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
g_free (src->location);
|
if (src->location) {
|
||||||
|
g_free (src->location);
|
||||||
|
src->location = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
|
GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
|
||||||
}
|
}
|
||||||
|
@ -179,6 +187,7 @@ static gboolean
|
||||||
gst_gio_src_start (GstBaseSrc * base_src)
|
gst_gio_src_start (GstBaseSrc * base_src)
|
||||||
{
|
{
|
||||||
GstGioSrc *src = GST_GIO_SRC (base_src);
|
GstGioSrc *src = GST_GIO_SRC (base_src);
|
||||||
|
GFile *file;
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
|
|
||||||
if (src->location == NULL) {
|
if (src->location == NULL) {
|
||||||
|
@ -186,15 +195,17 @@ gst_gio_src_start (GstBaseSrc * base_src)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
src->file = g_file_new_for_uri (src->location);
|
file = g_file_new_for_uri (src->location);
|
||||||
|
|
||||||
if (src->file == NULL) {
|
if (file == NULL) {
|
||||||
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
|
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
|
||||||
("Malformed URI or protocol not supported (%s)", src->location));
|
("Malformed URI or protocol not supported (%s)", src->location));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
src->stream = g_file_read (src->file, src->cancel, &err);
|
src->stream = g_file_read (file, src->cancel, &err);
|
||||||
|
|
||||||
|
g_object_unref (file);
|
||||||
|
|
||||||
if (src->stream == NULL && !gst_gio_error (src, "g_file_read", &err, NULL)) {
|
if (src->stream == NULL && !gst_gio_error (src, "g_file_read", &err, NULL)) {
|
||||||
|
|
||||||
|
@ -209,13 +220,9 @@ gst_gio_src_start (GstBaseSrc * base_src)
|
||||||
|
|
||||||
g_clear_error (&err);
|
g_clear_error (&err);
|
||||||
|
|
||||||
g_object_unref (src->file);
|
|
||||||
src->file = NULL;
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
} else if (src->stream == NULL) {
|
} else if (src->stream == NULL) {
|
||||||
g_object_unref (src->file);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,11 +257,6 @@ gst_gio_src_stop (GstBaseSrc * base_src)
|
||||||
src->stream = NULL;
|
src->stream = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src->file != NULL) {
|
|
||||||
g_object_unref (src->file);
|
|
||||||
src->file = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (src, "closed location %s", src->location);
|
GST_DEBUG_OBJECT (src, "closed location %s", src->location);
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
@ -321,10 +323,9 @@ gst_gio_src_unlock_stop (GstBaseSrc * base_src)
|
||||||
{
|
{
|
||||||
GstGioSrc *src = GST_GIO_SRC (base_src);
|
GstGioSrc *src = GST_GIO_SRC (base_src);
|
||||||
|
|
||||||
GST_LOG_OBJECT (src, "restoring cancellable");
|
GST_LOG_OBJECT (src, "resetting cancellable");
|
||||||
|
|
||||||
g_object_unref (src->cancel);
|
g_cancellable_reset (src->cancel);
|
||||||
src->cancel = g_cancellable_new ();
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,6 @@ struct _GstGioSrc
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
GCancellable *cancel;
|
GCancellable *cancel;
|
||||||
GFile *file;
|
|
||||||
gchar *location;
|
gchar *location;
|
||||||
guint64 position;
|
guint64 position;
|
||||||
GFileInputStream *stream;
|
GFileInputStream *stream;
|
||||||
|
|
Loading…
Reference in a new issue