From 95468dcf17eecf84742ad4147c651fbe281d4c3f Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Fri, 27 Sep 2013 15:55:14 +0200 Subject: [PATCH] Modified rdpsnd opensles backend, now just filling queue and not waiting for completion of playback, results in better sound quality. --- channels/rdpsnd/client/opensles/opensl_io.c | 14 ++++++++------ channels/rdpsnd/client/opensles/opensl_io.h | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/channels/rdpsnd/client/opensles/opensl_io.c b/channels/rdpsnd/client/opensles/opensl_io.c index c18326b01..5c0b4dbb0 100644 --- a/channels/rdpsnd/client/opensles/opensl_io.c +++ b/channels/rdpsnd/client/opensles/opensl_io.c @@ -241,7 +241,7 @@ OPENSL_STREAM *android_OpenAudioDevice(int sr, int outchannels, int bufferframes } p->time = 0.; - p->next = CreateEvent(NULL, TRUE, FALSE, NULL); + p->queue = Queue_New(TRUE, -1, -1); return p; } @@ -253,7 +253,7 @@ void android_CloseAudioDevice(OPENSL_STREAM *p){ return; openSLDestroyEngine(p); - CloseHandle(p->next); + Queue_Free(p->queue); free(p); } @@ -269,9 +269,10 @@ void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context) OPENSL_STREAM *p = (OPENSL_STREAM *) context; assert(p); - assert(p->next); + assert(p->queue); - SetEvent(p->next); + void *data = Queue_Dequeue(p->queue); + free(data); } // puts a buffer of size samples to the device @@ -281,9 +282,10 @@ int android_AudioOut(OPENSL_STREAM *p, const short *buffer,int size) assert(buffer); assert(size > 0); + void *data = calloc(size, sizeof(short)); + memcpy(data, buffer, size * sizeof(short)); (*p->bqPlayerBufferQueue)->Enqueue(p->bqPlayerBufferQueue, - buffer, sizeof(short) * size); - WaitForSingleObject(p->next, INFINITE); + data, sizeof(short) * size); return size; } diff --git a/channels/rdpsnd/client/opensles/opensl_io.h b/channels/rdpsnd/client/opensles/opensl_io.h index 93dd2b53d..98fe8b0bc 100644 --- a/channels/rdpsnd/client/opensles/opensl_io.h +++ b/channels/rdpsnd/client/opensles/opensl_io.h @@ -58,7 +58,7 @@ typedef struct opensl_stream { unsigned int outchannels; unsigned int sr; - HANDLE next; + wQueue *queue; } OPENSL_STREAM; /*