gio: Don't close the GIO streams for the giostream{src,sink} elements

This makes it possible to do something useful with the streams
after the element has stopped. Fixes bug #587896.
This commit is contained in:
Sebastian Dröge 2009-07-08 17:19:29 +02:00
parent 399d4fcbe7
commit 1c0123cf58
6 changed files with 14 additions and 2 deletions

View file

@ -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;
}

View file

@ -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);

View file

@ -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;
}

View file

@ -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);

View file

@ -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

View file

@ -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