[Spice-devel] [PATCH] Handle spice_audio_new failures
Marc-André Lureau
marcandre.lureau at gmail.com
Mon Jan 16 02:13:37 PST 2012
On Mon, Jan 16, 2012 at 10:58 AM, Christophe Fergeau
<cfergeau at redhat.com> wrote:
> 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);
I would prefer to just return here:
if (!self)
return NULL;
> + 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;
> }
ack otherwise
--
Marc-André Lureau
More information about the Spice-devel
mailing list