[Spice-devel] [PATCHv2 01/22] audio: add accessor to check if audio is enabled
Marc-André Lureau
marcandre.lureau at redhat.com
Wed Nov 26 09:55:52 PST 2014
---
gtk/spice-audio.c | 19 ++++++++++---------
gtk/spice-session-priv.h | 1 +
gtk/spice-session.c | 8 ++++++++
3 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/gtk/spice-audio.c b/gtk/spice-audio.c
index 638f667..ce303f1 100644
--- a/gtk/spice-audio.c
+++ b/gtk/spice-audio.c
@@ -166,17 +166,18 @@ static void connect_channel(SpiceAudio *self, SpiceChannel *channel)
static void update_audio_channels(SpiceAudio *self, SpiceSession *session)
{
- if (session->priv->audio) {
- GList *list, *tmp;
-
- list = spice_session_get_channels(session);
- for (tmp = g_list_first(list); tmp != NULL; tmp = g_list_next(tmp)) {
- connect_channel(self, tmp->data);
- }
- g_list_free(list);
- } else {
+ GList *list, *tmp;
+
+ if (!spice_session_get_audio_enabled(session)) {
g_debug("FIXME: disconnect audio channels");
+ return;
+ }
+
+ list = spice_session_get_channels(session);
+ for (tmp = g_list_first(list); tmp != NULL; tmp = g_list_next(tmp)) {
+ connect_channel(self, tmp->data);
}
+ g_list_free(list);
}
static void channel_new(SpiceSession *session, SpiceChannel *channel, SpiceAudio *self)
diff --git a/gtk/spice-session-priv.h b/gtk/spice-session-priv.h
index 8e102e0..55e2ed2 100644
--- a/gtk/spice-session-priv.h
+++ b/gtk/spice-session-priv.h
@@ -172,6 +172,7 @@ guint32 spice_session_get_playback_latency(SpiceSession *session);
void spice_session_sync_playback_latency(SpiceSession *session);
const gchar* spice_session_get_shared_dir(SpiceSession *session);
void spice_session_set_shared_dir(SpiceSession *session, const gchar *dir);
+gboolean spice_session_get_audio_enabled(SpiceSession *session);
G_END_DECLS
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index c44a3e1..f729ae0 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -2279,3 +2279,11 @@ SpiceURI *spice_session_get_proxy_uri(SpiceSession *session)
return s->proxy;
}
+
+G_GNUC_INTERNAL
+gboolean spice_session_get_audio_enabled(SpiceSession *session)
+{
+ g_return_val_if_fail(SPICE_IS_SESSION(session), FALSE);
+
+ return session->priv->audio;
+}
--
2.1.0
More information about the Spice-devel
mailing list