[Spice-devel] [PATCH] Handle spice_audio_new failures

Christophe Fergeau cfergeau at redhat.com
Mon Jan 16 01:58:46 PST 2012


spice_audio_new can return a NULL pointer when there's a failure
during the initialization of the audio system. When this happens,
we shouldn't keep initializing the spice audio channel as if nothing
happened, but just stop the connection.
This can be tested by forcing the "self" variable to NULL in
spice_audio_new
---
 gtk/spice-audio.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/gtk/spice-audio.c b/gtk/spice-audio.c
index f58a81e..9eddf0c 100644
--- a/gtk/spice-audio.c
+++ b/gtk/spice-audio.c
@@ -222,9 +222,11 @@ SpiceAudio *spice_audio_new(SpiceSession *session, GMainContext *context,
     self = SPICE_AUDIO(spice_gstaudio_new(session, context, name));
 #endif
 
-    spice_g_signal_connect_object(session, "notify::enable-audio", G_CALLBACK(session_enable_audio), self, 0);
-    spice_g_signal_connect_object(session, "channel-new", G_CALLBACK(channel_new), self, 0);
-    update_audio_channels(self, session);
+    if (self != NULL) {
+        spice_g_signal_connect_object(session, "notify::enable-audio", G_CALLBACK(session_enable_audio), self, 0);
+        spice_g_signal_connect_object(session, "channel-new", G_CALLBACK(channel_new), self, 0);
+        update_audio_channels(self, session);
+    }
 
     return self;
 }
-- 
1.7.7.5



More information about the Spice-devel mailing list