0
0

I experienced problems in my project, trying to retrieve GUID with FMOD. I used SlimDX as a control Guid to compare with the GUID that the FMOD Wrapper returns.

First, i used SlimDX some month before FMOD, and "it worked", so i knew the problem came from FMOD. I nailed it this morning, after 1 week of workaround and problems.

GUID are 128 bits data structures, which are grouped like that :
(32 bits) (16 bits) (16 bits) (64 bits)

The last 64 bits are treated as 8 [b:34q4avju]bytes[/b:34q4avju] (let me emphasize the [b:34q4avju]bytes[/b:34q4avju] a second time). In C++, char is a 1 byte (8 bits) type. Here comes the funny thing. In .Net, Char is a 2 byte (16 bits) type (let me prevent MS bashing : they decided that for Unicode handling.Net char are unicode char). The problem in the wrapper, returning a Char[] instead of a byte[] leads to misinterpretation of datas, and impossibilty to retrieve the correct GUIDs

SO !

in fmod.cs (and maybe its counterpart which i dont remember the name) change

[code:34q4avju] [StructLayout(LayoutKind.Sequential)]
public struct GUID
{
public uint Data1; /* Specifies the first 8 hexadecimal digits of the GUID /
public ushort Data2; /
Specifies the first group of 4 hexadecimal digits. /
public ushort Data3; /
Specifies the second group of 4 hexadecimal digits. /
[MarshalAs(UnmanagedType.ByValArray,SizeConst=8)]
public Char[] Data4; /
Array of 8 bytes. The first 2 bytes contain the third group of 4 hexadecimal digits. The remaining 6 bytes contain the final 12 hexadecimal digits. */
}[/code:34q4avju]

by

[code:34q4avju] [StructLayout(LayoutKind.Sequential)]
public struct GUID
{
public uint Data1; /* Specifies the first 8 hexadecimal digits of the GUID /
public ushort Data2; /
Specifies the first group of 4 hexadecimal digits. /
public ushort Data3; /
Specifies the second group of 4 hexadecimal digits. /
[MarshalAs(UnmanagedType.ByValArray,SizeConst=8)]
public byte[] Data4; /
Array of 8 bytes. The first 2 bytes contain the third group of 4 hexadecimal digits. The remaining 6 bytes contain the final 12 hexadecimal digits. */
}[/code:34q4avju]

Problem solved. :)

Disclaimer : no offense btw, i just wanted to give you that little patch. I’m truly happy and i wanted to thank you for the wrapper, which was damn useful in order to complete my project

  • You must to post comments
0
0

hi fderudder,

Thanks for the patch, I’ll update the wrapper for the next release.

-Pete

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.