[Spice-commits] 6 commits - gtk/channel-cursor.c gtk/channel-display.c gtk/channel-inputs.c gtk/channel-main.c gtk/channel-playback.c gtk/channel-record.c gtk/channel-usbredir.c gtk/map-file gtk/spice-audio.c gtk/spice-audio.h gtk/spice-channel.c gtk/spice-client.h gtk/spice-gstaudio.c gtk/spice-option.c gtk/spice-pulse.c gtk/spice-session.c gtk/spicy.c
Marc-André Lureau
elmarco at kemper.freedesktop.org
Mon Nov 7 05:30:24 PST 2011
gtk/channel-cursor.c | 1 -
gtk/channel-display.c | 1 -
gtk/channel-inputs.c | 5 +----
gtk/channel-main.c | 1 -
gtk/channel-playback.c | 4 +---
gtk/channel-record.c | 4 +---
gtk/channel-usbredir.c | 2 --
gtk/map-file | 1 +
gtk/spice-audio.c | 42 ++++++++++++++++++++++++++++++++++++++----
gtk/spice-audio.h | 6 +++---
gtk/spice-channel.c | 14 ++++++++++----
gtk/spice-client.h | 1 +
gtk/spice-gstaudio.c | 5 +----
gtk/spice-option.c | 5 +++++
gtk/spice-pulse.c | 5 +----
gtk/spice-session.c | 31 ++++++++++++++++++++++++++++---
gtk/spicy.c | 5 +----
17 files changed, 92 insertions(+), 41 deletions(-)
New commits:
commit 542e003b122aee705e3ecb672f54a2c63c36dc62
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Mon Nov 7 14:29:17 2011 +0100
Drop useless memset
Private data in GObject's is initialized to 0's upon constuction
diff --git a/gtk/channel-cursor.c b/gtk/channel-cursor.c
index 9df5b40..4ad402c 100644
--- a/gtk/channel-cursor.c
+++ b/gtk/channel-cursor.c
@@ -80,7 +80,6 @@ static void spice_cursor_channel_init(SpiceCursorChannel *channel)
SpiceCursorChannelPrivate *c;
c = channel->priv = SPICE_CURSOR_CHANNEL_GET_PRIVATE(channel);
- memset(c, 0, sizeof(*c));
cache_init(&c->cursors, "cursor");
}
diff --git a/gtk/channel-display.c b/gtk/channel-display.c
index 206e630..923281b 100644
--- a/gtk/channel-display.c
+++ b/gtk/channel-display.c
@@ -555,7 +555,6 @@ static void spice_display_channel_init(SpiceDisplayChannel *channel)
SpiceDisplayChannelPrivate *c;
c = channel->priv = SPICE_DISPLAY_CHANNEL_GET_PRIVATE(channel);
- memset(c, 0, sizeof(*c));
ring_init(&c->surfaces);
c->image_cache.ops = &image_cache_ops;
diff --git a/gtk/channel-inputs.c b/gtk/channel-inputs.c
index e1d0d60..f6c4a3e 100644
--- a/gtk/channel-inputs.c
+++ b/gtk/channel-inputs.c
@@ -74,10 +74,7 @@ static void spice_inputs_channel_up(SpiceChannel *channel);
static void spice_inputs_channel_init(SpiceInputsChannel *channel)
{
- SpiceInputsChannelPrivate *c;
-
- c = channel->priv = SPICE_INPUTS_CHANNEL_GET_PRIVATE(channel);
- memset(c, 0, sizeof(*c));
+ channel->priv = SPICE_INPUTS_CHANNEL_GET_PRIVATE(channel);
}
static void spice_inputs_get_property(GObject *object,
diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 2b8d88f..74eeca9 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -155,7 +155,6 @@ static void spice_main_channel_init(SpiceMainChannel *channel)
SpiceMainChannelPrivate *c;
c = channel->priv = SPICE_MAIN_CHANNEL_GET_PRIVATE(channel);
- memset(c, 0, sizeof(*c));
c->agent_msg_queue = g_queue_new();
}
diff --git a/gtk/channel-playback.c b/gtk/channel-playback.c
index 29fe218..4804682 100644
--- a/gtk/channel-playback.c
+++ b/gtk/channel-playback.c
@@ -85,10 +85,8 @@ static void spice_playback_handle_msg(SpiceChannel *channel, SpiceMsgIn *msg);
static void spice_playback_channel_init(SpicePlaybackChannel *channel)
{
- SpicePlaybackChannelPrivate *c;
+ channel->priv = SPICE_PLAYBACK_CHANNEL_GET_PRIVATE(channel);
- c = channel->priv = SPICE_PLAYBACK_CHANNEL_GET_PRIVATE(channel);
- memset(c, 0, sizeof(*c));
spice_channel_set_capability(SPICE_CHANNEL(channel), SPICE_PLAYBACK_CAP_CELT_0_5_1);
spice_channel_set_capability(SPICE_CHANNEL(channel), SPICE_PLAYBACK_CAP_VOLUME);
}
diff --git a/gtk/channel-record.c b/gtk/channel-record.c
index 33fd222..443337c 100644
--- a/gtk/channel-record.c
+++ b/gtk/channel-record.c
@@ -91,10 +91,8 @@ static void channel_up(SpiceChannel *channel);
static void spice_record_channel_init(SpiceRecordChannel *channel)
{
- SpiceRecordChannelPrivate *c;
+ channel->priv = SPICE_RECORD_CHANNEL_GET_PRIVATE(channel);
- c = channel->priv = SPICE_RECORD_CHANNEL_GET_PRIVATE(channel);
- memset(c, 0, sizeof(*c));
spice_channel_set_capability(SPICE_CHANNEL(channel), SPICE_RECORD_CAP_CELT_0_5_1);
spice_channel_set_capability(SPICE_CHANNEL(channel), SPICE_RECORD_CAP_VOLUME);
}
diff --git a/gtk/channel-usbredir.c b/gtk/channel-usbredir.c
index bb90dca..c0991c9 100644
--- a/gtk/channel-usbredir.c
+++ b/gtk/channel-usbredir.c
@@ -81,8 +81,6 @@ static int usbredir_write_callback(void *user_data, uint8_t *data, int count);
static void spice_usbredir_channel_init(SpiceUsbredirChannel *channel)
{
channel->priv = SPICE_USBREDIR_CHANNEL_GET_PRIVATE(channel);
-
- memset(channel->priv, 0, sizeof(SpiceUsbredirChannelPrivate));
}
static void spice_usbredir_channel_finalize(GObject *obj)
diff --git a/gtk/spice-gstaudio.c b/gtk/spice-gstaudio.c
index 2e1c8b6..559da8c 100644
--- a/gtk/spice-gstaudio.c
+++ b/gtk/spice-gstaudio.c
@@ -104,10 +104,7 @@ static void spice_gstaudio_dispose(GObject *obj)
static void spice_gstaudio_init(SpiceGstaudio *pulse)
{
- SpiceGstaudioPrivate *p;
-
- p = pulse->priv = SPICE_GSTAUDIO_GET_PRIVATE(pulse);
- memset(p, 0, sizeof(*p));
+ pulse->priv = SPICE_GSTAUDIO_GET_PRIVATE(pulse);
}
static void spice_gstaudio_class_init(SpiceGstaudioClass *klass)
diff --git a/gtk/spice-pulse.c b/gtk/spice-pulse.c
index 7231251..83f7cb9 100644
--- a/gtk/spice-pulse.c
+++ b/gtk/spice-pulse.c
@@ -131,10 +131,7 @@ static void spice_pulse_dispose(GObject *obj)
static void spice_pulse_init(SpicePulse *pulse)
{
- SpicePulsePrivate *p;
-
- p = pulse->priv = SPICE_PULSE_GET_PRIVATE(pulse);
- memset(p, 0, sizeof(*p));
+ pulse->priv = SPICE_PULSE_GET_PRIVATE(pulse);
}
static void spice_pulse_class_init(SpicePulseClass *klass)
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 419d72f..6884cb2 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -168,7 +168,6 @@ static void spice_session_init(SpiceSession *session)
SPICE_DEBUG("New session (compiled from package " PACKAGE_STRING ")");
s = session->priv = SPICE_SESSION_GET_PRIVATE(session);
- memset(s, 0, sizeof(*s));
ring_init(&s->channels);
cache_init(&s->images, "image");
diff --git a/gtk/spicy.c b/gtk/spicy.c
index e837414..6c05b1e 100644
--- a/gtk/spicy.c
+++ b/gtk/spicy.c
@@ -1073,10 +1073,7 @@ static spice_window *create_spice_window(spice_connection *conn, int id, SpiceCh
int i;
SpiceGrabSequence *seq;
- win = malloc(sizeof(*win));
- if (NULL == win)
- return NULL;
- memset(win,0,sizeof(*win));
+ win = g_new0(struct spice_window, 1);
win->id = id;
win->conn = conn;
win->display_channel = channel;
commit 2caa8afa4a70a30e682b6db2a5cad5a237d25400
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Mon Nov 7 12:58:34 2011 +0100
Use G_PARAM_CONSTRUCT for property initial value
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index bc92acc..419d72f 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -169,8 +169,6 @@ static void spice_session_init(SpiceSession *session)
SPICE_DEBUG("New session (compiled from package " PACKAGE_STRING ")");
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");
@@ -789,7 +787,7 @@ static void spice_session_class_init(SpiceSessionClass *klass)
"Enable audio channels",
"Enable audio channels",
TRUE,
- G_PARAM_READWRITE |
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
/**
@@ -845,7 +843,7 @@ static void spice_session_class_init(SpiceSessionClass *klass)
"Enable USB device redirection",
"Forward USB devices to the SPICE server",
TRUE,
- G_PARAM_READWRITE |
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
/**
commit d45809979a21961f52641773edc0c335d65cf281
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Sat Nov 5 17:20:04 2011 +0100
Add missing include of spice-audio
diff --git a/gtk/spice-client.h b/gtk/spice-client.h
index 48ea96d..3f84b0b 100644
--- a/gtk/spice-client.h
+++ b/gtk/spice-client.h
@@ -41,6 +41,7 @@
#include "channel-smartcard.h"
#include "channel-usbredir.h"
#include "usb-device-manager.h"
+#include "spice-audio.h"
#define SPICE_CLIENT_ERROR spice_client_error_quark()
commit 83df1cd36efd4347e25334995a25fe9f3fe6cabf
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Sat Nov 5 17:04:05 2011 +0100
Add session enable-audio property
Create audio channels only if enable-audio is TRUE
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
commit 079499ef49ee5fa607b5bf1e4242e9bde6f0269f
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Sat Nov 5 17:09:05 2011 +0100
SpiceAudio stream name default to get_application_name()
diff --git a/gtk/spice-audio.c b/gtk/spice-audio.c
index e991cea..3f4bb80 100644
--- a/gtk/spice-audio.c
+++ b/gtk/spice-audio.c
@@ -64,22 +64,23 @@ static void spice_audio_init(SpiceAudio *self G_GNUC_UNUSED)
* spice_audio_new:
* @session: the #SpiceSession to connect to
* @context: a #GMainContext to attach to (or %NULL for default).
- * @name: a name for the audio channels (or %NULL for default).
+ * @name: a name for the audio channels (or %NULL for application name).
*
* Once instantiated, #SpiceAudio will handle the playback and record
* channels to stream to your local audio system.
*
* Returns: a new #SpiceAudio instance or %NULL if no backend or failed.
+ * Deprecated: 0.8: Use spice_audio_get() instead
**/
SpiceAudio *spice_audio_new(SpiceSession *session, GMainContext *context,
- const char *name)
+ const char *name)
{
SpiceAudio *audio = NULL;
if (context == NULL)
- context = g_main_context_default();
+ context = g_main_context_default();
if (name == NULL)
- name = "spice";
+ name = g_get_application_name();
#ifdef WITH_PULSE
audio = SPICE_AUDIO(spice_pulse_new(session, context, name));
commit 3c84fd3921ff2bc2db47253faeb24662f0be4659
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Sat Nov 5 17:07:41 2011 +0100
Add spice_audio_get()
We are going to deprecate spice_audio_new()
some day. There are a few know problems:
- SpiceAudio is an abstract class,
so it can't have a ctor
- SpiceAudio should be a singleton,
associated with the session lifetime
- SpiceSession should have a enable-audio property,
internal code should be able to access the audio object
That way of getting the audio object is similar to the smartcard manager and usb manager.
diff --git a/gtk/map-file b/gtk/map-file
index 0b1b26f..f9bc46c 100644
--- a/gtk/map-file
+++ b/gtk/map-file
@@ -2,6 +2,7 @@ SPICEGTK_1 {
global:
spice_audio_get_type;
spice_audio_new;
+spice_audio_get;
spice_channel_connect;
spice_channel_destroy;
spice_channel_disconnect;
diff --git a/gtk/spice-audio.c b/gtk/spice-audio.c
index baa7c0b..e991cea 100644
--- a/gtk/spice-audio.c
+++ b/gtk/spice-audio.c
@@ -89,3 +89,36 @@ SpiceAudio *spice_audio_new(SpiceSession *session, GMainContext *context,
#endif
return audio;
}
+
+/**
+ * spice_audio_get:
+ * @session: the #SpiceSession to connect to
+ * @context: (allow-none): a #GMainContext to attach to (or %NULL for default).
+ *
+ * Gets the #SpiceAudio associated with the passed in #SpiceSession.
+ * A new #SpiceAudio instance will be created the first time this
+ * function is called for a certain #SpiceSession.
+ *
+ * Note that this function returns a weak reference, which should not be used
+ * after the #SpiceSession itself has been unref-ed by the caller.
+ *
+ * Returns: (transfer none): a weak reference to a #SpiceAudio
+ * instance or %NULL if failed.
+ **/
+SpiceAudio *spice_audio_get(SpiceSession *session, GMainContext *context)
+{
+ static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
+ SpiceAudio *self;
+
+ g_static_mutex_lock(&mutex);
+ self = g_object_get_data(G_OBJECT(session), "spice-audio");
+ if (self == NULL) {
+ self = spice_audio_new(session, context, NULL);
+ g_object_set_data(G_OBJECT(session), "spice-audio", self);
+ if (self)
+ g_object_weak_ref(G_OBJECT(session), (GWeakNotify)g_object_unref, self);
+ }
+ g_static_mutex_unlock(&mutex);
+
+ return self;
+}
diff --git a/gtk/spice-audio.h b/gtk/spice-audio.h
index b881698..dc66e88 100644
--- a/gtk/spice-audio.h
+++ b/gtk/spice-audio.h
@@ -69,9 +69,9 @@ struct _SpiceAudioClass {
GType spice_audio_get_type(void);
-SpiceAudio *spice_audio_new(SpiceSession *session,
- GMainContext *context,
- const char *name);
+SpiceAudio* spice_audio_new(SpiceSession *session, GMainContext *context, const char *name);
+
+SpiceAudio* spice_audio_get(SpiceSession *session, GMainContext *context);
G_END_DECLS
More information about the Spice-commits
mailing list