Reputation: 2563
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?
Upvotes: 1
Views: 142
Reputation: 197
'engineEngine' is passed as a pointer, try
engineEngine->CreateAudioPlayer(......
or
(*engineEngine).CreateAudioPlayer(.....
Upvotes: 0
Reputation: 409176
When looking at the header file, I see that SLObjectItf
is defined as
typedef const struct SLObjectItf_ * const * SLObjectItf;
That means it's a pointer to pointer to a structure. When you pass a pointer to the SLObjectItf
variable you pass a pointer to pointer to pointer to the structure, so *engineEngine
is the pointer to pointer to structure. You need another dereference operator, or simply not pass it as a pointer.
Upvotes: 2