((SLDataFormat_PCM*)pDataFormat)->samplesPerSec = mal_round_to_standard_sample_rate__opensl(sampleRate * 1000); /* In millihertz. Annoyingly, the sample rate variable is named differently between SLAndroidDataFormat_PCM_EX and SLDataFormat_PCM */
// Android has a few restrictions on the format as documented here: https://developer.android.com/ndk/guides/audio/opensl-for-android.html
/* Unsupported format. Fall back to something safer and try again. If this fails, just abort. */
// - Only mono and stereo is supported.
pcm.formatType = SL_DATAFORMAT_PCM;
// - Only u8 and s16 formats are supported.
pcm.numChannels = 1;
// - Maximum sample rate of 48000.
((SLDataFormat_PCM*)&pcm)->samplesPerSec = SL_SAMPLINGRATE_16; /* The name of the sample rate variable is different between SLAndroidDataFormat_PCM_EX and SLDataFormat_PCM. */
#ifdef MAL_ANDROID
pcm.bitsPerSample = 16;
if (pFormat->numChannels > 2) {
pcm.containerSize = pcm.bitsPerSample; /* Always tightly packed for now. */