I’m glad Csound finally has a forum!
Hope I’ll find some answers for this issue.
I am working on the new version of CsoundUnity, GitHub - rorywalsh/CsoundUnity, a great project started by @rory with the help of Richard Henninger.
The goal of the new version is to pack Csound in the form of a Unity Custom package, to be used via the Unity’s Package Manager, basically to be able to import it directly from the git repository above (from the develop branch).
Everything works great on Windows (and in editor), but we are facing a crash in Android.
This is the crash log:
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 Cause: null pointer dereference ... at libc.memset(memset:48) at libcsoundandroid.kperf_nodebug(kperf_nodebug:210) at libcsoundandroid.csoundPerformKsmps(csoundPerformKsmps:70) ...
I’m using the android .so libraries found in:
I tried compiling with IL2CPP or without, using ARM7 or ARM64.
I tried on different devices with Android 6, 7 and 8.
This is the relevant code we use to start Csound, where csdFile is the string representing the content of the csd:
Csound6.NativeMethods.csoundInitialize(1); csound = Csound6.NativeMethods.csoundCreate(System.IntPtr.Zero); Csound6.NativeMethods.csoundSetHostImplementedAudioIO(csound, 1, 0); Csound6.NativeMethods.csoundCreateMessageBuffer(csound, 0); int ret = Csound6.NativeMethods.csoundCompileCsdText(csound, csdFile); Csound6.NativeMethods.csoundStart(csound);
This works perfectly on Windows.
Asking for the version and API version works on Android too:
started Csound version 6150, API Version: 400
So the libs are found, and some of the methods work (for example calling GetOpcodeList returns correctly), but the crash occurs as soon as Csound tries to write/allocate memory, for example calling PerformKsmps.
I tried to debug the size of MYFLT and these are the results:
size of MYFLT: 4 type of MYFLT: System.Single Marshal.sizeof: 4 Csound size of MYFLT: 4
so we should be handling its size correctly on Android.
But we have the crash. Could it be related with the Android manifest and the permissions?
EDIT: tried adding permissions to the AndroidManifest, same crash.
Hope to find some answers here on the forum!
And of course, any help with the package is more than welcome, we need samples, docs, and above all new users! Please contribute!
Thanks for reading!