[Spice-devel] [spice-gtk PATCH v2 3/7] audio: pulse implements spice-audio get functions

Marc-André Lureau mlureau at redhat.com
Mon Mar 23 06:42:33 PDT 2015


Hi

----- Original Message -----
> As spice-pulse is aware of client volume changes, it can return the
> updated value of volume and mute when requested.

Given that you subscribe to events, how do you know if the value is sync or ever set?

Instead, I would call pa_context_get_{sink_input,source_output}_info(). However, it looks all async, I don't know if you can make sync call. I guess you need to reenter the loop. Perhaps you should make the SpiceAudio getters async too then.


> ---
>  gtk/spice-pulse.c | 56
>  +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 56 insertions(+)
> 
> diff --git a/gtk/spice-pulse.c b/gtk/spice-pulse.c
> index 6b27c97..f47b0a6 100644
> --- a/gtk/spice-pulse.c
> +++ b/gtk/spice-pulse.c
> @@ -81,6 +81,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)
>  {
> @@ -148,6 +152,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;
> @@ -981,3 +989,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
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
> 


More information about the Spice-devel mailing list