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

Victor Toso victortoso at redhat.com
Thu Jul 11 08:08:45 UTC 2019


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 at redhat.com>
> ---
>  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() ?

Not a big issue, this is just testing tool. Either way,

Acked-by: Victor Toso <victortoso at redhat.com>

> +        /* 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 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/20190711/2116b07b/attachment.sig>


More information about the Spice-devel mailing list