- Home /
Native plugin problems with varargs on iOS (Opus)
I'm trying to add the Opus library to my project using native plugins. I have it fully working on Android, Windows, and Mac. It's almost working on iOS, except for one function which is causing problems.
This is the C declaration of the function:
int opus_encoder_ctl(OpusEncoder *st, int request, ...)
I use this function to get and set the bitrate. It uses varargs, but there's only two variations I use, one where the third argument is an int (for setting the value) and one where it's an int pointer (for getting the value).
This is how I have the functions declared in c sharp:
[DllImport(LIBRARY_NAME, CallingConvention = CallingConvention.Cdecl)]
public static extern int opus_encoder_ctl(IntPtr st, Ctl request, int value);
[DllImport(LIBRARY_NAME, CallingConvention = CallingConvention.Cdecl)]
public static extern int opus_encoder_ctl(IntPtr st, Ctl request, out Int32 value);
I have both variations defined as separate functions. I read that this was the recommended way to call vararg functions from c-sharp, and it works on Android, Windows, Mac, and the iOS emulator. But on iOS devices it has issues. With the "out" argument function (which should correspond to the pointer variation in c), the resulting value is always zero. And with the int argument variation the function behaves strangely, as if I had passed in a much higher bitrate.
It seems like varargs are the issue here, but maybe it's the out argument? Any ideas what could be causing this?
Your answer
Follow this Question
Related Questions
UnityPluginLoad never called on iOS, Is it just broken? 1 Answer
iOS open docx file from Application.persistentData 2 Answers
Can I code a native plugin for iOS in C/C++? 0 Answers
Does Unity iOS have equivalent of AndroidJavaObject , AndroidJavaClass ? 0 Answers
IOS native plugin become slow in Unity 0 Answers