5

I faced a problem, that I can't solved for 3 days and you're my last hope.

My goal is to record sound with Bass.dll (there's special version of library for iPhone and version of .net wrapper for it; can be found here: un4seen.com)

On simulator program works (or seems to work properly). But when I tried to run it on the iPhone - I got this error:

"Attempting to JIT compile method '(wrapper native-to-managed) RecordingAudioHelloWorld.Player:recordingHandler (int,intptr,int,intptr)' while running with --aot-only."

error happens here:

RECORDPROC _recordingHandler = new RECORDPROC(recordingHandler);

_record = Bass.BASS_RecordStart(16000, 1, BASSFlag.BASS_SPEAKER_RIGHT, _recordingHandler, IntPtr.Zero); // <-- ERROR!!!

private int recordingHandler (int handle, IntPtr buffer, int length, IntPtr user)
{
//....
}

As I read here, on SO, I changed Linker behavior to "Link SDK assemblies only", but it has no effect.

Is there anything that I could do with it?

Linger
  • 14,942
  • 23
  • 52
  • 79
Konstantin Loginov
  • 15,802
  • 5
  • 58
  • 95

1 Answers1

8

Try to add the MonoPInvokeCallback attribute to your recordingHandler function. Note that you also need to make the function static. YourDelegateType should be the delegate type you defined in C# that corresponds to the signature of this method.

[MonoPInvokeCallback (typeof(YourDelegateType)]
private static int recordingHandler (int handle, IntPtr buffer, int length, IntPtr user)
{
// ...
}
Kirk Woll
  • 76,112
  • 22
  • 180
  • 195
Rolf Bjarne Kvinge
  • 19,253
  • 2
  • 42
  • 86
  • After adding [MonoPInvokeCallbackAttribute(typeof(_Ov_fopen))] [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ov_fopen")] public static extern unsafe int ov_fopen([In()] [MarshalAs(UnmanagedType.LPStr)] string path, ref File vf); Delegate: [UnmanagedFunctionPointer(CallingConvention.StdCall)] delegate int _Ov_fopen(string path,ref File file); Gives me a another error `Error MT3001: Could not AOT the assembly '/XXX/obj/iPhone/Debug/build-iphone5.2-8.1.1/mtouch-cache/Build/BindingLibrary.dll' (MT3001)` @Rolf Bjarne Kvinge – Brijesh May 16 '16 at 12:41