diff --git a/ext/gio/gstgiobasesink.c b/ext/gio/gstgiobasesink.c index 6a878717a1..7ddd970628 100644 --- a/ext/gio/gstgiobasesink.c +++ b/ext/gio/gstgiobasesink.c @@ -134,10 +134,11 @@ static gboolean gst_gio_base_sink_stop (GstBaseSink * base_sink) { GstGioBaseSink *sink = GST_GIO_BASE_SINK (base_sink); + GstGioBaseSinkClass *klass = GST_GIO_BASE_SINK_GET_CLASS (sink); gboolean success; GError *err = NULL; - if (G_IS_OUTPUT_STREAM (sink->stream)) { + if (klass->close_on_stop && G_IS_OUTPUT_STREAM (sink->stream)) { GST_DEBUG_OBJECT (sink, "closing stream"); /* FIXME: can block but unfortunately we can't use async operations @@ -155,6 +156,9 @@ gst_gio_base_sink_stop (GstBaseSink * base_sink) GST_DEBUG_OBJECT (sink, "g_outut_stream_close succeeded"); } + g_object_unref (sink->stream); + sink->stream = NULL; + } else { g_object_unref (sink->stream); sink->stream = NULL; } diff --git a/ext/gio/gstgiobasesink.h b/ext/gio/gstgiobasesink.h index 9a14225499..7f13a854b9 100644 --- a/ext/gio/gstgiobasesink.h +++ b/ext/gio/gstgiobasesink.h @@ -61,6 +61,7 @@ struct _GstGioBaseSinkClass GstBaseSinkClass parent_class; GOutputStream * (*get_stream) (GstGioBaseSink *bsink); + gboolean close_on_stop; }; GType gst_gio_base_sink_get_type (void); diff --git a/ext/gio/gstgiobasesrc.c b/ext/gio/gstgiobasesrc.c index cfeab575b8..f67015270f 100644 --- a/ext/gio/gstgiobasesrc.c +++ b/ext/gio/gstgiobasesrc.c @@ -145,10 +145,11 @@ static gboolean gst_gio_base_src_stop (GstBaseSrc * base_src) { GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src); + GstGioBaseSrcClass *klass = GST_GIO_BASE_SRC_GET_CLASS (src); gboolean success; GError *err = NULL; - if (G_IS_INPUT_STREAM (src->stream)) { + if (klass->close_on_stop && G_IS_INPUT_STREAM (src->stream)) { GST_DEBUG_OBJECT (src, "closing stream"); /* FIXME: can block but unfortunately we can't use async operations @@ -166,6 +167,9 @@ gst_gio_base_src_stop (GstBaseSrc * base_src) GST_DEBUG_OBJECT (src, "g_input_stream_close succeeded"); } + g_object_unref (src->stream); + src->stream = NULL; + } else { g_object_unref (src->stream); src->stream = NULL; } diff --git a/ext/gio/gstgiobasesrc.h b/ext/gio/gstgiobasesrc.h index d1eea70142..7a14859cbd 100644 --- a/ext/gio/gstgiobasesrc.h +++ b/ext/gio/gstgiobasesrc.h @@ -62,6 +62,7 @@ struct _GstGioBaseSrcClass GstBaseSrcClass parent_class; GInputStream * (*get_stream) (GstGioBaseSrc *bsrc); + gboolean close_on_stop; }; GType gst_gio_base_src_get_type (void); diff --git a/ext/gio/gstgiosink.c b/ext/gio/gstgiosink.c index cf8cea5b99..57d1024942 100644 --- a/ext/gio/gstgiosink.c +++ b/ext/gio/gstgiosink.c @@ -126,6 +126,7 @@ gst_gio_sink_class_init (GstGioSinkClass * klass) gstgiobasesink_class->get_stream = GST_DEBUG_FUNCPTR (gst_gio_sink_get_stream); + gstgiobasesink_class->close_on_stop = TRUE; } static void diff --git a/ext/gio/gstgiosrc.c b/ext/gio/gstgiosrc.c index e4e39cb7b9..ce944be6b7 100644 --- a/ext/gio/gstgiosrc.c +++ b/ext/gio/gstgiosrc.c @@ -129,6 +129,7 @@ gst_gio_src_class_init (GstGioSrcClass * klass) GST_DEBUG_FUNCPTR (gst_gio_src_check_get_range); gstgiobasesrc_class->get_stream = GST_DEBUG_FUNCPTR (gst_gio_src_get_stream); + gstgiobasesrc_class->close_on_stop = TRUE; } static void