[Spice-devel] [RFC v4 58/62] server/reds: make reds_fill_channels return no sound channels for client > 1
Alon Levy
alevy at redhat.com
Tue Apr 26 03:55:23 PDT 2011
At this point you can actually connect a second client without disconnecting the
first due to the sound channel doing the disconnect. Since sound has not
been multiple client enabled yet this is all that can be done.
---
server/reds.c | 30 ++++++++++++++++++++++++++----
1 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/server/reds.c b/server/reds.c
index dc73202..4abebb8 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -960,18 +960,40 @@ int reds_num_of_channels()
return reds ? reds->num_of_channels : 0;
}
+static int secondary_channels[] = {
+ SPICE_CHANNEL_MAIN, SPICE_CHANNEL_DISPLAY, SPICE_CHANNEL_CURSOR, SPICE_CHANNEL_INPUTS};
+
+static int channel_is_secondary(Channel *channel)
+{
+ int i;
+ for (i = 0 ; i < sizeof(secondary_channels)/sizeof(secondary_channels[0]); ++i) {
+ if (channel->type == secondary_channels[i]) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
void reds_fill_channels(SpiceMsgChannels *channels_info)
{
Channel *channel;
int i;
+ int used_channels = 0;
channels_info->num_of_channels = reds->num_of_channels;
channel = reds->channels;
- for (i = 0; i < reds->num_of_channels; i++) {
+ for (i = 0; i < reds->num_of_channels; i++, channel = channel->next) {
ASSERT(channel);
- channels_info->channels[i].type = channel->type;
- channels_info->channels[i].id = channel->id;
- channel = channel->next;
+ if (reds->num_clients > 1 && !channel_is_secondary(channel)) {
+ continue;
+ }
+ channels_info->channels[used_channels].type = channel->type;
+ channels_info->channels[used_channels].id = channel->id;
+ used_channels++;
+ }
+ channels_info->num_of_channels = used_channels;
+ if (used_channels != reds->num_of_channels) {
+ red_printf("sent %d out of %d", used_channels, reds->num_of_channels);
}
}
--
1.7.4.4
More information about the Spice-devel
mailing list