summaryrefslogtreecommitdiffstats
path: root/server/inputs_channel.c
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2011-04-02 12:54:52 +0300
committerAlon Levy <alevy@redhat.com>2011-08-23 17:44:54 +0300
commit09ae4700d27b7c1cca64c2ce4c90f0c6cdf81ccf (patch)
treecca9910321cdfe30c4302ba6929e2f7cfa206fae /server/inputs_channel.c
parentb6cf68604f2d184367d0f89834ebcce88e00bad8 (diff)
downloadspice-09ae4700d27b7c1cca64c2ce4c90f0c6cdf81ccf.tar.gz
spice-09ae4700d27b7c1cca64c2ce4c90f0c6cdf81ccf.tar.xz
spice-09ae4700d27b7c1cca64c2ce4c90f0c6cdf81ccf.zip
server: move pipe from RedChannel to RedChannelClient
Another cleanup patch, no change to behavior (still one client, and it disconnects previous client if any). The implementation for multiple client is straightforward: the pipe remains per (channel,client) pair, so it needs to move from the RedChannel that to RedChannelClient. Implementation using a single pipe with multiple consumers (to reflect different latencies) doesn't fit well with pipe rewriting that is used by the display channel. Additionally this approach is much simpler to verify. Lastly it doesn't add considerable overhead (but see the display channel changes in a later patch for a real place to rethink). This patch is just technical, changing signatures to reflect the first argument (oop style) so red_channel becomes red_channel_client. Some places may seem odd but they should be fixed with later comits where the channels grow to support multiple clients. Sound (playback/record) channels are the only ones not touched - this is consistent with previous patches, since they have been left out of the RedChannel refactoring. That is left as future work. (note that they don't use a pipe, which was the reason for not refactoring).
Diffstat (limited to 'server/inputs_channel.c')
-rw-r--r--server/inputs_channel.c36
1 files changed, 9 insertions, 27 deletions
diff --git a/server/inputs_channel.c b/server/inputs_channel.c
index 3a4a0d0d..e350689a 100644
--- a/server/inputs_channel.c
+++ b/server/inputs_channel.c
@@ -221,14 +221,6 @@ static uint8_t kbd_get_leds(SpiceKbdInstance *sin)
return sif->get_leds(sin);
}
-static InputsPipeItem *inputs_pipe_item_new(InputsChannel *inputs_channel, int type)
-{
- InputsPipeItem *item = spice_malloc(sizeof(InputsPipeItem));
-
- red_channel_pipe_item_init(&inputs_channel->base, &item->base, type);
- return item;
-}
-
static KeyModifiersPipeItem *inputs_key_modifiers_item_new(
InputsChannel *inputs_channel, uint8_t modifiers)
{
@@ -240,15 +232,6 @@ static KeyModifiersPipeItem *inputs_key_modifiers_item_new(
return item;
}
-// Right now every PipeItem we add is an InputsPipeItem, later maybe make it simpler
-// for type only PipeItems
-static void inputs_pipe_add_type(InputsChannel *channel, int type)
-{
- InputsPipeItem* pipe_item = inputs_pipe_item_new(channel, type);
-
- red_channel_pipe_add_push(&channel->base, &pipe_item->base);
-}
-
static void inputs_channel_release_pipe_item(RedChannelClient *rcc,
PipeItem *base, int item_pushed)
{
@@ -318,7 +301,7 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
SpiceMsgcMouseMotion *mouse_motion = (SpiceMsgcMouseMotion *)buf;
if (++inputs_channel->motion_count % SPICE_INPUT_MOTION_ACK_BUNCH == 0) {
- inputs_pipe_add_type(inputs_channel, PIPE_ITEM_MOUSE_MOTION_ACK);
+ red_channel_client_pipe_add_type(rcc, PIPE_ITEM_MOUSE_MOTION_ACK);
}
if (mouse && reds_get_mouse_mode() == SPICE_MOUSE_MODE_SERVER) {
SpiceMouseInterface *sif;
@@ -333,7 +316,7 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
SpiceMsgcMousePosition *pos = (SpiceMsgcMousePosition *)buf;
if (++inputs_channel->motion_count % SPICE_INPUT_MOTION_ACK_BUNCH == 0) {
- inputs_pipe_add_type(inputs_channel, PIPE_ITEM_MOUSE_MOTION_ACK);
+ red_channel_client_pipe_add_type(rcc, PIPE_ITEM_MOUSE_MOTION_ACK);
}
if (reds_get_mouse_mode() != SPICE_MOUSE_MODE_CLIENT) {
break;
@@ -468,21 +451,20 @@ static void inputs_shutdown(Channel *channel)
static void inputs_migrate(Channel *channel)
{
InputsChannel *inputs_channel = channel->data;
- InputsPipeItem *item;
+ RedChannelClient *rcc = inputs_channel->base.rcc;
ASSERT(g_inputs_channel == (InputsChannel *)channel->data);
- item = inputs_pipe_item_new(inputs_channel, PIPE_ITEM_MIGRATE);
- red_channel_pipe_add_push(&inputs_channel->base, &item->base);
+ red_channel_client_pipe_add_type(rcc, PIPE_ITEM_MIGRATE);
}
-static void inputs_pipe_add_init(InputsChannel *inputs_channel)
+static void inputs_pipe_add_init(RedChannelClient *rcc)
{
InputsInitPipeItem *item = spice_malloc(sizeof(InputsInitPipeItem));
- red_channel_pipe_item_init(&inputs_channel->base, &item->base,
+ red_channel_pipe_item_init(rcc->channel, &item->base,
PIPE_ITEM_INPUTS_INIT);
item->modifiers = kbd_get_leds(keyboard);
- red_channel_pipe_add_push(&inputs_channel->base, &item->base);
+ red_channel_client_pipe_add_push(rcc, &item->base);
}
static int inputs_channel_config_socket(RedChannelClient *rcc)
@@ -539,7 +521,7 @@ static void inputs_link(Channel *channel, RedsStream *stream, int migration,
rcc = red_channel_client_create(sizeof(RedChannelClient), &g_inputs_channel->base, stream);
ASSERT(rcc);
channel->data = inputs_channel;
- inputs_pipe_add_init(inputs_channel);
+ inputs_pipe_add_init(rcc);
}
static void inputs_push_keyboard_modifiers(uint8_t modifiers)
@@ -550,7 +532,7 @@ static void inputs_push_keyboard_modifiers(uint8_t modifiers)
return;
}
item = inputs_key_modifiers_item_new(g_inputs_channel, modifiers);
- red_channel_pipe_add_push(&g_inputs_channel->base, &item->base);
+ red_channel_client_pipe_add_push(g_inputs_channel->base.rcc, &item->base);
}
void inputs_on_keyboard_leds_change(void *opaque, uint8_t leds)