diff options
author | Alon Levy <alevy@redhat.com> | 2011-04-02 12:54:52 +0300 |
---|---|---|
committer | Alon Levy <alevy@redhat.com> | 2011-08-23 17:44:54 +0300 |
commit | 09ae4700d27b7c1cca64c2ce4c90f0c6cdf81ccf (patch) | |
tree | cca9910321cdfe30c4302ba6929e2f7cfa206fae /server/red_client_cache.h | |
parent | b6cf68604f2d184367d0f89834ebcce88e00bad8 (diff) | |
download | spice-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/red_client_cache.h')
-rw-r--r-- | server/red_client_cache.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/server/red_client_cache.h b/server/red_client_cache.h index fae4b2ad..6c17ba61 100644 --- a/server/red_client_cache.h +++ b/server/red_client_cache.h @@ -24,6 +24,7 @@ #define FUNC_NAME(name) red_cursor_cache_##name #define VAR_NAME(name) cursor_cache_##name #define CHANNEL CursorChannel +#define CHANNELCLIENT RedChannelClient #elif defined(CLIENT_PALETTE_CACHE) @@ -34,12 +35,15 @@ #define FUNC_NAME(name) red_palette_cache_##name #define VAR_NAME(name) palette_cache_##name #define CHANNEL DisplayChannel +#define CHANNELCLIENT RedChannelClient #else #error "no cache type." #endif +#define CHANNEL_FROM_RCC(rcc) SPICE_CONTAINEROF((rcc)->channel, CHANNEL, common.base); + static CacheItem *FUNC_NAME(find)(CHANNEL *channel, uint64_t id) { CacheItem *item = channel->CACHE_NAME[CACHE_HASH_KEY(id)]; @@ -55,9 +59,10 @@ static CacheItem *FUNC_NAME(find)(CHANNEL *channel, uint64_t id) return item; } -static void FUNC_NAME(remove)(CHANNEL *channel, CacheItem *item) +static void FUNC_NAME(remove)(CHANNELCLIENT *channel_client, CacheItem *item) { CacheItem **now; + CHANNEL *channel = CHANNEL_FROM_RCC(channel_client); ASSERT(item); now = &channel->CACHE_NAME[CACHE_HASH_KEY(item->id)]; @@ -74,11 +79,12 @@ static void FUNC_NAME(remove)(CHANNEL *channel, CacheItem *item) channel->VAR_NAME(available) += item->size; red_channel_pipe_item_init(&channel->common.base, &item->u.pipe_data, PIPE_ITEM_TYPE_INVAL_ONE); - red_channel_pipe_add_tail(&channel->common.base, &item->u.pipe_data); // for now + red_channel_client_pipe_add_tail(channel_client, &item->u.pipe_data); // for now } -static int FUNC_NAME(add)(CHANNEL *channel, uint64_t id, size_t size) +static int FUNC_NAME(add)(CHANNELCLIENT *channel_client, uint64_t id, size_t size) { + CHANNEL *channel = CHANNEL_FROM_RCC(channel_client); CacheItem *item; int key; @@ -92,7 +98,7 @@ static int FUNC_NAME(add)(CHANNEL *channel, uint64_t id, size_t size) free(item); return FALSE; } - FUNC_NAME(remove)(channel, tail); + FUNC_NAME(remove)(channel_client, tail); } ++channel->VAR_NAME(items); item->u.cache_data.next = channel->CACHE_NAME[(key = CACHE_HASH_KEY(id))]; @@ -130,4 +136,4 @@ static void FUNC_NAME(reset)(CHANNEL *channel, long size) #undef FUNC_NAME #undef VAR_NAME #undef CHANNEL - +#undef CHANNEL_FROM_RCC |