[Spice-commits] 2 commits - src/channel-main.c

Pavel Grunt pgrunt at kemper.freedesktop.org
Fri Apr 15 11:57:59 UTC 2016


 src/channel-main.c |   22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

New commits:
commit de5beccb0fe77fb5e1c75c7bb3bd6f4f06e66937
Author: Pavel Grunt <pgrunt at redhat.com>
Date:   Thu Apr 14 18:01:24 2016 +0200

    channel-main: Move variable to block where is needed

diff --git a/src/channel-main.c b/src/channel-main.c
index a7770fa..604f333 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -2247,17 +2247,14 @@ static void migrate_channel_event_cb(SpiceChannel *channel, SpiceChannelEvent ev
 {
     spice_migrate *mig = data;
     SpiceChannelPrivate  *c = SPICE_CHANNEL(channel)->priv;
-    SpiceSession *session;
 
     g_return_if_fail(mig->nchannels > 0);
     g_signal_handlers_disconnect_by_func(channel, migrate_channel_event_cb, data);
 
-    session = spice_channel_get_session(mig->src_channel);
-
     switch (event) {
     case SPICE_CHANNEL_OPENED:
-
         if (c->channel_type == SPICE_CHANNEL_MAIN) {
+            SpiceSession *session = spice_channel_get_session(mig->src_channel);
             if (mig->do_seamless) {
                 SpiceMainChannelPrivate *main_priv = SPICE_MAIN_CHANNEL(channel)->priv;
 
commit 286044a7ca2aeee0b5fbc63774a7611bc7cc4748
Author: Pavel Grunt <pgrunt at redhat.com>
Date:   Thu Apr 14 18:01:23 2016 +0200

    channel-main: Add helper function for getting audio
    
    Avoid repeating the same code and having a SpiceSession variable
    defined when is not really needed.
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/src/channel-main.c b/src/channel-main.c
index 8e5de8a..a7770fa 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -1187,11 +1187,15 @@ gboolean spice_main_send_monitor_config(SpiceMainChannel *channel)
     return TRUE;
 }
 
+static SpiceAudio *spice_main_get_audio(const SpiceMainChannel *channel)
+{
+    return spice_audio_get(spice_channel_get_session(SPICE_CHANNEL(channel)), NULL);
+}
+
 static void audio_playback_volume_info_cb(GObject *object, GAsyncResult *res, gpointer user_data)
 {
     SpiceMainChannel *main_channel = user_data;
-    SpiceSession *session = spice_channel_get_session(SPICE_CHANNEL(main_channel));
-    SpiceAudio *audio = spice_audio_get(session, NULL);
+    SpiceAudio *audio = spice_main_get_audio(main_channel);
     VDAgentAudioVolumeSync *avs;
     guint16 *volume;
     guint8 nchannels;
@@ -1229,8 +1233,7 @@ static void audio_playback_volume_info_cb(GObject *object, GAsyncResult *res, gp
 
 static void agent_sync_audio_playback(SpiceMainChannel *main_channel)
 {
-    SpiceSession *session = spice_channel_get_session(SPICE_CHANNEL(main_channel));
-    SpiceAudio *audio = spice_audio_get(session, NULL);
+    SpiceAudio *audio = spice_main_get_audio(main_channel);
     SpiceMainChannelPrivate *c = main_channel->priv;
 
     if (audio == NULL ||
@@ -1249,8 +1252,7 @@ static void agent_sync_audio_playback(SpiceMainChannel *main_channel)
 static void audio_record_volume_info_cb(GObject *object, GAsyncResult *res, gpointer user_data)
 {
     SpiceMainChannel *main_channel = user_data;
-    SpiceSession *session = spice_channel_get_session(SPICE_CHANNEL(main_channel));
-    SpiceAudio *audio = spice_audio_get(session, NULL);
+    SpiceAudio *audio = spice_main_get_audio(main_channel);
     VDAgentAudioVolumeSync *avs;
     guint16 *volume;
     guint8 nchannels;
@@ -1287,8 +1289,7 @@ static void audio_record_volume_info_cb(GObject *object, GAsyncResult *res, gpoi
 
 static void agent_sync_audio_record(SpiceMainChannel *main_channel)
 {
-    SpiceSession *session = spice_channel_get_session(SPICE_CHANNEL(main_channel));
-    SpiceAudio *audio = spice_audio_get(session, NULL);
+    SpiceAudio *audio = spice_main_get_audio(main_channel);
     SpiceMainChannelPrivate *c = main_channel->priv;
 
     if (audio == NULL ||


More information about the Spice-commits mailing list