Re: [RFC PATCH spice-server v5 16/22] stream-device: Create channel when needed

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

 



Acked-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>


On Wed, 2017-08-30 at 16:28 +0100, Frediano Ziglio wrote:
> This allows a better id allocation as devices are created after
> fixed ones.
> Also will allow to support more easily multiple monitor.
> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  server/stream-device.c | 38 ++++++++++++++++++++++++++++++++------
>  1 file changed, 32 insertions(+), 6 deletions(-)
> 
> diff --git a/server/stream-device.c b/server/stream-device.c
> index 9e401f8e..ae108788 100644
> --- a/server/stream-device.c
> +++ b/server/stream-device.c
> @@ -72,7 +72,7 @@ stream_device_read_msg_from_dev(RedCharDevice
> *self, SpiceCharDeviceInstance *si
>      int n;
>      bool handled = false;
>  
> -    if (dev->has_error) {
> +    if (dev->has_error || !dev->stream_channel) {
>          return NULL;
>      }
>  
> @@ -238,11 +238,7 @@ 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;
> -    stream_channel_register_start_cb(stream_channel,
> stream_device_stream_start, dev);
>  
>      sif = spice_char_device_get_interface(sin);
>      if (sif->state) {
> @@ -265,6 +261,33 @@ stream_device_dispose(GObject *object)
>  }
>  
>  static void
> +allocate_channels(StreamDevice *dev)
> +{
> +    if (dev->stream_channel) {
> +        return;
> +    }
> +
> +    SpiceServer* reds =
> red_char_device_get_server(RED_CHAR_DEVICE(dev));
> +
> +    int id = reds_get_free_channel_id(reds, SPICE_CHANNEL_DISPLAY);
> +    g_return_if_fail(id >= 0);
> +
> +    StreamChannel *stream_channel = stream_channel_new(reds, id);
> +
> +    dev->stream_channel = stream_channel;
> +
> +    stream_channel_register_start_cb(stream_channel,
> stream_device_stream_start, dev);
> +}
> +
> +static void
> +reset_channels(StreamDevice *dev)
> +{
> +    if (dev->stream_channel) {
> +        stream_channel_reset(dev->stream_channel);
> +    }
> +}
> +
> +static void
>  stream_device_port_event(RedCharDevice *char_dev, uint8_t event)
>  {
>      if (event != SPICE_PORT_EVENT_OPENED && event !=
> SPICE_PORT_EVENT_CLOSED) {
> @@ -275,10 +298,13 @@ stream_device_port_event(RedCharDevice
> *char_dev, uint8_t event)
>  
>      // reset device and channel on close/open
>      dev->opened = (event == SPICE_PORT_EVENT_OPENED);
> +    if (dev->opened) {
> +        allocate_channels(dev);
> +    }
>      dev->hdr_pos = 0;
>      dev->has_error = false;
>      red_char_device_reset(char_dev);
> -    stream_channel_reset(dev->stream_channel);
> +    reset_channels(dev);
>  }
>  
>  static void
_______________________________________________
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]