Modified rdpsnd opensles backend, now just filling queue and not waiting

for completion of playback, results in better sound quality.
This commit is contained in:
Armin Novak 2013-09-27 15:55:14 +02:00
parent c96cef5dd8
commit 95468dcf17
2 changed files with 9 additions and 7 deletions

View File

@ -241,7 +241,7 @@ OPENSL_STREAM *android_OpenAudioDevice(int sr, int outchannels, int bufferframes
} }
p->time = 0.; p->time = 0.;
p->next = CreateEvent(NULL, TRUE, FALSE, NULL); p->queue = Queue_New(TRUE, -1, -1);
return p; return p;
} }
@ -253,7 +253,7 @@ void android_CloseAudioDevice(OPENSL_STREAM *p){
return; return;
openSLDestroyEngine(p); openSLDestroyEngine(p);
CloseHandle(p->next); Queue_Free(p->queue);
free(p); free(p);
} }
@ -269,9 +269,10 @@ void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
OPENSL_STREAM *p = (OPENSL_STREAM *) context; OPENSL_STREAM *p = (OPENSL_STREAM *) context;
assert(p); 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 // 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(buffer);
assert(size > 0); assert(size > 0);
void *data = calloc(size, sizeof(short));
memcpy(data, buffer, size * sizeof(short));
(*p->bqPlayerBufferQueue)->Enqueue(p->bqPlayerBufferQueue, (*p->bqPlayerBufferQueue)->Enqueue(p->bqPlayerBufferQueue,
buffer, sizeof(short) * size); data, sizeof(short) * size);
WaitForSingleObject(p->next, INFINITE);
return size; return size;
} }

View File

@ -58,7 +58,7 @@ typedef struct opensl_stream {
unsigned int outchannels; unsigned int outchannels;
unsigned int sr; unsigned int sr;
HANDLE next; wQueue *queue;
} OPENSL_STREAM; } OPENSL_STREAM;
/* /*