I see customer devices on Google Play store that have my app unable to realize the OpenSLES player object.
static SLObjectItf playerObject;
...
result = (*playerObject)->Realize(playerObject, SL_BOOLEAN_FALSE);
gives the error SL_RESULT_CONTENT_UNSUPPORTED.
// Configure data format.
static SLDataFormat_PCM pcm;
memset( &pcm, 0, sizeof(pcm) );
pcm.formatType = SL_DATAFORMAT_PCM;
pcm.numChannels = 1;
pcm.samplesPerSec = SL_SAMPLINGRATE_11_025;
pcm.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16;
pcm.containerSize = 16;
pcm.channelMask = SL_SPEAKER_FRONT_CENTER;
pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
// Configure Audio Source.
SLDataSource source;
source.pFormat = &pcm;
source.pLocator = &bufferQueue;
// Create engine
//LOGI("create audio engine");
result = slCreateEngine
(
&engineObject,
0, // numOptions
NULL,
0, // numInterfaces
NULL,
NULL
);
CHECK_SL( result, "slCreateEngine" );
result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
CHECK_SL( result, "engineObject->Realize" );
// get the engine interface, which is needed in order to create other objects
result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
CHECK_SL( result, "GetInterface ENGINE" );
result = (*engineEngine)->CreateOutputMix( engineEngine,&outputMixObject, 0, NULL, NULL );
CHECK_SL( result, "CreateOutputMix" );
result = (*outputMixObject)->Realize(outputMixObject,SL_BOOLEAN_FALSE);
CHECK_SL( result, "outputMixObject->Realize" );
SLDataLocator_OutputMix loc_outmix = { SL_DATALOCATOR_OUTPUTMIX,outputMixObject };
SLDataSink audioSnk = { &loc_outmix, NULL };
// Create Audio player.
const SLInterfaceID ids[2] = { SL_IID_ANDROIDSIMPLEBUFFERQUEUE, SL_IID_VOLUME };
const SLboolean req[2] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_FALSE };
result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &source, &audioSnk, 2, ids, req);
CHECK_SL( result, "CreateAudioPlayer" );
// Realize Audio player.
result = (*playerObject)->Realize(playerObject, SL_BOOLEAN_FALSE);
CHECK_SL( result, "playerObject->Realize" );
I see this on devices like these: Lenovo A1000, samsung/SM-T285, motorola/Moto G (4), ...
Is it complaining about the data format? It's not very exotic: PCM at 11025 Hz, 16 bit.