Limit maximum "n-surfaces" via param spec

In commit beec1b41, we manually limited this property value in
_set_property(). But there's a simpler way to do it: via the param spec
for the property.

This also means that we can remove the warning log in red_worker_new()
since GObject will automatically warn if a property is assigned a value
outside of its valid range.

Change the minimum and default value for this property from 0 to 1 so
that we always have a primary surface.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
Jonathon Jongsma 2016-10-31 16:06:51 -05:00 committed by Frediano Ziglio
parent 5fba8dd1a3
commit 207cd10dcc
2 changed files with 2 additions and 5 deletions

View File

@ -60,7 +60,6 @@ display_channel_set_property(GObject *object,
{
case PROP_N_SURFACES:
self->priv->n_surfaces = g_value_get_uint(value);
self->priv->n_surfaces = MIN(self->priv->n_surfaces, NUM_SURFACES);
break;
case PROP_VIDEO_CODECS:
if (self->priv->video_codecs) {
@ -2238,8 +2237,8 @@ display_channel_class_init(DisplayChannelClass *klass)
g_param_spec_uint("n-surfaces",
"number of surfaces",
"Number of surfaces for this channel",
0, G_MAXUINT,
0,
1, NUM_SURFACES,
1,
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));

View File

@ -1358,8 +1358,6 @@ RedWorker* red_worker_new(QXLInstance *qxl,
init_info.memslot_id_bits,
init_info.internal_groupslot_id);
spice_warn_if_fail(init_info.n_surfaces <= NUM_SURFACES);
worker->event_timeout = INF_EVENT_WAIT;
worker->cursor_channel = cursor_channel_new(reds, qxl,