Re: [PATCH spice-gtk 2/2] spicy: send ordered list of preferred video codecs

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

 



On Thu, Jul 11, 2019 at 10:08 AM Victor Toso <victortoso@xxxxxxxxxx> wrote:
>
> On Thu, Jul 04, 2019 at 12:29:22PM +0200, Kevin Pouget wrote:
> > Instead of sending only the preferred video codec (selected), spicy
> > now sends an ordered list. When a video codec is selected in the radio
> > box, this codec is moved to beginning of the list.
> >
> > Signed-off-by: Kevin Pouget <kpouget@xxxxxxxxxx>
> > ---
> >  tools/spicy.c | 31 +++++++++++++++++++++++++++++--
> >  1 file changed, 29 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/spicy.c b/tools/spicy.c
> > index 8a6d077..403a66d 100644
> > --- a/tools/spicy.c
> > +++ b/tools/spicy.c
> > @@ -1014,8 +1014,35 @@ static void video_codec_type_cb(GtkRadioAction *action G_GNUC_UNUSED,
> >                                  GtkRadioAction *current,
> >                                  gpointer user_data)
> >  {
> > -    spice_display_channel_change_preferred_video_codec_type(SPICE_CHANNEL(user_data),
> > -                                                            gtk_radio_action_get_current_value(current));
> > +    static GArray *preferred_codecs = NULL;
> > +    gint selected_codec = gtk_radio_action_get_current_value(current);
> > +    guint i;
> > +    GError *err = NULL;
> > +
> > +    if (!preferred_codecs) {
> > +        preferred_codecs = g_array_sized_new(FALSE, FALSE,
> > +                                             sizeof(gint),
> > +                                             G_N_ELEMENTS(video_codec_type_entries));
>
> This will leak, no? Maybe move the static var to global scope and
> cleanup in the end of main() ?

my rule/understanding is that memory allocated once, and accessible
all along the execution, is not considered as a leak,
so I wouldn't change it, even if it were not a testing tool

(let me know if I'm wrong!)

> Not a big issue, this is just testing tool. Either way,
>
> Acked-by: Victor Toso <victortoso@xxxxxxxxxx>

thanks,

Kevin


> > +        /* initialize with the menu ordering */
> > +        for (i = 0; i < G_N_ELEMENTS(video_codec_type_entries); i++) {
> > +            g_array_append_val(preferred_codecs, video_codec_type_entries[i].value);
> > +        }
> > +    }
> > +
> > +    /* remove codec from array and insert at the beginning */
> > +    for (i = 0; i < preferred_codecs->len &&
> > +                g_array_index(preferred_codecs, gint, i) != selected_codec; i++);
> > +
> > +    g_assert(i < preferred_codecs->len);
> > +    g_array_remove_index(preferred_codecs, i);
> > +    g_array_prepend_val(preferred_codecs, selected_codec);
> > +
> > +    if (!spice_display_channel_change_preferred_video_codec_types(SPICE_CHANNEL(user_data),
> > +                                                                  (gint *) preferred_codecs->data,
> > +                                                                  preferred_codecs->len, &err)) {
> > +        g_warning("setting preferred video codecs failed: %s", err->message);
> > +        g_error_free(err);
> > +    }
> >  }
> >
> >  static void
> > --
> > 2.21.0
> >
> > _______________________________________________
> > Spice-devel mailing list
> > Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> > https://lists.freedesktop.org/mailman/listinfo/spice-devel
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




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