diff options
author | Pavel Grunt <pgrunt@redhat.com> | 2016-04-14 18:01:23 +0200 |
---|---|---|
committer | Pavel Grunt <pgrunt@redhat.com> | 2016-04-15 13:57:23 +0200 |
commit | 286044a7ca2aeee0b5fbc63774a7611bc7cc4748 (patch) | |
tree | 4801abaf17d80ad483b0ade01992d081ff1d8949 | |
parent | 4da4d9201cc3f86e38f00388cdd6157fe70e3328 (diff) |
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@redhat.com>
-rw-r--r-- | src/channel-main.c | 17 |
1 files changed, 9 insertions, 8 deletions
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 || |