Tao.Sdl: SDL_AudioSpec marshalling

I wonder if anyone can solve this marshalling conundrum.

[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct SDL_AudioSpec {
public int freq;
public short format;
public byte channels;
public byte silence;
public short samples;
public short padding;
public int size;
public IntPtr callback;
public object userdata;
}

Marshal.SizeOf(typeof(Sdl.SDL_AudioSpec))) == 24

If I replace the last member declaration with 'public IntPtr':

Marshal.SizeOf(typeof(Sdl.SDL_AudioSpec))) == 32

The latter is the correct size; passing the smaller structure to Sdl.SDL_OpenAudio() results in a crash. What's going on here?

Theme by La Boite a site | Powered by Drupal