mike-jumper commented on a change in pull request #312:
URL: https://github.com/apache/guacamole-server/pull/312#discussion_r518992278



##########
File path: src/protocols/rdp/channels/audio-input/audio-buffer.c
##########
@@ -233,6 +239,96 @@ static int guac_rdp_audio_buffer_read_sample(
 void guac_rdp_audio_buffer_write(guac_rdp_audio_buffer* audio_buffer,
         char* buffer, int length) {
 
+    pthread_mutex_lock(&(audio_buffer->lock));
+
+    /* Ignore packet if there is no buffer */
+    if (audio_buffer->packet_size == 0 || audio_buffer->packet == NULL) {
+        pthread_mutex_unlock(&(audio_buffer->lock));
+        return;
+    }
+
+    /* Allocate the new buffer. */
+    audio_stream_list *tmp = 
(audio_stream_list*)malloc(sizeof(audio_stream_list));
+    tmp->data = malloc(length);
+
+    /* Write the stream data to the new buffer. */
+    tmp->length = length;
+    tmp->next = NULL;
+    memcpy(tmp->data, buffer, tmp->length);
+    
+    /* Add the new buffer into the list. */
+    if (audio_buffer->first_stream_list == NULL) {
+        audio_buffer->first_stream_list = tmp;
+        audio_buffer->last_stream_list = tmp;
+    }
+    else {
+        audio_buffer->last_stream_list->next = (void*)tmp;
+        audio_buffer->last_stream_list =
+            (audio_stream_list*)audio_buffer->last_stream_list->next;
+    }

Review comment:
       If new memory will be allocated for every received `blob` of audio data, 
there needs to be some reasonable upper bound on how much pending audio data 
will be stored.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to