[RFC PATCH 08/16] stream-device: Create channel for stream device

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

 



So can be used by the device to communicate with the clients.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/stream-device.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/server/stream-device.c b/server/stream-device.c
index 96a6b92..35ba3f0 100644
--- a/server/stream-device.c
+++ b/server/stream-device.c
@@ -22,6 +22,8 @@
 #include <spice/stream-device.h>
 
 #include "char-device.h"
+#include "stream-channel.h"
+#include "reds.h"
 
 #define STREAM_TYPE_DEVICE stream_device_get_type()
 
@@ -41,8 +43,10 @@ typedef struct StreamDeviceClass StreamDeviceClass;
 
 struct StreamDevice {
     RedCharDevice parent;
+
     StreamDevHeader hdr;
     uint8_t hdr_pos;
+    StreamChannel *channel;
 };
 
 struct StreamDeviceClass {
@@ -162,7 +166,10 @@ stream_device_connect(RedsState *reds, SpiceCharDeviceInstance *sin)
 {
     SpiceCharDeviceInterface *sif;
 
+    StreamChannel *channel = stream_channel_new(reds);
+
     StreamDevice *dev = stream_device_new(sin, reds);
+    dev->channel = channel;
 
     sif = spice_char_device_get_interface(sin);
     if (sif->state) {
@@ -175,6 +182,19 @@ stream_device_connect(RedsState *reds, SpiceCharDeviceInstance *sin)
 static void
 stream_device_dispose(GObject *object)
 {
+    StreamDevice *device = STREAM_DEVICE(object);
+
+    if (device->channel) {
+        RedChannel *red_channel = RED_CHANNEL(device->channel);
+        RedsState *reds = red_channel_get_server(red_channel);
+
+        // prevent future connection
+        reds_unregister_channel(reds, red_channel);
+
+        // close all current connections and drop the reference
+        red_channel_destroy(red_channel);
+        device->channel = NULL;
+    }
 }
 
 static void
-- 
git-series 0.9.1
_______________________________________________
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]