[rhythmbox] encoder: close output streams, now that giostreamsink doesn't



commit f7bf76d14b2758d21f23d693a62cc5e45b8fa4fb
Author: Jonathan Matthew <jonathan d14n org>
Date:   Mon Jul 27 23:25:05 2009 +1000

    encoder: close output streams, now that giostreamsink doesn't
    
    In gst-plugins-base 0.10.24 and later, giostreamsink will no longer
    close the output stream, so we have to do it ourselves.

 backends/gstreamer/rb-encoder-gst.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/backends/gstreamer/rb-encoder-gst.c b/backends/gstreamer/rb-encoder-gst.c
index 8b6a50c..8dd5630 100644
--- a/backends/gstreamer/rb-encoder-gst.c
+++ b/backends/gstreamer/rb-encoder-gst.c
@@ -69,6 +69,8 @@ struct _RBEncoderGstPrivate {
 	gint64 total_length;
 	guint progress_id;
 	char *dest_uri;
+
+	GOutputStream *outstream;
 };
 
 G_DEFINE_TYPE_WITH_CODE(RBEncoderGst, rb_encoder_gst, G_TYPE_OBJECT,
@@ -157,6 +159,12 @@ rb_encoder_gst_finalize (GObject *object)
 		encoder->priv->pipeline = NULL;
 	}
 
+	if (encoder->priv->outstream) {
+		g_output_stream_close (encoder->priv->outstream, NULL, NULL);
+		g_object_unref (encoder->priv->outstream);
+		encoder->priv->outstream = NULL;
+	}
+
 	g_free (encoder->priv->dest_uri);
 
         G_OBJECT_CLASS (rb_encoder_gst_parent_class)->finalize (object);
@@ -255,6 +263,16 @@ bus_watch_cb (GstBus *bus, GstMessage *message, gpointer data)
 		rb_debug ("received EOS");
 
 		gst_element_set_state (encoder->priv->pipeline, GST_STATE_NULL);
+		if (encoder->priv->outstream != NULL) {
+			GError *error = NULL;
+			g_output_stream_close (encoder->priv->outstream, NULL, &error);
+			if (error != NULL) {
+				rb_debug ("error closing output stream: %s", error->message);
+				g_error_free (error);
+			}
+			g_object_unref (encoder->priv->outstream);
+			encoder->priv->outstream = NULL;
+		}
 
 		rb_encoder_gst_emit_completed (encoder);
 
@@ -632,6 +650,7 @@ attach_output_pipeline (RBEncoderGst *encoder,
 
 		if (stream != NULL) {
 			g_object_set (sink, "stream", stream, NULL);
+			encoder->priv->outstream = G_OUTPUT_STREAM (stream);
 		}
 	} else {
 		rb_debug ("unable to create giostreamsink, falling back to default sink for %s", dest);
@@ -953,6 +972,17 @@ rb_encoder_gst_cancel (RBEncoder *encoder)
 	g_object_unref (priv->pipeline);
 	priv->pipeline = NULL;
 
+	if (priv->outstream != NULL) {
+		GError *error = NULL;
+		g_output_stream_close (priv->outstream, NULL, &error);
+		if (error != NULL) {
+			rb_debug ("error closing output stream: %s", error->message);
+			g_error_free (error);
+		}
+		g_object_unref (priv->outstream);
+		priv->outstream = NULL;
+	}
+
 	rb_encoder_gst_emit_completed (RB_ENCODER_GST (encoder));
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]