[Spice-commits] 2 commits - gtk/spice-gstaudio.c
Victor Toso de Carvalho
victortoso at kemper.freedesktop.org
Mon Dec 1 05:47:41 PST 2014
gtk/spice-gstaudio.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
New commits:
commit 7acd660241fb908b6f48ff9c36d00874326697ca
Author: Victor Toso <victortoso at redhat.com>
Date: Mon Nov 24 17:48:17 2014 +0100
audio: Avoid bad pipelines from gst_parse_launch
gst_parse_launch may return not NULL even when error is set.
This can lead to data loss when playing or recording audio.
diff --git a/gtk/spice-gstaudio.c b/gtk/spice-gstaudio.c
index 5f9abb2..1b82f24 100644
--- a/gtk/spice-gstaudio.c
+++ b/gtk/spice-gstaudio.c
@@ -245,9 +245,9 @@ static void record_start(SpiceRecordChannel *channel, gint format, gint channels
"appsink caps=\"%s\" name=appsink", audio_caps);
p->record.pipe = gst_parse_launch(pipeline, &error);
- if (p->record.pipe == NULL) {
+ if (error != NULL) {
g_warning("Failed to create pipeline: %s", error->message);
- goto lerr;
+ goto cleanup;
}
bus = gst_pipeline_get_bus(GST_PIPELINE(p->record.pipe));
@@ -268,7 +268,11 @@ static void record_start(SpiceRecordChannel *channel, gint format, gint channels
G_CALLBACK(record_new_buffer), gstaudio, 0);
#endif
-lerr:
+cleanup:
+ if (error != NULL && p->record.pipe != NULL) {
+ gst_object_unref(p->record.pipe);
+ p->record.pipe = NULL;
+ }
g_clear_error(&error);
g_free(audio_caps);
g_free(pipeline);
@@ -345,16 +349,20 @@ static void playback_start(SpicePlaybackChannel *channel, gint format, gint chan
"audioconvert ! audioresample ! autoaudiosink name=\"audiosink\"", audio_caps);
SPICE_DEBUG("audio pipeline: %s", pipeline);
p->playback.pipe = gst_parse_launch(pipeline, &error);
- if (p->playback.pipe == NULL) {
+ if (error != NULL) {
g_warning("Failed to create pipeline: %s", error->message);
- goto lerr;
+ goto cleanup;
}
p->playback.src = gst_bin_get_by_name(GST_BIN(p->playback.pipe), "appsrc");
p->playback.sink = gst_bin_get_by_name(GST_BIN(p->playback.pipe), "audiosink");
p->playback.rate = frequency;
p->playback.channels = channels;
-lerr:
+cleanup:
+ if (error != NULL && p->playback.pipe != NULL) {
+ gst_object_unref(p->playback.pipe);
+ p->playback.pipe = NULL;
+ }
g_clear_error(&error);
g_free(audio_caps);
g_free(pipeline);
commit f924bd4543c555d617be3346d3db605f2c9dd72a
Author: Victor Toso <victortoso at redhat.com>
Date: Mon Nov 24 17:30:55 2014 +0100
audio: new-sample callback must return GST_FLOW_OK
diff --git a/gtk/spice-gstaudio.c b/gtk/spice-gstaudio.c
index 6173783..5f9abb2 100644
--- a/gtk/spice-gstaudio.c
+++ b/gtk/spice-gstaudio.c
@@ -120,13 +120,13 @@ static void spice_gstaudio_class_init(SpiceGstaudioClass *klass)
g_type_class_add_private(klass, sizeof(SpiceGstaudioPrivate));
}
-static void record_new_buffer(GstAppSink *appsink, gpointer data)
+static GstFlowReturn record_new_buffer(GstAppSink *appsink, gpointer data)
{
SpiceGstaudio *gstaudio = data;
SpiceGstaudioPrivate *p = gstaudio->priv;
GstMessage *msg;
- g_return_if_fail(p != NULL);
+ g_return_val_if_fail(p != NULL, GST_FLOW_ERROR);
#ifdef WITH_GST1AUDIO
msg = gst_message_new_application(GST_OBJECT(p->record.pipe),
@@ -135,6 +135,7 @@ static void record_new_buffer(GstAppSink *appsink, gpointer data)
msg = gst_message_new_application(GST_OBJECT(p->record.pipe), NULL);
#endif
gst_element_post_message(p->record.pipe, msg);
+ return GST_FLOW_OK;
}
static void record_stop(SpiceGstaudio *gstaudio)
More information about the Spice-commits
mailing list