[Spice-devel] [PATCH spice-server 14/15] Move display_channel_init_video_streams()

Jonathon Jongsma jjongsma at redhat.com
Fri Oct 20 21:13:19 UTC 2017


Move this function into display-channel.c since it deals with how the
DisplayChannel allocates and manages the video streams, rather than
implementation of VideoStream. Also move some helper functions that are
DisplayChannel-specific.
---
 server/display-channel.c | 26 ++++++++++++++++++++++++++
 server/display-channel.h |  2 ++
 server/video-stream.c    | 28 +---------------------------
 server/video-stream.h    |  1 -
 4 files changed, 29 insertions(+), 28 deletions(-)

diff --git a/server/display-channel.c b/server/display-channel.c
index 360c887f8..8c3d72899 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -2273,6 +2273,32 @@ display_channel_init(DisplayChannel *self)
     self->priv->image_surfaces.ops = &image_surfaces_ops;
 }
 
+static void video_stream_recycle(DisplayChannel *display, VideoStream *stream)
+{
+    stream->next = display->priv->free_streams;
+    display->priv->free_streams = stream;
+}
+
+void display_channel_free_video_stream(DisplayChannel *display,
+                                       VideoStream *stream)
+{
+    video_stream_recycle(display, stream);
+    display->priv->stream_count--;
+}
+
+static void display_channel_init_video_streams(DisplayChannel *display)
+{
+    int i;
+
+    ring_init(&display->priv->streams);
+    display->priv->free_streams = NULL;
+    for (i = 0; i < NUM_STREAMS; i++) {
+        VideoStream *stream = display_channel_get_nth_stream(display, i);
+        ring_item_init(&stream->link);
+        video_stream_recycle(display, stream);
+    }
+}
+
 static void
 display_channel_constructed(GObject *object)
 {
diff --git a/server/display-channel.h b/server/display-channel.h
index 4f7def216..377fc7ea7 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -157,6 +157,8 @@ void                       display_channel_gl_scanout                (DisplayCha
 void                       display_channel_gl_draw                   (DisplayChannel *display,
                                                                       SpiceMsgDisplayGlDraw *draw);
 void                       display_channel_gl_draw_done              (DisplayChannel *display);
+void                       display_channel_free_video_stream         (DisplayChannel *display,
+                                                                      VideoStream *stream);
 
 void display_channel_update_monitors_config(DisplayChannel *display, QXLMonitorsConfig *config,
                                             uint16_t count, uint16_t max_allowed);
diff --git a/server/video-stream.c b/server/video-stream.c
index 757497950..a88d0ae5f 100644
--- a/server/video-stream.c
+++ b/server/video-stream.c
@@ -45,32 +45,6 @@ void video_stream_stop(DisplayChannel *display, VideoStream *stream)
     video_stream_unref(stream);
 }
 
-static void video_stream_recycle(DisplayChannel *display, VideoStream *stream)
-{
-    stream->next = display->priv->free_streams;
-    display->priv->free_streams = stream;
-}
-
-static void video_stream_free(VideoStream *stream)
-{
-    DisplayChannel *display = stream->display;
-    video_stream_recycle(display, stream);
-    display->priv->stream_count--;
-}
-
-void display_channel_init_video_streams(DisplayChannel *display)
-{
-    int i;
-
-    ring_init(&display->priv->streams);
-    display->priv->free_streams = NULL;
-    for (i = 0; i < NUM_STREAMS; i++) {
-        VideoStream *stream = display_channel_get_nth_stream(display, i);
-        ring_item_init(&stream->link);
-        video_stream_recycle(display, stream);
-    }
-}
-
 void video_stream_unref(VideoStream *stream)
 {
     if (--stream->refs != 0)
@@ -78,7 +52,7 @@ void video_stream_unref(VideoStream *stream)
 
     spice_warn_if_fail(!ring_item_is_linked(&stream->link));
 
-    video_stream_free(stream);
+    display_channel_free_video_stream(stream->display, stream);
 }
 
 void video_stream_agent_unref(VideoStreamAgent *agent)
diff --git a/server/video-stream.h b/server/video-stream.h
index f818c8c5d..cc1b7b0ce 100644
--- a/server/video-stream.h
+++ b/server/video-stream.h
@@ -114,7 +114,6 @@ struct VideoStream {
     DisplayChannel *display;
 };
 
-void                  display_channel_init_video_streams            (DisplayChannel *display);
 void                  video_stream_stop                             (DisplayChannel *display,
                                                                      VideoStream *stream);
 void                  video_stream_unref                            (VideoStream *stream);
-- 
2.13.6



More information about the Spice-devel mailing list