From 622b49a6a1612a6f3307bd9ef0bc4deec1f8ac92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 18 Jun 2025 23:47:40 +0200 Subject: [PATCH] Android buildfix --- android/jni/AndroidAudio.h | 2 +- android/jni/OpenSLContext.cpp | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/android/jni/AndroidAudio.h b/android/jni/AndroidAudio.h index c1879a5a89..e3920df4bc 100644 --- a/android/jni/AndroidAudio.h +++ b/android/jni/AndroidAudio.h @@ -3,7 +3,7 @@ #include #include -typedef int (*AndroidAudioCallback)(short *buffer, int numSamples, int sampleRateHz, void *userdata); +typedef void (*AndroidAudioCallback)(short *buffer, int numSamples, int sampleRateHz, void *userdata); class AudioContext { public: diff --git a/android/jni/OpenSLContext.cpp b/android/jni/OpenSLContext.cpp index e0a5fbbdda..0ec0e8b17e 100644 --- a/android/jni/OpenSLContext.cpp +++ b/android/jni/OpenSLContext.cpp @@ -49,13 +49,9 @@ void OpenSLContext::BqPlayerCallback(SLAndroidSimpleBufferQueueItf bq) { return; } - int renderedFrames = audioCallback(buffer[curBuffer], framesPerBuffer, SampleRate(), nullptr); + audioCallback(buffer[curBuffer], framesPerBuffer, SampleRate(), nullptr); - int sizeInBytes = framesPerBuffer * 2 * sizeof(short); - int byteCount = (framesPerBuffer - renderedFrames) * 4; - if (byteCount > 0) { - memset(buffer[curBuffer] + renderedFrames * 2, 0, byteCount); - } + const int sizeInBytes = framesPerBuffer * 2 * sizeof(short); SLresult result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, buffer[curBuffer], sizeInBytes); // TODO: get rid of this snprintf too @@ -64,7 +60,7 @@ void OpenSLContext::BqPlayerCallback(SLAndroidSimpleBufferQueueItf bq) { // the most likely other result is SL_RESULT_BUFFER_INSUFFICIENT, // which for this code example would indicate a programming error if (result != SL_RESULT_SUCCESS) { - ERROR_LOG(Log::Audio, "OpenSL: Failed to enqueue! %i %i", renderedFrames, sizeInBytes); + ERROR_LOG(Log::Audio, "OpenSL: Failed to enqueue! %i", sizeInBytes); } curBuffer += 1; // Switch buffer