[Spice-commits] server/Makefile.am server/char-device.h server/reds.c server/stream-device.c server/stream-device.h
Frediano Ziglio
fziglio at kemper.freedesktop.org
Thu Mar 8 11:01:56 UTC 2018
server/Makefile.am | 1 +
server/char-device.h | 1 -
server/reds.c | 3 ++-
server/stream-device.c | 20 ++++----------------
server/stream-device.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 55 insertions(+), 18 deletions(-)
New commits:
commit 6bd9a486a99f6f85e78406c54ad1c280b0d1f7f0
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Wed Mar 7 07:43:56 2018 +0000
stream-device: Separate declaration in a separate header
Move public declaration (stream_device_connect) from char-device.h
to a new stream-device.h.
Add type declaration for StreamDevice.
This allows to use the type outside the implementation file and makes it
easier to extend the interface without changing char-device.h header.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/server/Makefile.am b/server/Makefile.am
index b0e8597f..61725990 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -168,6 +168,7 @@ libserver_la_SOURCES = \
stream-channel.c \
stream-channel.h \
stream-device.c \
+ stream-device.h \
sw-canvas.c \
tree.c \
tree.h \
diff --git a/server/char-device.h b/server/char-device.h
index 54a1ef93..dccd576d 100644
--- a/server/char-device.h
+++ b/server/char-device.h
@@ -236,7 +236,6 @@ RedCharDevice *spicevmc_device_connect(RedsState *reds,
uint8_t channel_type);
void spicevmc_device_disconnect(RedsState *reds,
SpiceCharDeviceInstance *char_device);
-RedCharDevice *stream_device_connect(RedsState *reds, SpiceCharDeviceInstance *sin);
SpiceCharDeviceInterface *spice_char_device_get_interface(SpiceCharDeviceInstance *instance);
diff --git a/server/reds.c b/server/reds.c
index a31ed4e9..9660476c 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -74,6 +74,7 @@
#include "red-client.h"
#include "glib-compat.h"
#include "net-utils.h"
+#include "stream-device.h"
#define REDS_MAX_STAT_NODES 100
@@ -3108,7 +3109,7 @@ static int spice_server_char_device_add_interface(SpiceServer *reds,
if (strcmp(char_device->portname, "org.spice-space.webdav.0") == 0) {
dev_state = spicevmc_device_connect(reds, char_device, SPICE_CHANNEL_WEBDAV);
} else if (strcmp(char_device->portname, "com.redhat.stream.0") == 0) {
- dev_state = stream_device_connect(reds, char_device);
+ dev_state = RED_CHAR_DEVICE(stream_device_connect(reds, char_device));
} else {
dev_state = spicevmc_device_connect(reds, char_device, SPICE_CHANNEL_PORT);
}
diff --git a/server/stream-device.c b/server/stream-device.c
index dc58dce6..fd73e784 100644
--- a/server/stream-device.c
+++ b/server/stream-device.c
@@ -19,25 +19,14 @@
#include <config.h>
#endif
+#include "stream-device.h"
+
#include <spice/stream-device.h>
-#include "char-device.h"
#include "stream-channel.h"
#include "cursor-channel.h"
#include "reds.h"
-#define TYPE_STREAM_DEVICE stream_device_get_type()
-
-#define STREAM_DEVICE(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_STREAM_DEVICE, StreamDevice))
-#define STREAM_DEVICE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), TYPE_STREAM_DEVICE, StreamDeviceClass))
-#define STREAM_DEVICE_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), TYPE_STREAM_DEVICE, StreamDeviceClass))
-
-typedef struct StreamDevice StreamDevice;
-typedef struct StreamDeviceClass StreamDeviceClass;
-
struct StreamDevice {
RedCharDevice parent;
@@ -64,7 +53,6 @@ struct StreamDeviceClass {
RedCharDeviceClass parent_class;
};
-static GType stream_device_get_type(void) G_GNUC_CONST;
static StreamDevice *stream_device_new(SpiceCharDeviceInstance *sin, RedsState *reds);
G_DEFINE_TYPE(StreamDevice, stream_device, RED_TYPE_CHAR_DEVICE)
@@ -504,7 +492,7 @@ stream_device_stream_queue_stat(void *opaque, const StreamQueueStat *stats G_GNU
}
}
-RedCharDevice *
+StreamDevice *
stream_device_connect(RedsState *reds, SpiceCharDeviceInstance *sin)
{
SpiceCharDeviceInterface *sif;
@@ -516,7 +504,7 @@ stream_device_connect(RedsState *reds, SpiceCharDeviceInstance *sin)
sif->state(sin, 1);
}
- return RED_CHAR_DEVICE(dev);
+ return dev;
}
static void
diff --git a/server/stream-device.h b/server/stream-device.h
new file mode 100644
index 00000000..eff6e870
--- /dev/null
+++ b/server/stream-device.h
@@ -0,0 +1,48 @@
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ Copyright (C) 2018 Red Hat, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef STREAM_DEVICE_H
+#define STREAM_DEVICE_H
+
+#include "char-device.h"
+
+G_BEGIN_DECLS
+
+/**
+ * StreamDevice inherits from RedCharDevice.
+ */
+typedef struct StreamDevice StreamDevice;
+typedef struct StreamDeviceClass StreamDeviceClass;
+
+#define TYPE_STREAM_DEVICE stream_device_get_type()
+
+#define STREAM_DEVICE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_STREAM_DEVICE, StreamDevice))
+#define STREAM_DEVICE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), TYPE_STREAM_DEVICE, StreamDeviceClass))
+#define IS_STREAM_DEVICE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), TYPE_STREAM_DEVICE))
+#define STREAM_DEVICE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), TYPE_STREAM_DEVICE, StreamDeviceClass))
+
+GType stream_device_get_type(void) G_GNUC_CONST;
+StreamDevice *stream_device_connect(RedsState *reds, SpiceCharDeviceInstance *sin);
+
+G_END_DECLS
+
+#endif /* STREAM_DEVICE_H */
More information about the Spice-commits
mailing list