[Spice-devel] [PATCH spice-gtk 3/4] Add session enable-audio property

Christophe Fergeau cfergeau at redhat.com
Mon Nov 7 00:33:45 PST 2011


On Sat, Nov 05, 2011 at 05:56:08PM +0100, Marc-André Lureau wrote:
> 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;

Is it needed since there's a default value specified in g_param_spec_boolean?
ACK regardless of what you decide to do with this minor nitpick

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/20111107/b5d1037c/attachment.pgp>


More information about the Spice-devel mailing list