[Spice-commits] 2 commits - server/dcc.c server/display-channel.c server/display-channel.h server/stream.c

Victor Toso de Carvalho victortoso at kemper.freedesktop.org
Fri Jun 30 10:32:02 UTC 2017


 server/dcc.c             |    2 +-
 server/display-channel.c |    5 +++++
 server/display-channel.h |    1 +
 server/stream.c          |    4 ++--
 4 files changed, 9 insertions(+), 3 deletions(-)

New commits:
commit 31fb967f1a13d9a0af01ccab2e304ff12ea9f300
Author: Victor Toso <me at victortoso.com>
Date:   Thu Jun 29 17:30:47 2017 +0200

    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 at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/dcc.c b/server/dcc.c
index f8393362..a9529fae 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -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);
     }
diff --git a/server/display-channel.c b/server/display-channel.c
index bebee3bb..68ea3bad 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -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) {
diff --git a/server/display-channel.h b/server/display-channel.h
index 436cd33e..d15aad46 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -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;
diff --git a/server/stream.c b/server/stream.c
index 9a3a82d1..ff2676cf 100644
--- a/server/stream.c
+++ b/server/stream.c
@@ -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);
     }
commit 970cb2a1d3ccf35bea68bdd5a0144b2a2f6a3e3d
Author: Victor Toso <me at victortoso.com>
Date:   Thu Jun 29 17:20:22 2017 +0200

    stream: use display_channel_get_stream_id()
    
    As we have a function for that, don't do the math elsewhere.
    
    Signed-off-by: Victor Toso <victortoso at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/stream.c b/server/stream.c
index 838c6436..9a3a82d1 100644
--- a/server/stream.c
+++ b/server/stream.c
@@ -422,7 +422,7 @@ static void display_channel_create_stream(DisplayChannel *display, Drawable *dra
         dcc_create_stream(dcc, stream);
     }
     spice_debug("stream %d %dx%d (%d, %d) (%d, %d) %u fps",
-                (int)(stream - display->priv->streams_buf), stream->width,
+                display_channel_get_stream_id(display, stream), stream->width,
                 stream->height, stream->dest_area.left, stream->dest_area.top,
                 stream->dest_area.right, stream->dest_area.bottom,
                 stream->input_fps);


More information about the Spice-commits mailing list