c++ - C++ - Convert typedef to non-static method or object creation
问题描述
Hello I am using c++ in my Android project and I am fairly new to it. I have this class called SuperpoweredAndroidAudioIO which has the following constructor parameters.
SuperpoweredAndroidAudioIO(int samplerate, int buffersize, bool enableInput, bool enableOutput, audioProcessingCallback callback, void *clientdata, int inputStreamType = -1, int outputStreamType = -1);
Here audioProcessingCallback is a typedef which is defined in the library like this,
typedef bool (*audioProcessingCallback) (void *clientdata, short int *audioIO, int numberOfFrames, int samplerate);
Now every time I have to create an object of SuperpoweredAndroidAudioIO, I have to pass the static method as the parameter for the audioProcessingCallback like this,
static bool audioProcessing(
void *__unused clientdata, // custom pointer
short int *audio, // buffer of interleaved samples
int numberOfFrames, // number of frames to process
int __unused samplerate // current sample rate in Hz
) {
//Some code
return true;
}
audioIO = new SuperpoweredAndroidAudioIO(
samplerate,
buffersize,
true,
true,
audioProcessing, // audio processing callback function
NULL,
-1,
SL_ANDROID_STREAM_MEDIA
);
So my question is that is there any way to remove that static method as an audio processing callback and directly assign a method or object or anything that can work without static. The reason is that if I declare a static method I have to use all the variables inside it as static. So can anyone please help here?
解决方案
推荐阅读
- python - 使用 python 和 raspbian 编辑 wpa_supplicant.conf
- python - 小路('
') 导致所有 url 映射到不正确的视图 - r - 在compana中用较小的值(即0001)替换零值时,有没有办法获得一致的结果?
- html - 如何使按钮像链接一样但在新选项卡上?
- xcode - 如何在 macOS 10.14.4 Mojave 上使用 fink
- java - System.out.print 不显示客户数据
- javascript - 等待 serviceWorker 注册不返回激活的工作人员
- mysql - 如何使用“级联”删除用户并自动删除他的所有关系?
- visual-studio-code - VS Code:在顶部和底部面板之间来回切换的键盘快捷键?
- php - 在 php 中使用会话(本地存储)的购物车