summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2013-09-25 16:05:30 +0200
committerFrediano Ziglio <fziglio@redhat.com>2015-11-24 08:57:01 +0000
commitacba59bb9b0e3a5e362139b00f49006e90bbde11 (patch)
treeb6474a28ac79a6bf515063dddf712afa78b41f94 /server
parent6df1558523c624dbbf414a034e673d277fe8a439 (diff)
downloadspice-acba59bb9b0e3a5e362139b00f49006e90bbde11.zip
spice-acba59bb9b0e3a5e362139b00f49006e90bbde11.tar.gz
spice-acba59bb9b0e3a5e362139b00f49006e90bbde11.tar.xz
worker: move attach_stream
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
Diffstat (limited to 'server')
-rw-r--r--server/red_worker.c56
-rw-r--r--server/stream.c56
-rw-r--r--server/stream.h1
3 files changed, 56 insertions, 57 deletions
diff --git a/server/red_worker.c b/server/red_worker.c
index 443e00a..f64befa 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -159,50 +159,6 @@ static void red_create_surface(DisplayChannel *display, uint32_t surface_id, uin
uint32_t height, int32_t stride, uint32_t format,
void *line_0, int data_is_valid, int send_client);
-void attach_stream(DisplayChannel *display, Drawable *drawable, Stream *stream)
-{
- DisplayChannelClient *dcc;
- RingItem *item, *next;
-
- spice_assert(!drawable->stream && !stream->current);
- spice_assert(drawable && stream);
- stream->current = drawable;
- drawable->stream = stream;
- stream->last_time = drawable->creation_time;
-
- uint64_t duration = drawable->creation_time - stream->input_fps_start_time;
- if (duration >= RED_STREAM_INPUT_FPS_TIMEOUT) {
- /* Round to the nearest integer, for instance 24 for 23.976 */
- stream->input_fps = ((uint64_t)stream->num_input_frames * 1000 * 1000 * 1000 + duration / 2) / duration;
- spice_debug("input-fps=%u", stream->input_fps);
- stream->num_input_frames = 0;
- stream->input_fps_start_time = drawable->creation_time;
- } else {
- stream->num_input_frames++;
- }
-
- FOREACH_DCC(display, item, next, dcc) {
- StreamAgent *agent;
- QRegion clip_in_draw_dest;
-
- agent = &dcc->stream_agents[get_stream_id(display, stream)];
- region_or(&agent->vis_region, &drawable->tree_item.base.rgn);
-
- region_init(&clip_in_draw_dest);
- region_add(&clip_in_draw_dest, &drawable->red_drawable->bbox);
- region_and(&clip_in_draw_dest, &agent->clip);
-
- if (!region_is_equal(&clip_in_draw_dest, &drawable->tree_item.base.rgn)) {
- region_remove(&agent->clip, &drawable->red_drawable->bbox);
- region_or(&agent->clip, &drawable->tree_item.base.rgn);
- dcc_stream_agent_clip(dcc, agent);
- }
-#ifdef STREAM_STATS
- agent->stats.num_input_frames++;
-#endif
- }
-}
-
QXLInstance* red_worker_get_qxl(RedWorker *worker)
{
spice_return_val_if_fail(worker != NULL, NULL);
@@ -624,18 +580,6 @@ static void red_clear_surface_drawables_from_pipes(DisplayChannel *display,
}
}
-void detach_stream(DisplayChannel *display, Stream *stream,
- int detach_sized)
-{
- spice_assert(stream->current && stream->current->stream);
- spice_assert(stream->current->stream == stream);
- stream->current->stream = NULL;
- if (detach_sized) {
- stream->current->sized_stream = NULL;
- }
- stream->current = NULL;
-}
-
static int red_display_drawable_is_in_pipe(DisplayChannelClient *dcc, Drawable *drawable)
{
DrawablePipeItem *dpi;
diff --git a/server/stream.c b/server/stream.c
index 518e2d8..8d16658 100644
--- a/server/stream.c
+++ b/server/stream.c
@@ -258,6 +258,62 @@ static int is_next_stream_frame(DisplayChannel *display,
}
}
+static void attach_stream(DisplayChannel *display, Drawable *drawable, Stream *stream)
+{
+ DisplayChannelClient *dcc;
+ RingItem *item, *next;
+
+ spice_assert(!drawable->stream && !stream->current);
+ spice_assert(drawable && stream);
+ stream->current = drawable;
+ drawable->stream = stream;
+ stream->last_time = drawable->creation_time;
+
+ uint64_t duration = drawable->creation_time - stream->input_fps_start_time;
+ if (duration >= RED_STREAM_INPUT_FPS_TIMEOUT) {
+ /* Round to the nearest integer, for instance 24 for 23.976 */
+ stream->input_fps = ((uint64_t)stream->num_input_frames * 1000 * 1000 * 1000 + duration / 2) / duration;
+ spice_debug("input-fps=%u", stream->input_fps);
+ stream->num_input_frames = 0;
+ stream->input_fps_start_time = drawable->creation_time;
+ } else {
+ stream->num_input_frames++;
+ }
+
+ FOREACH_DCC(display, item, next, dcc) {
+ StreamAgent *agent;
+ QRegion clip_in_draw_dest;
+
+ agent = &dcc->stream_agents[get_stream_id(display, stream)];
+ region_or(&agent->vis_region, &drawable->tree_item.base.rgn);
+
+ region_init(&clip_in_draw_dest);
+ region_add(&clip_in_draw_dest, &drawable->red_drawable->bbox);
+ region_and(&clip_in_draw_dest, &agent->clip);
+
+ if (!region_is_equal(&clip_in_draw_dest, &drawable->tree_item.base.rgn)) {
+ region_remove(&agent->clip, &drawable->red_drawable->bbox);
+ region_or(&agent->clip, &drawable->tree_item.base.rgn);
+ dcc_stream_agent_clip(dcc, agent);
+ }
+#ifdef STREAM_STATS
+ agent->stats.num_input_frames++;
+#endif
+ }
+}
+
+void detach_stream(DisplayChannel *display, Stream *stream,
+ int detach_sized)
+{
+ spice_assert(stream->current && stream->current->stream);
+ spice_assert(stream->current->stream == stream);
+ stream->current->stream = NULL;
+ if (detach_sized) {
+ stream->current->sized_stream = NULL;
+ }
+ stream->current = NULL;
+}
+
static void before_reattach_stream(DisplayChannel *display,
Stream *stream, Drawable *new_frame)
{
diff --git a/server/stream.h b/server/stream.h
index 65de2f4..7c589e4 100644
--- a/server/stream.h
+++ b/server/stream.h
@@ -154,7 +154,6 @@ void stream_agent_unref (DisplayChan
void stream_agent_stats_print (StreamAgent *agent);
void stream_agent_stop (StreamAgent *agent);
-void attach_stream(DisplayChannel *display, Drawable *drawable, Stream *stream);
void detach_stream(DisplayChannel *display, Stream *stream, int detach_sized);
#endif /* STREAM_H */