Dllimport for mpglib.dll

  • Thread starter Thread starter Keltus
  • Start date Start date
K

Keltus

Hi,

I am trying to write a C# wrapper class for the famous mp3 decoder
mpg123. I have gotten the win32 .dll version of it, and have a sample
C program that uses the .dll which I think is pretty good. I have not
found a C# or even a C/C++ wrapper class of mpglib.dll so this might
be a difficult task since mpglib.dll only decodes the .mp3 files to
PCM format.

The first thing I need to do is use DllImport to import the library
functions. Does anyone know how to import the following C functions?
The fixed size character array in a struct is what confuses me.


struct mpstr { char c[40000]; };

typedef BOOL (*INITMP3) (struct mpstr *mp);
typedef void (*EXITMP3) (struct mpstr *mp);
typedef int (*DECODEMP3) (struct mpstr *mp, char *inmemory, int
inmemsize,
char *outmemory, int outmemsize, int
*done);

Thanks in advance
 
public struct MPStr
{
[MarshalAs(UnmanagedType.ByValArray, ArraySubType=typeof(char),
SizeConst=40000)]
char[] c;
}

If those function definitions you mention are actually function
pointers, you must define them as delegates in C#. E.g.

public delegate bool InitMp3Delegate(MPStr mp);
public delegate bool ExitMp3Delegate(MPStr mp);
public delegate bool DecodeMp3Delegate(MPStr mp, char[] inmemory, int
inmemsize, char[] outmemoery, int outmemsize, out int done)

Hi,

I am trying to write a C# wrapper class for the famous mp3 decoder
mpg123. I have gotten the win32 .dll version of it, and have a sample
C program that uses the .dll which I think is pretty good. I have not
found a C# or even a C/C++ wrapper class of mpglib.dll so this might
be a difficult task since mpglib.dll only decodes the .mp3 files to
PCM format.

The first thing I need to do is use DllImport to import the library
functions. Does anyone know how to import the following C functions?
The fixed size character array in a struct is what confuses me.


struct mpstr { char c[40000]; };

typedef BOOL (*INITMP3) (struct mpstr *mp);
typedef void (*EXITMP3) (struct mpstr *mp);
typedef int (*DECODEMP3) (struct mpstr *mp, char *inmemory, int
inmemsize,
char *outmemory, int outmemsize, int
*done);

Thanks in advance
 
Back
Top