[Spice-devel] [PATCH] Handle spice_audio_new failures

Christophe Fergeau cfergeau at redhat.com
Mon Jan 16 02:20:21 PST 2012


On Mon, Jan 16, 2012 at 11:13:37AM +0100, Marc-André Lureau wrote:
> 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;

Pushed with these changes

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20120116/1339c020/attachment.pgp>


More information about the Spice-devel mailing list