通常说回调是用函数指针实现的。当我检查PortAudio的源代码时,我看到回调函数被声明为普通函数(不是f。指针)。这是正常/合法/可取的吗?
typedef int PaStreamCallback(
const void *input, void *output,
unsigned long frameCount,
const PaStreamCallbackTimeInfo* timeInfo,
PaStreamCallbackFlags statusFlags,
void *userData );
答案 0 :(得分:4)
只要参数用作PaStreamCallback*
(指针到函数),就可以了,就像
PaError Pa_OpenStream (
PaStream ** stream,
const PaStreamParameters * inputParameters,
const PaStreamParameters * outputParameters,
double sampleRate,
unsigned long framesPerBuffer,
PaStreamFlags streamFlags,
PaStreamCallback * streamCallback, // <---
void * userData
)