[PATCH spice-server v3 1/2] stream-channel: Factor out a function to create StreamDataItem

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

 



Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/stream-channel.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/server/stream-channel.c b/server/stream-channel.c
index 680fa3d1..fc409ee6 100644
--- a/server/stream-channel.c
+++ b/server/stream-channel.c
@@ -537,6 +537,20 @@ data_item_free(RedPipeItem *base)
     g_free(pipe_item);
 }
 
+static StreamDataItem*
+stream_data_item_new(StreamChannel *channel, size_t size, uint32_t mm_time)
+{
+    StreamDataItem *item = g_malloc(sizeof(*item) + size);
+    red_pipe_item_init_full(&item->base, RED_PIPE_ITEM_TYPE_STREAM_DATA,
+                            data_item_free);
+    item->data.base.id = channel->stream_id;
+    item->data.base.multi_media_time = mm_time;
+    item->data.data_size = size;
+    item->channel = channel;
+
+    return item;
+}
+
 void
 stream_channel_send_data(StreamChannel *channel, const void *data, size_t size, uint32_t mm_time)
 {
@@ -549,13 +563,7 @@ stream_channel_send_data(StreamChannel *channel, const void *data, size_t size,
 
     RedChannel *red_channel = RED_CHANNEL(channel);
 
-    StreamDataItem *item = g_malloc(sizeof(*item) + size);
-    red_pipe_item_init_full(&item->base, RED_PIPE_ITEM_TYPE_STREAM_DATA,
-                            data_item_free);
-    item->data.base.id = channel->stream_id;
-    item->data.base.multi_media_time = mm_time;
-    item->data.data_size = size;
-    item->channel = channel;
+    StreamDataItem *item = stream_data_item_new(channel, size, mm_time);
     stream_channel_update_queue_stat(channel, 1, size);
     // TODO try to optimize avoiding the copy
     memcpy(item->data.data, data, size);
-- 
2.17.0

_______________________________________________
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]