I have an android project with OpenSL ES and need to do some cleaning up.
One of the things I want to do is separate some logic from one file.
The file has the following variable defined:
static SLObjectItf engineObject = NULL;
This is a C variable as we access it like so:
(*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
I am trying to pass it off to another C++ class like so:
audioBuffer->Create(&engineObject);
This is how you would normally pass a pointer to SLObjectItf but it's a C variable so there is some different behaviour here.
This seems like a fairly straightforward task, here is the recieving function:
AudioBuffer::Create(SLObjectItf* engineEngine)
{
// ....
(*engineEngine)->CreateAudioPlayer(engineEngine, &bqPlayerObject, &audioSrc, &audioSnk,
3, ids, req);
}
And the error is:
request for member 'CreateAudioPlayer' in '* * engineEngine', which is of pointer type 'const SLEngineItf_* const' (maybe you meant to use '->' ?)
How do I pass a C variable into a C++ function and use it there?
SLObjectItf? And do you really need that many pointer indirections?engineObjectis pointer to structure, so you don't need to pass pointer to it inaudioBuffer->Create(&engineObject);. If you doengineEngineispointer to pointerso do(*(*engineEngine))->CreateAudioPlayer(...)SLObjectItfis a pointer to a pointer to struct.(*engineEngine)first indirection;->func()second indirection. so your function needs more indirection.