[Spice-devel] [RFC PATCH spice-server v4 07/22] stream-device: Create channel for stream device
Frediano Ziglio
fziglio at redhat.com
Fri Aug 25 09:53:54 UTC 2017
So can be used by the device to communicate with the clients.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
server/stream-device.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/server/stream-device.c b/server/stream-device.c
index e343f1f5..0551e5b5 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 TYPE_STREAM_DEVICE stream_device_get_type()
@@ -37,9 +39,11 @@ typedef struct StreamDeviceClass StreamDeviceClass;
struct StreamDevice {
RedCharDevice parent;
+
StreamDevHeader hdr;
uint8_t hdr_pos;
bool has_error;
+ StreamChannel *stream_channel;
};
struct StreamDeviceClass {
@@ -189,7 +193,10 @@ stream_device_connect(RedsState *reds, SpiceCharDeviceInstance *sin)
{
SpiceCharDeviceInterface *sif;
+ StreamChannel *stream_channel = stream_channel_new(reds, 1); // TODO id
+
StreamDevice *dev = stream_device_new(sin, reds);
+ dev->stream_channel = stream_channel;
sif = spice_char_device_get_interface(sin);
if (sif->state) {
@@ -202,6 +209,13 @@ stream_device_connect(RedsState *reds, SpiceCharDeviceInstance *sin)
static void
stream_device_dispose(GObject *object)
{
+ StreamDevice *device = STREAM_DEVICE(object);
+
+ if (device->stream_channel) {
+ // close all current connections and drop the reference
+ red_channel_destroy(RED_CHANNEL(device->stream_channel));
+ device->stream_channel = NULL;
+ }
}
static void
--
2.13.5
More information about the Spice-devel
mailing list