[Spice-devel] [PATCH spice-server 14/18] sound: Reduce message buffer
Frediano Ziglio
fziglio at redhat.com
Wed Nov 23 18:07:28 UTC 2016
Sound messages are not that big.
This limit RecordChannelClient to 64K so the entire
structure can be a GObject (which are currently limited
to 64K).
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
server/sound.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/server/sound.c b/server/sound.c
index 5ce028c..cff34a4 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -97,7 +97,9 @@ struct SndChannelClient {
uint32_t command;
- uint8_t receive_buf[SND_RECEIVE_BUF_SIZE];
+ /* we don't expect very big messages so don't allocate too much
+ * bytes, data will be cached in RecordChannelClient::samples */
+ uint8_t receive_buf[SND_CODEC_MAX_FRAME_BYTES + 64];
RedPipeItem persistent_pipe_item;
snd_channel_on_message_done_proc on_message_done;
@@ -780,8 +782,10 @@ static uint8_t*
snd_channel_client_alloc_recv_buf(RedChannelClient *rcc, uint16_t type, uint32_t size)
{
SndChannelClient *client = SND_CHANNEL_CLIENT(rcc);
- // TODO isn't too much the buffer ?? return NULL ??
- spice_assert(size < sizeof(client->receive_buf));
+ // If message is to big allocate one, this should never happen
+ if (size > sizeof(client->receive_buf)) {
+ return spice_malloc(size);
+ }
return client->receive_buf;
}
@@ -789,6 +793,10 @@ static void
snd_channel_client_release_recv_buf(RedChannelClient *rcc, uint16_t type, uint32_t size,
uint8_t *msg)
{
+ SndChannelClient *client = SND_CHANNEL_CLIENT(rcc);
+ if (msg != client->receive_buf) {
+ free(msg);
+ }
}
// TODO remove and just use red_channel_client_disconnect ??
--
2.7.4
More information about the Spice-devel
mailing list