For certain devices, reporting a large minBufferSize, it can lead to an integer arithmetic overflow. Changing the code in the constructor to:
OpenSLAudioIODevice (const String& deviceName) : AudioIODevice (deviceName, openSLTypeName), Thread ("OpenSL"), callback (nullptr), sampleRate (0), deviceOpen (false), inputBuffer (2, 2), outputBuffer (2, 2) { // OpenSL has piss-poor support for determining latency, so the only way I can find to // get a number for this is by asking the AudioTrack/AudioRecord classes.. AndroidAudioIODevice javaDevice (String::empty); // this is a total guess about how to calculate the latency, but seems to vaguely agree // with the devices I've tested.. YMMV inputLatency = ((javaDevice.minBufferSizeIn * 2) / 3); outputLatency = ((javaDevice.minBufferSizeOut * 2) / 3); const int64 longestLatency = jmax (inputLatency, outputLatency); const int64 totalLatency = inputLatency + outputLatency; inputLatency = (int)((longestLatency * inputLatency) / totalLatency) & ~15; outputLatency = (int)((longestLatency * outputLatency) / totalLatency) & ~15; }
fixes this.