[Spice-devel] [PATCH spice-gtk 3/4] Add session enable-audio property
Marc-André Lureau
marcandre.lureau at gmail.com
Sat Nov 5 09:56:08 PDT 2011
Create audio channels only if enable-audio is TRUE
---
gtk/spice-channel.c | 14 ++++++++++----
gtk/spice-option.c | 5 +++++
gtk/spice-session.c | 28 ++++++++++++++++++++++++++++
3 files changed, 43 insertions(+), 4 deletions(-)
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 23c16e7..99af206 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -1706,11 +1706,17 @@ SpiceChannel *spice_channel_new(SpiceSession *s, int type, int id)
gtype = SPICE_TYPE_INPUTS_CHANNEL;
break;
case SPICE_CHANNEL_PLAYBACK:
- gtype = SPICE_TYPE_PLAYBACK_CHANNEL;
- break;
- case SPICE_CHANNEL_RECORD:
- gtype = SPICE_TYPE_RECORD_CHANNEL;
+ case SPICE_CHANNEL_RECORD: {
+ gboolean enabled;
+ g_object_get(G_OBJECT(s), "enable-audio", &enabled, NULL);
+ if (!enabled) {
+ g_debug("audio channel is disabled, not creating it");
+ return NULL;
+ }
+ gtype = type == SPICE_CHANNEL_RECORD ?
+ SPICE_TYPE_RECORD_CHANNEL : SPICE_TYPE_PLAYBACK_CHANNEL;
break;
+ }
#ifdef USE_SMARTCARD
case SPICE_CHANNEL_SMARTCARD: {
gboolean enabled;
diff --git a/gtk/spice-option.c b/gtk/spice-option.c
index 4a2ba90..9819543 100644
--- a/gtk/spice-option.c
+++ b/gtk/spice-option.c
@@ -32,6 +32,7 @@ static char *host_subject = NULL;
static char *smartcard_db = NULL;
static char *smartcard_certificates = NULL;
static gboolean smartcard = FALSE;
+static gboolean disable_audio = FALSE;
static gboolean disable_usbredir = FALSE;
static void option_version(void)
@@ -64,6 +65,8 @@ GOptionGroup* spice_get_option_group(void)
N_("Truststore file for secure connections"), N_("<file>") },
{ "spice-host-subject", '\0', 0, G_OPTION_ARG_STRING, &host_subject,
N_("Subject of the host certificate (field=value pairs separated by commas)"), N_("<host-subject>") },
+ { "spice-disable-audio", '\0', 0, G_OPTION_ARG_NONE, &disable_audio,
+ N_("Disable audio support"), NULL },
{ "spice-smartcard", '\0', 0, G_OPTION_ARG_NONE, &smartcard,
N_("Enable smartcard support"), NULL },
{ "spice-smartcard-certificates", '\0', 0, G_OPTION_ARG_STRING, &smartcard_certificates,
@@ -132,4 +135,6 @@ void spice_set_session_option(SpiceSession *session)
}
if (disable_usbredir)
g_object_set(session, "enable-usbredir", FALSE, NULL);
+ if (disable_audio)
+ g_object_set(session, "enable-audio", FALSE, NULL);
}
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 90e0318..bc92acc 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -45,6 +45,9 @@ struct _SpiceSessionPrivate {
char *cert_subject;
guint verify;
+ /* whether to enable audio */
+ gboolean audio;
+
/* whether to enable smartcard event forwarding to the server */
gboolean smartcard;
@@ -140,6 +143,7 @@ enum {
PROP_CERT_SUBJECT,
PROP_VERIFY,
PROP_MIGRATION_STATE,
+ PROP_AUDIO,
PROP_SMARTCARD,
PROP_SMARTCARD_CERTIFICATES,
PROP_SMARTCARD_DB,
@@ -166,6 +170,7 @@ static void spice_session_init(SpiceSession *session)
s = session->priv = SPICE_SESSION_GET_PRIVATE(session);
memset(s, 0, sizeof(*s));
s->usbredir = TRUE;
+ s->audio = TRUE;
ring_init(&s->channels);
cache_init(&s->images, "image");
@@ -412,6 +417,9 @@ static void spice_session_get_property(GObject *gobject,
case PROP_COLOR_DEPTH:
g_value_set_int(value, s->color_depth);
break;
+ case PROP_AUDIO:
+ g_value_set_boolean(value, s->audio);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
break;
@@ -502,6 +510,9 @@ static void spice_session_set_property(GObject *gobject,
case PROP_COLOR_DEPTH:
s->color_depth = g_value_get_int(value);
break;
+ case PROP_AUDIO:
+ s->audio = g_value_get_boolean(value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
break;
@@ -765,6 +776,23 @@ static void spice_session_class_init(SpiceSessionClass *klass)
G_PARAM_STATIC_STRINGS));
/**
+ * SpiceSession:enable-audio:
+ *
+ * If set to TRUE, the audio channels will be enabled for
+ * playback and recording.
+ *
+ * Since: 0.8
+ **/
+ g_object_class_install_property
+ (gobject_class, PROP_AUDIO,
+ g_param_spec_boolean("enable-audio",
+ "Enable audio channels",
+ "Enable audio channels",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ /**
* SpiceSession:smartcard-certificates:
*
* This property is used when one wants to simulate a smartcard with no
--
1.7.7
More information about the Spice-devel
mailing list