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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey,

On Mon, Mar 23, 2015 at 09:42:33AM -0400, Marc-André Lureau wrote:
> 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?

I only care about NEW/CHANGED events in the sink-input/source-output for
our streams. If the stream was never created, we can't sync as we never
got the volume value. If the stream was created then we always have the
last value given by pulseaudio.

Note that, in this last case, even if we don't have a stream we can
return the last volume of the last stream created (which is the volume of
the new stream when it is created)

>
> 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 don't think is possible unless using the threaded api (like pulsesink
and pulsesrc in gst-plugins-good) - Then we could 'lock' while the thread
gets the volume/mute values.

It is also possible to subscribe/unsubscribe for events when necessary.

>I guess you need to reenter the loop. Perhaps you should make the SpiceAudio getters async too then.
>

Well, that's also possible. Do you think it is the best alternative?

>
> > ---
> >  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@xxxxxxxxxxxxxxxxxxxxx
> > http://lists.freedesktop.org/mailman/listinfo/spice-devel
> > 
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]