display-channel: introduce display_channel_get_nth_stream()

To help avoid stream.c and dcc.c to access display-channel private
structure to get the nth Stream structure pointer.

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
Victor Toso 2017-06-29 17:30:47 +02:00
parent 970cb2a1d3
commit 31fb967f1a
4 changed files with 8 additions and 2 deletions

View File

@ -487,7 +487,7 @@ static void dcc_init_stream_agents(DisplayChannelClient *dcc)
for (i = 0; i < NUM_STREAMS; i++) {
StreamAgent *agent = &dcc->priv->stream_agents[i];
agent->stream = &display->priv->streams_buf[i];
agent->stream = display_channel_get_nth_stream(display, i);
region_init(&agent->vis_region);
region_init(&agent->clip);
}

View File

@ -2416,6 +2416,11 @@ int display_channel_get_stream_id(DisplayChannel *display, Stream *stream)
return (int)(stream - display->priv->streams_buf);
}
Stream *display_channel_get_nth_stream(DisplayChannel *display, gint i)
{
return &display->priv->streams_buf[i];
}
gboolean display_channel_validate_surface(DisplayChannel *display, uint32_t surface_id)
{
if SPICE_UNLIKELY(surface_id >= display->priv->n_surfaces) {

View File

@ -184,6 +184,7 @@ typedef struct RedSurface {
_iter, DisplayChannelClient, _data)
int display_channel_get_stream_id(DisplayChannel *display, Stream *stream);
Stream *display_channel_get_nth_stream(DisplayChannel *display, gint i);
typedef struct RedSurfaceDestroyItem {
RedPipeItem pipe_item;

View File

@ -141,7 +141,7 @@ void display_channel_init_streams(DisplayChannel *display)
ring_init(&display->priv->streams);
display->priv->free_streams = NULL;
for (i = 0; i < NUM_STREAMS; i++) {
Stream *stream = &display->priv->streams_buf[i];
Stream *stream = display_channel_get_nth_stream(display, i);
ring_item_init(&stream->link);
stream_free(display, stream);
}