[Spice-devel] [PATCH] gstaudio: check before set mute/volume properties

Christophe Fergeau cfergeau at redhat.com
Fri Jan 18 17:31:54 UTC 2019


On Fri, Jan 18, 2019 at 04:40:08PM +0100, Victor Toso wrote:
> Hi,
> 
> On Fri, Jan 18, 2019 at 04:35:09PM +0100, Christophe Fergeau wrote:
> > "Check before setting ..."
> 
> Indeed, fixed.
> 
> > On Fri, Jan 18, 2019 at 03:49:21PM +0100, Victor Toso wrote:
> > > From: Victor Toso <me at victortoso.com>
> > > 
> > > Otherwise we can get warnings such as:
> > > 
> > >     GLib-GObject-WARNING **: 16:10:00.857:
> > >     g_object_set_is_valid_property: object class 'GstAutoAudioSink' has no property named 'volume'
> > > 
> > > Signed-off-by: Victor Toso <victortoso at redhat.com>
> > > ---
> > >  src/spice-gstaudio.c | 32 +++++++++++++++++++++++---------
> > >  1 file changed, 23 insertions(+), 9 deletions(-)
> > > 
> > > diff --git a/src/spice-gstaudio.c b/src/spice-gstaudio.c
> > > index 98c1f4f..51ff028 100644
> > > --- a/src/spice-gstaudio.c
> > > +++ b/src/spice-gstaudio.c
> > > @@ -368,10 +368,13 @@ static void playback_volume_changed(GObject *object, GParamSpec *pspec, gpointer
> > >      if (!e)
> > >          e = g_object_ref(p->playback.sink);
> > >  
> > > -    if (GST_IS_STREAM_VOLUME(e))
> > > +    if (GST_IS_STREAM_VOLUME(e)) {
> > >          gst_stream_volume_set_volume(GST_STREAM_VOLUME(e), GST_STREAM_VOLUME_FORMAT_CUBIC, vol);
> > > -    else
> > > +    } else if (g_object_class_find_property(G_OBJECT_GET_CLASS (e), "volume") != NULL) {
> > >          g_object_set(e, "volume", vol, NULL);
> > 
> > Dunno how expensive g_object_class_find_property is, and if we should
> > cache this? Looks good otherwise.
> 
> No clue about how expensive it is, shouldn't be bad but
> considering that this is only triggered after volume/mute
> messages, which are not too happen often in normal use case, it
> should be fine.

Ok,

Acked-by: Christophe Fergeau <cfergeau at redhat.com>

Christophe

> 
> > Christophe
> > 
> > > +    } else {
> > > +        g_warning("playback: ignoring volume change on %s", gst_element_get_name(e));
> > > +    }
> > >  
> > >      g_object_unref(e);
> > >  }
> > > @@ -394,8 +397,13 @@ static void playback_mute_changed(GObject *object, GParamSpec *pspec, gpointer d
> > >      if (!e)
> > >          e = g_object_ref(p->playback.sink);
> > >  
> > > -    if (GST_IS_STREAM_VOLUME(e))
> > > +    if (GST_IS_STREAM_VOLUME(e)) {
> > >          gst_stream_volume_set_mute(GST_STREAM_VOLUME(e), mute);
> > > +    } else if (g_object_class_find_property(G_OBJECT_GET_CLASS (e), "mute") != NULL) {
> > > +        g_object_set(e, "mute", mute, NULL);
> > > +    } else {
> > > +        g_warning("playback: ignoring mute change on %s", gst_element_get_name(e));
> > > +    }
> > >  
> > >      g_object_unref(e);
> > >  }
> > > @@ -427,10 +435,13 @@ static void record_volume_changed(GObject *object, GParamSpec *pspec, gpointer d
> > >      if (!e)
> > >          e = g_object_ref(p->record.src);
> > >  
> > > -    if (GST_IS_STREAM_VOLUME(e))
> > > +    if (GST_IS_STREAM_VOLUME(e)) {
> > >          gst_stream_volume_set_volume(GST_STREAM_VOLUME(e), GST_STREAM_VOLUME_FORMAT_CUBIC, vol);
> > > -    else
> > > -        g_warning("gst lacks volume capabilities on src");
> > > +    } else if (g_object_class_find_property(G_OBJECT_GET_CLASS (e), "volume") != NULL) {
> > > +        g_object_set(e, "volume", vol, NULL);
> > > +    } else {
> > > +        g_warning("record: ignoring volume change on %s", gst_element_get_name(e));
> > > +    }
> > >  
> > >      g_object_unref(e);
> > >  }
> > > @@ -453,10 +464,13 @@ static void record_mute_changed(GObject *object, GParamSpec *pspec, gpointer dat
> > >      if (!e)
> > >          e = g_object_ref(p->record.src);
> > >  
> > > -    if (GST_IS_STREAM_VOLUME (e))
> > > +    if (GST_IS_STREAM_VOLUME (e)) {
> > >          gst_stream_volume_set_mute(GST_STREAM_VOLUME(e), mute);
> > > -    else
> > > -        g_warning("gst lacks mute capabilities on src: %d", mute);
> > > +    } else if (g_object_class_find_property(G_OBJECT_GET_CLASS (e), "mute") != NULL) {
> > > +        g_object_set(e, "mute", mute, NULL);
> > > +    } else {
> > > +        g_warning("record: ignoring mute change on %s", gst_element_get_name(e));
> > > +    }
> > >  
> > >      g_object_unref(e);
> > >  }
> > > -- 
> > > 2.20.1
> > > 
> > > _______________________________________________
> > > Spice-devel mailing list
> > > Spice-devel at lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/spice-devel
> 
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20190118/66216ea8/attachment-0001.sig>


More information about the Spice-devel mailing list