diff options
-rw-r--r-- | client/playback_channel.cpp | 8 | ||||
-rw-r--r-- | common/messages.h | 6 | ||||
-rw-r--r-- | server/snd_worker.c | 2 | ||||
-rw-r--r-- | spice.proto | 8 |
4 files changed, 13 insertions, 11 deletions
diff --git a/client/playback_channel.cpp b/client/playback_channel.cpp index 9ac6ed6..1e902a9 100644 --- a/client/playback_channel.cpp +++ b/client/playback_channel.cpp @@ -295,8 +295,8 @@ void PlaybackChannel::handle_stop(RedPeer::InMessage* message) void PlaybackChannel::handle_raw_data(RedPeer::InMessage* message) { SpiceMsgPlaybackPacket* packet = (SpiceMsgPlaybackPacket*)message->data(); - uint8_t* data = (uint8_t*)(packet + 1); - uint32_t size = message->size() - sizeof(*packet); + uint8_t* data = packet->data; + uint32_t size = packet->data_size; #ifdef WAVE_CAPTURE put_wave_data(data, size); return; @@ -315,8 +315,8 @@ void PlaybackChannel::handle_raw_data(RedPeer::InMessage* message) void PlaybackChannel::handle_celt_data(RedPeer::InMessage* message) { SpiceMsgPlaybackPacket* packet = (SpiceMsgPlaybackPacket*)message->data(); - uint8_t* data = (uint8_t*)(packet + 1); - uint32_t size = message->size() - sizeof(*packet); + uint8_t* data = packet->data; + uint32_t size = packet->data_size; celt_int16_t pcm[256 * 2]; if (celt051_decode(_celt_decoder, data, size, pcm) != CELT_OK) { diff --git a/common/messages.h b/common/messages.h index e317949..7575f07 100644 --- a/common/messages.h +++ b/common/messages.h @@ -368,7 +368,8 @@ typedef struct SpiceMsgcMouseRelease { typedef struct SpiceMsgPlaybackMode { uint32_t time; uint32_t mode; //SPICE_AUDIO_DATA_MODE_? - uint8_t data[0]; + uint8_t *data; + uint32_t data_size; } SpiceMsgPlaybackMode, SpiceMsgcRecordMode; typedef struct SpiceMsgPlaybackStart { @@ -380,7 +381,8 @@ typedef struct SpiceMsgPlaybackStart { typedef struct SpiceMsgPlaybackPacket { uint32_t time; - uint8_t data[0]; + uint8_t *data; + uint32_t data_size; } SpiceMsgPlaybackPacket, SpiceMsgcRecordPacket; typedef struct SpiceMsgRecordStart { diff --git a/server/snd_worker.c b/server/snd_worker.c index 544da3b..d55380c 100644 --- a/server/snd_worker.c +++ b/server/snd_worker.c @@ -281,7 +281,7 @@ static int snd_record_handle_write(RecordChannel *record_channel, size_t size, v } packet = (SpiceMsgcRecordPacket *)message; - size = size - sizeof(*packet); + size = packet->data_size; if (record_channel->mode == SPICE_AUDIO_DATA_MODE_CELT_0_5_1) { int celt_err = celt051_decode(record_channel->celt_decoder, packet->data, size, diff --git a/spice.proto b/spice.proto index bad9ed3..6cedfac 100644 --- a/spice.proto +++ b/spice.proto @@ -921,13 +921,13 @@ channel PlaybackChannel : BaseChannel { server: message { uint32 time; - uint8 data[] @end; + uint8 data[] @end @as_ptr(data_size); } @ctype(SpiceMsgPlaybackPacket) data = 101; message { uint32 time; audio_data_mode mode; - uint8 data[] @end; + uint8 data[] @end @as_ptr(data_size); } mode; message { @@ -952,13 +952,13 @@ channel RecordChannel : BaseChannel { client: message { uint32 time; - uint8 data[] @end @nomarshal; + uint8 data[] @end @nomarshal @as_ptr(data_size); } @ctype(SpiceMsgcRecordPacket) data = 101; message { uint32 time; audio_data_mode mode; - uint8 data[] @end; + uint8 data[] @end @as_ptr(data_size); } mode; message { |