[Mono-list] Possible to use a Linux .so program in Mono?

Jonathan Pryor jonpryor at vt.edu
Mon Apr 26 15:06:38 EDT 2010


On Mon, 2010-04-26 at 11:58 -0700, Steve Ricketts wrote:
> I'm looking at the various alternatives to processing audio files and just
> wondered if it would be possible to pass information to a Linux .so file
> written in c?  Specifically, I'd like to pass a byte array of PCM audio data
> and get back GSM into a byte array.

Yes.

http://www.mono-project.com/Dllimport

If you know that the unmanaged code won't hold a reference to the byte
array once the method has returned, then you can use `byte[]` as the
parameter type.  Otherwise, you'll need to copy the byte[] into
unmanaged memory (Marshal.AllocHGlobal() + Marshal.Copy() +
Marshal.FreeHGlobal() once you know the memory isn't being used
anymore).

 - Jon




More information about the Mono-list mailing list