'FMOD.CREATESOUNDEXINFO' cannot be marshaled


(Sergio) #1

I’m using Unity plugin, and my code is working on PC. But when I run on iPhone, xCode gives me this error:

ArgumentException: Type ‘FMOD.CREATESOUNDEXINFO’ cannot be marshaled
as an unmanaged structure; no meaningful size or offset can be
computed. at System.Runtime.InteropServices.Marshal.SizeOf
(System.Type t)

when I execute this code:

FMOD.CREATESOUNDEXINFO exinfo = new FMOD.CREATESOUNDEXINFO();
exinfo.cbsize = Marshal.SizeOf(exinfo);

am I doing anything wrong?


(Nicholas Wilcox) #2

What version of Unity are you using?


(Sergio) #3

I’m using 1.06.10


(Nicholas Wilcox) #4

Until Unity fixes their IL2CPP system you can try replacing the createStream function with

[DllImport(VERSION.dll)]
private static extern RESULT FMOD5_System_CreateStream           (IntPtr system, byte[] name_or_data, MODE mode, IntPtr exinfo, out IntPtr sound);

public RESULT createStream            (string name, MODE mode, out Sound sound)
{			
	sound = null;
	
	byte[] stringData;
	stringData = Encoding.UTF8.GetBytes(name + Char.MinValue);
				
	IntPtr soundraw;
	RESULT result = FMOD5_System_CreateStream(rawPtr, stringData, mode, IntPtr.Zero, out soundraw);
	sound = new Sound(soundraw);
	
	return result;
}

(Sergio) #5

Thanks Nicholas, I’ll try it