Android buildfix

This commit is contained in:
Henrik Rydgård
2025-06-18 23:47:40 +02:00
parent 0502d79c99
commit 622b49a6a1
2 changed files with 4 additions and 8 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
#include <string>
#include <mutex>
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:
+3 -7
View File
@@ -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