Question

I'm trying to assign a function to the AURenderCallback inputProc

int setupRemoteIO(audio unit etc){
    inProc.inputProc = playerCallback
}     

but it says that playerCallback is not declared in this scope although playerCallback is present in the same file and class as setupRemoteIO.

The player callback is like this

static OSStatus playerCallback(void *inRefCon etc)

What could be the problem?

Was it helpful?

Solution

In C, you need to declare a function before its first use, i.e. higher up in the file than the point where you try to use the function. That's why include files are usually clustered at the top of a file; all of the symbols declared in the headers will be available throughout the code in the including file.

In this case, that means the declaration of your callback:

static OSStatus playerCallback(void *inRefCon etc);

must appear before your setupRemoteIO() function so that the compiler knows the function exists when you come to use it.

As you're on iOS, I'll also make the point that in recent compilers this restriction doesn't apply to Objective-C methods. It used to: you could only use method selectors that had already been seen. But in newer versions of Clang an Objective-C method can make use of a selector declared later in the same file without error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top