[Spice-devel] [spice-gtk PATCH v4 4/6] audio: pulse implements spice-audio get functions
Victor Toso
victortoso at redhat.com
Mon Mar 30 04:09:13 PDT 2015
As spice-pulse is aware of client volume changes, it can return the
updated value of volume and mute when requested.
---
gtk/spice-pulse.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/gtk/spice-pulse.c b/gtk/spice-pulse.c
index 81a5588..24c3ab2 100644
--- a/gtk/spice-pulse.c
+++ b/gtk/spice-pulse.c
@@ -82,6 +82,10 @@ static const char *context_state_names[] = {
static void stream_stop(SpicePulse *pulse, struct stream *s);
static gboolean connect_channel(SpiceAudio *audio, SpiceChannel *channel);
static void channel_weak_notified(gpointer data, GObject *where_the_object_was);
+static gboolean spice_pulse_get_playback_mute(SpiceAudio *audio);
+static guint16* spice_pulse_get_playback_volume(SpiceAudio *audio, guint8 *nchannels);
+static gboolean spice_pulse_get_record_mute(SpiceAudio *audio);
+static guint16* spice_pulse_get_record_volume(SpiceAudio *audio, guint8 *nchannels);
static void spice_pulse_finalize(GObject *obj)
{
@@ -149,6 +153,10 @@ static void spice_pulse_class_init(SpicePulseClass *klass)
SpiceAudioClass *audio_class = SPICE_AUDIO_CLASS(klass);
audio_class->connect_channel = connect_channel;
+ audio_class->get_playback_mute = spice_pulse_get_playback_mute;
+ audio_class->get_playback_volume = spice_pulse_get_playback_volume;
+ audio_class->get_record_mute = spice_pulse_get_record_mute;
+ audio_class->get_record_volume = spice_pulse_get_record_volume;
gobject_class->finalize = spice_pulse_finalize;
gobject_class->dispose = spice_pulse_dispose;
@@ -1041,3 +1049,51 @@ error:
g_object_unref(pulse);
return NULL;
}
+
+static gboolean spice_pulse_get_playback_mute(SpiceAudio *audio)
+{
+ SpicePulsePrivate *p = SPICE_PULSE(audio)->priv;
+ return p->playback.mute;
+}
+
+static guint16* spice_pulse_get_playback_volume(SpiceAudio *audio, guint8 *nchannels)
+{
+ SpicePulsePrivate *p = SPICE_PULSE(audio)->priv;
+ guint16 *volume;
+
+ if (nchannels != NULL)
+ *nchannels = p->playback.nchannels;
+
+ if (p->playback.nchannels == 0) {
+ SPICE_DEBUG("%s: Number of channels in playback is 0", __func__);
+ return NULL;
+ }
+
+ volume = g_new(guint16, p->playback.nchannels);
+ memcpy (volume, p->playback.volume, sizeof(guint16) * (p->playback.nchannels));
+ return volume;
+}
+
+static gboolean spice_pulse_get_record_mute(SpiceAudio *audio)
+{
+ SpicePulsePrivate *p = SPICE_PULSE(audio)->priv;
+ return p->record.mute;
+}
+
+static guint16* spice_pulse_get_record_volume(SpiceAudio *audio, guint8 *nchannels)
+{
+ SpicePulsePrivate *p = SPICE_PULSE(audio)->priv;
+ guint16 *volume;
+
+ if (nchannels != NULL)
+ *nchannels = p->record.nchannels;
+
+ if (p->record.nchannels == 0) {
+ SPICE_DEBUG("%s: Number of channels in record is 0", __func__);
+ return NULL;
+ }
+
+ volume = g_new(guint16, p->record.nchannels);
+ memcpy (volume, p->record.volume, sizeof(guint16) * (p->record.nchannels));
+ return volume;
+}
--
2.1.0
More information about the Spice-devel
mailing list