[PATCH spice-server 6/7] video_stream_detach_and_stop -> display_channel_stop_video_streams()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rename this function and move it to display-channel.[ch]. This function
is really a DisplayChannel method, since it iterates through all of the
channel's streams and detaches and stops them. Because of this change,
detach_video_stream_gracefully() could also be made static and moved to
display-channel.c. However, we temporarily need to expose
dcc_detach_stream_gracefully() from video-stream.h. This function will
be moved to the channel client source file in a subsequent commit.

Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
---
 server/display-channel.c | 26 ++++++++++++++++++++++++++
 server/display-channel.h |  1 +
 server/red-worker.c      |  2 +-
 server/video-stream.c    | 33 +++------------------------------
 server/video-stream.h    |  7 +++----
 5 files changed, 34 insertions(+), 35 deletions(-)

diff --git a/server/display-channel.c b/server/display-channel.c
index 35c2a0197..e41a05a0d 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -2277,6 +2277,20 @@ static gboolean video_timeout_source_check(GSource *source)
     return ready;
 }
 
+static void detach_video_stream_gracefully(DisplayChannel *display,
+                                           VideoStream *stream,
+                                           Drawable *update_area_limit)
+{
+    DisplayChannelClient *dcc;
+
+    FOREACH_DCC(display, dcc) {
+        dcc_detach_stream_gracefully(dcc, stream, update_area_limit);
+    }
+    if (stream->current) {
+        video_stream_detach_drawable(stream);
+    }
+}
+
 static gboolean video_timeout_source_dispatch(GSource *source, GSourceFunc callback,
                                               gpointer user_data)
 {
@@ -3010,4 +3024,16 @@ void video_stream_maintenance(DisplayChannel *display,
     }
 }
 
+void display_channel_stop_video_streams(DisplayChannel *display)
+{
+    RingItem *stream_item;
+
+    spice_debug("trace");
+    while ((stream_item = ring_get_head(&display->priv->streams))) {
+        VideoStream *stream = SPICE_CONTAINEROF(stream_item, VideoStream, link);
+
+        detach_video_stream_gracefully(display, stream, NULL);
+        video_stream_stop(stream);
+    }
+}
 
diff --git a/server/display-channel.h b/server/display-channel.h
index 0718bb61c..d9a75e3c7 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -168,6 +168,7 @@ void display_channel_reset_image_cache(DisplayChannel *self);
 
 void display_channel_debug_oom(DisplayChannel *display, const char *msg);
 void display_channel_free_video_stream(DisplayChannel *display, VideoStream *stream);
+void display_channel_stop_video_streams(DisplayChannel *display);
 
 G_END_DECLS
 
diff --git a/server/red-worker.c b/server/red-worker.c
index cdf29b329..8d8a53ad0 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -298,7 +298,7 @@ static void red_migrate_display(DisplayChannel *display, RedChannelClient *rcc)
      * Notice that detach_and_stop_streams won't lead to any dev ram changes, since
      * handle_dev_stop already took care of releasing all the dev ram resources.
      */
-    video_stream_detach_and_stop(display);
+    display_channel_stop_video_streams(display);
     if (red_channel_client_is_connected(rcc)) {
         red_channel_client_default_migrate(rcc);
     }
diff --git a/server/video-stream.c b/server/video-stream.c
index 887433417..227824fa0 100644
--- a/server/video-stream.c
+++ b/server/video-stream.c
@@ -413,9 +413,9 @@ static void red_upgrade_item_free(RedPipeItem *base)
  * after dcc_detach_stream_gracefully is called for all the display channel clients,
  * video_stream_detach_drawable should be called. See comment (1).
  */
-static void dcc_detach_stream_gracefully(DisplayChannelClient *dcc,
-                                         VideoStream *stream,
-                                         Drawable *update_area_limit)
+void dcc_detach_stream_gracefully(DisplayChannelClient *dcc,
+                                  VideoStream *stream,
+                                  Drawable *update_area_limit)
 {
     DisplayChannel *display = DCC_TO_DC(dcc);
     int stream_id = display_channel_get_video_stream_id(display, stream);
@@ -477,20 +477,6 @@ clear_vis_region:
     region_clear(&agent->vis_region);
 }
 
-void detach_video_stream_gracefully(DisplayChannel *display,
-                                    VideoStream *stream,
-                                    Drawable *update_area_limit)
-{
-    DisplayChannelClient *dcc;
-
-    FOREACH_DCC(display, dcc) {
-        dcc_detach_stream_gracefully(dcc, stream, update_area_limit);
-    }
-    if (stream->current) {
-        video_stream_detach_drawable(stream);
-    }
-}
-
 /*
  * region  : a primary surface region. Streams that intersects with the given
  *           region will be detached.
@@ -536,16 +522,3 @@ void video_stream_detach_behind(DisplayChannel *display,
     }
 }
 
-void video_stream_detach_and_stop(DisplayChannel *display)
-{
-    RingItem *stream_item;
-
-    spice_debug("trace");
-    while ((stream_item = ring_get_head(&display->priv->streams))) {
-        VideoStream *stream = SPICE_CONTAINEROF(stream_item, VideoStream, link);
-
-        detach_video_stream_gracefully(display, stream, NULL);
-        video_stream_stop(stream);
-    }
-}
-
diff --git a/server/video-stream.h b/server/video-stream.h
index 7e3fd8e70..b1c50ea25 100644
--- a/server/video-stream.h
+++ b/server/video-stream.h
@@ -130,7 +130,6 @@ struct VideoStream {
 
 void video_stream_stop(VideoStream *stream);
 void video_stream_unref(VideoStream *stream);
-void video_stream_detach_and_stop(DisplayChannel *display);
 void video_stream_detach_behind(DisplayChannel *display, QRegion *region,
                                 Drawable *drawable);
 
@@ -138,8 +137,8 @@ void video_stream_agent_unref(VideoStreamAgent *agent);
 void video_stream_agent_stop(VideoStreamAgent *agent);
 
 void video_stream_detach_drawable(VideoStream *stream);
-void detach_video_stream_gracefully(DisplayChannel *display,
-                                    VideoStream *stream,
-                                    Drawable *update_area_limit);
+void dcc_detach_stream_gracefully(DisplayChannelClient *dcc,
+                                  VideoStream *stream,
+                                  Drawable *update_area_limit);
 
 #endif /* VIDEO_STREAM_H_ */
-- 
2.13.6

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]