[Spice-devel] [RFC PATCH spice-server v3 06/20] stream-device: Create channel for stream device
Frediano Ziglio
fziglio at redhat.com
Fri Aug 25 09:25:51 UTC 2017
>
> On Wed, 2017-08-23 at 10:14 +0100, Frediano Ziglio wrote:
> > 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 | 20 ++++++++++++++++++++
> > 1 file changed, 20 insertions(+)
> >
> > diff --git a/server/stream-device.c b/server/stream-device.c
> > index 1c56e41a..026f79c7 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 *channel;
> > };
> >
> > struct StreamDeviceClass {
> > @@ -189,7 +193,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;
>
> Personally, I would rather have this channel allocated and assigned
> within the device constructor rather here.
>
>
> Otherwise, it looks OK.
>
I changed completely this part.
First I renamed "channel" field to "stream_channel" so to
avoid confusion in the future with "cursor_channel".
Second now the IDs are allocated dynamically and the
channel too when the device is opened.
This will allow to easier implement multi monitor support
(which possibly will require multiple StreamChannels)
> >
> > sif = spice_char_device_get_interface(sin);
> > if (sif->state) {
> > @@ -202,6 +209,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
>
Frediano
More information about the Spice-devel
mailing list