Update FMOD

dev
Nadine Ganz 2024-11-13 17:30:09 +01:00
parent 1930966955
commit 22f560ceaf
85 changed files with 433 additions and 323 deletions

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 1e4f622ce6fb20a46adf465f9497cb04 guid: b73e581d836ff624db4ea85aa624bbd2
TextScriptImporter: TextScriptImporter:
externalObjects: {} externalObjects: {}
userData: userData:

View File

@ -670,10 +670,10 @@ MonoBehaviour:
m_Name: FMODStudioSettings m_Name: FMODStudioSettings
m_EditorClassIdentifier: m_EditorClassIdentifier:
switchSettingsMigration: 1 switchSettingsMigration: 1
HasSourceProject: 1 HasSourceProject: 0
HasPlatforms: 1 HasPlatforms: 0
sourceProjectPath: sourceProjectPath:
sourceBankPath: sourceBankPath: ../../Audio/FMODBuild
sourceBankPathUnformatted: sourceBankPathUnformatted:
BankRefreshCooldown: 5 BankRefreshCooldown: 5
ShowBankRefreshWindow: 1 ShowBankRefreshWindow: 1
@ -694,8 +694,16 @@ MonoBehaviour:
VirtualChannelSettings: [] VirtualChannelSettings: []
RealChannelSettings: [] RealChannelSettings: []
Plugins: [] Plugins: []
MasterBanks: [] MasterBanks:
Banks: [] - Master
Banks:
- Dialogue_CN
- Dialogue_EN
- Dialogue_JP
- Music
- SFX
- Vehicles
- VO
BanksToLoad: [] BanksToLoad: []
LiveUpdatePort: 9264 LiveUpdatePort: 9264
EnableMemoryTracking: 0 EnableMemoryTracking: 0
@ -707,7 +715,7 @@ MonoBehaviour:
EnableErrorCallback: 0 EnableErrorCallback: 0
SharedLibraryUpdateStage: 0 SharedLibraryUpdateStage: 0
SharedLibraryTimeSinceStart: 0 SharedLibraryTimeSinceStart: 0
CurrentVersion: 131620 CurrentVersion: 131621
HideSetupWizard: 1 HideSetupWizard: 1
LastEventReferenceScanVersion: 131620 LastEventReferenceScanVersion: 131620
Platforms: Platforms:

View File

@ -51,7 +51,7 @@ namespace FMODUnityResonance
private static readonly string listenerPluginName = "Resonance Audio Listener"; private static readonly string listenerPluginName = "Resonance Audio Listener";
// Size of |RoomProperties| struct in bytes. // Size of |RoomProperties| struct in bytes.
private static readonly int roomPropertiesSize = FMOD.MarshalHelper.SizeOf(typeof(RoomProperties)); private static readonly int roomPropertiesSize = Marshal.SizeOf<RoomProperties>();
// Plugin data parameter index for the room properties. // Plugin data parameter index for the room properties.
private static readonly int roomPropertiesIndex = 1; private static readonly int roomPropertiesIndex = 1;

View File

@ -1,33 +1,23 @@
fileFormatVersion: 2 fileFormatVersion: 1
guid: 159cb3726937c6c498fa49eb627b0d96 guid: 159cb3726937c6c498fa49eb627b0d96
PluginImporter: PluginImporter:
externalObjects: {} serializedVersion: 1
serializedVersion: 2 iconMap: {}
iconMap: {} executionOrder: {}
executionOrder: {} isPreloaded: 0
defineConstraints: [] isOverridable: 0
isPreloaded: 0 platformData:
isOverridable: 0 Android:
isExplicitlyReferenced: 0 enabled: 1
validateReferences: 1 settings:
platformData: CPU: ARM64
- first: Any:
Android: Android enabled: 0
second: settings: {}
enabled: 1 Editor:
settings: enabled: 0
CPU: ARM64 settings:
- first: DefaultValueInitialized: true
Any: userData:
second: assetBundleName:
enabled: 0 assetBundleVariant:
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,33 +1,23 @@
fileFormatVersion: 2 fileFormatVersion: 1
guid: e4d6c68823f34e440bfe4e4ecba4c113 guid: e4d6c68823f34e440bfe4e4ecba4c113
PluginImporter: PluginImporter:
externalObjects: {} serializedVersion: 1
serializedVersion: 2 iconMap: {}
iconMap: {} executionOrder: {}
executionOrder: {} isPreloaded: 0
defineConstraints: [] isOverridable: 0
isPreloaded: 0 platformData:
isOverridable: 0 Android:
isExplicitlyReferenced: 0 enabled: 1
validateReferences: 1 settings:
platformData: CPU: ARM64
- first: Any:
Android: Android enabled: 0
second: settings: {}
enabled: 1 Editor:
settings: enabled: 0
CPU: ARM64 settings:
- first: DefaultValueInitialized: true
Any: userData:
second: assetBundleName:
enabled: 0 assetBundleVariant:
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,33 +1,23 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: f71c8f89be7646142baed6d482d5e89c guid: f71c8f89be7646142baed6d482d5e89c
PluginImporter: PluginImporter:
externalObjects: {} serializedVersion: 1
serializedVersion: 2 iconMap: {}
iconMap: {} executionOrder: {}
executionOrder: {} isPreloaded: 0
defineConstraints: [] isOverridable: 0
isPreloaded: 0 platformData:
isOverridable: 0 Android:
isExplicitlyReferenced: 0 enabled: 1
validateReferences: 1 settings:
platformData: CPU: ARMv7
- first: Any:
Android: Android enabled: 0
second: settings: {}
enabled: 1 Editor:
settings: enabled: 0
CPU: ARMv7 settings:
- first: DefaultValueInitialized: true
Any: userData:
second: assetBundleName:
enabled: 0 assetBundleVariant:
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,33 +1,23 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: cf01ad74bd6e5df46996c61b81ba590c guid: cf01ad74bd6e5df46996c61b81ba590c
PluginImporter: PluginImporter:
externalObjects: {} serializedVersion: 1
serializedVersion: 2 iconMap: {}
iconMap: {} executionOrder: {}
executionOrder: {} isPreloaded: 0
defineConstraints: [] isOverridable: 0
isPreloaded: 0 platformData:
isOverridable: 0 Android:
isExplicitlyReferenced: 0 enabled: 1
validateReferences: 1 settings:
platformData: CPU: ARMv7
- first: Any:
Android: Android enabled: 0
second: settings: {}
enabled: 1 Editor:
settings: enabled: 0
CPU: ARMv7 settings:
- first: DefaultValueInitialized: true
Any: userData:
second: assetBundleName:
enabled: 0 assetBundleVariant:
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,33 +1,23 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 099e80baee62d0c439475fae45e69f4e guid: 099e80baee62d0c439475fae45e69f4e
PluginImporter: PluginImporter:
externalObjects: {} serializedVersion: 1
serializedVersion: 2 iconMap: {}
iconMap: {} executionOrder: {}
executionOrder: {} isPreloaded: 0
defineConstraints: [] isOverridable: 0
isPreloaded: 0 platformData:
isOverridable: 0 Android:
isExplicitlyReferenced: 0 enabled: 1
validateReferences: 1 settings:
platformData: CPU: x86
- first: Any:
Android: Android enabled: 0
second: settings: {}
enabled: 1 Editor:
settings: enabled: 0
CPU: x86 settings:
- first: DefaultValueInitialized: true
Any: userData:
second: assetBundleName:
enabled: 0 assetBundleVariant:
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,33 +1,23 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: a20d361b085100b4997c4e5b0b83af31 guid: a20d361b085100b4997c4e5b0b83af31
PluginImporter: PluginImporter:
externalObjects: {} serializedVersion: 1
serializedVersion: 2 iconMap: {}
iconMap: {} executionOrder: {}
executionOrder: {} isPreloaded: 0
defineConstraints: [] isOverridable: 0
isPreloaded: 0 platformData:
isOverridable: 0 Android:
isExplicitlyReferenced: 0 enabled: 1
validateReferences: 1 settings:
platformData: CPU: x86
- first: Any:
Android: Android enabled: 0
second: settings: {}
enabled: 1 Editor:
settings: enabled: 0
CPU: x86 settings:
- first: DefaultValueInitialized: true
Any: userData:
second: assetBundleName:
enabled: 0 assetBundleVariant:
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,33 +1,23 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 7b1a5b0e7617bcf49885fb2dd09d7085 guid: 7b1a5b0e7617bcf49885fb2dd09d7085
PluginImporter: PluginImporter:
externalObjects: {} serializedVersion: 1
serializedVersion: 2 iconMap: {}
iconMap: {} executionOrder: {}
executionOrder: {} isPreloaded: 0
defineConstraints: [] isOverridable: 0
isPreloaded: 0 platformData:
isOverridable: 0 Android:
isExplicitlyReferenced: 0 enabled: 1
validateReferences: 1 settings:
platformData: CPU: x86_64
- first: Any:
Android: Android enabled: 0
second: settings: {}
enabled: 1 Editor:
settings: enabled: 0
CPU: x86_64 settings:
- first: DefaultValueInitialized: true
Any: userData:
second: assetBundleName:
enabled: 0 assetBundleVariant:
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,33 +1,23 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 8c078c4748d95c2489bb3b82aa144194 guid: 8c078c4748d95c2489bb3b82aa144194
PluginImporter: PluginImporter:
externalObjects: {} serializedVersion: 1
serializedVersion: 2 iconMap: {}
iconMap: {} executionOrder: {}
executionOrder: {} isPreloaded: 0
defineConstraints: [] isOverridable: 0
isPreloaded: 0 platformData:
isOverridable: 0 Android:
isExplicitlyReferenced: 0 enabled: 1
validateReferences: 1 settings:
platformData: CPU: x86_64
- first: Any:
Android: Android enabled: 0
second: settings: {}
enabled: 1 Editor:
settings: enabled: 0
CPU: x86_64 settings:
- first: DefaultValueInitialized: true
Any: userData:
second: assetBundleName:
enabled: 0 assetBundleVariant:
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7959e64b0c3130b46bf491f58fdfd6c7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: c74d44e6ba102764fb85c6dc1e6d4168
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
WebGL: WebGL
second:
enabled: 0
settings: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: aa0ee2b898faebd44b3b1def99fb7ab4
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
WebGL: WebGL
second:
enabled: 0
settings: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 76b6a358cc688fb4eb30cf7da58ae388
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: e52d91a08688cb04695051b8a87a82bd
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
WebGL: WebGL
second:
enabled: 0
settings: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 8ba5025cbb9d0bf499e12351728e7679
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
WebGL: WebGL
second:
enabled: 0
settings: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -55,18 +55,37 @@ namespace FMODUnity
protected override IEnumerable<FileRecord> GetBinaryFiles(BuildTarget buildTarget, bool allVariants, string suffix) protected override IEnumerable<FileRecord> GetBinaryFiles(BuildTarget buildTarget, bool allVariants, string suffix)
{ {
#if UNITY_2021_2_OR_NEWER bool emVer_1_38_11 = false;
bool useWASM = true; bool emVer_2_0_19 = false;
#else bool emVer_3_1_8 = false;
bool useWASM = false; bool emVer_3_1_39 = false;
#endif
if (allVariants || useWASM) #if UNITY_6000_0_OR_NEWER
emVer_3_1_39 = true;
#elif UNITY_2022_3_OR_NEWER
emVer_3_1_8 = true;
#elif UNITY_2021_2_OR_NEWER
emVer_2_0_19 = true;
#else
emVer_1_38_11 = true;
#endif
if (allVariants || emVer_3_1_39)
{
yield return new FileRecord(string.Format("3.1.39/libfmodstudio{0}.a", suffix));
}
if (allVariants || emVer_3_1_8)
{
yield return new FileRecord(string.Format("3.1.8/libfmodstudio{0}.a", suffix));
}
if (allVariants || emVer_2_0_19)
{ {
yield return new FileRecord(string.Format("2.0.19/libfmodstudio{0}.a", suffix)); yield return new FileRecord(string.Format("2.0.19/libfmodstudio{0}.a", suffix));
} }
if (allVariants || !useWASM) if (allVariants || emVer_1_38_11)
{ {
yield return new FileRecord(string.Format("libfmodstudiounityplugin{0}.bc", suffix)); yield return new FileRecord(string.Format("libfmodstudiounityplugin{0}.bc", suffix));
} }

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: bad0ac5e8fb6a4a5491bb4faaad2248c guid: 597d50bd5095f402b8bc3cc8910f1ba5
PluginImporter: PluginImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 4224da8f72f9e4ab3abd4b3bf5c1fa1d guid: 3ec8bec8785ec45edad3ef0d825a8bf9
PluginImporter: PluginImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 7e1c523081229477e99ec128c53318c6 guid: 1d0990c72c66745b0bf9e95da7a9ef56
PluginImporter: PluginImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 189f8fecd1aca4383b870da65aa76d5b guid: a2bf8e7e3a64b472b91a1dcf8ba5d62a
PluginImporter: PluginImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@ -874,7 +874,7 @@ namespace FMODUnity
private GUIContent subdirectoryHeader = new GUIContent("Output sub-directory:"); private GUIContent subdirectoryHeader = new GUIContent("Output sub-directory:");
private GUIContent speakerModeHeader = new GUIContent("Surround speaker mode:"); private GUIContent speakerModeHeader = new GUIContent("Surround speaker mode:");
private const string HelpText = "Select the output sub-directory and speaker mode that match the project " + private const string HelpText = "Select the output sub-directory and surround speaker mode that match the project " +
"platform settings in the FMOD Studio build preferences."; "platform settings in the FMOD Studio build preferences.";
private const string UndoText = "Edit FMOD Platform Settings"; private const string UndoText = "Edit FMOD Platform Settings";

View File

@ -117,7 +117,7 @@ namespace FMODUnity
[AOT.MonoPInvokeCallback(typeof(FMOD.SYSTEM_CALLBACK))] [AOT.MonoPInvokeCallback(typeof(FMOD.SYSTEM_CALLBACK))]
private static FMOD.RESULT ERROR_CALLBACK(IntPtr system, FMOD.SYSTEM_CALLBACK_TYPE type, IntPtr commanddata1, IntPtr commanddata2, IntPtr userdata) private static FMOD.RESULT ERROR_CALLBACK(IntPtr system, FMOD.SYSTEM_CALLBACK_TYPE type, IntPtr commanddata1, IntPtr commanddata2, IntPtr userdata)
{ {
FMOD.ERRORCALLBACK_INFO callbackInfo = (FMOD.ERRORCALLBACK_INFO)FMOD.MarshalHelper.PtrToStructure(commanddata1, typeof(FMOD.ERRORCALLBACK_INFO)); FMOD.ERRORCALLBACK_INFO callbackInfo = Marshal.PtrToStructure<FMOD.ERRORCALLBACK_INFO>(commanddata1);
// Filter out benign expected errors. // Filter out benign expected errors.
if ((callbackInfo.instancetype == FMOD.ERRORCALLBACK_INSTANCETYPE.CHANNEL || callbackInfo.instancetype == FMOD.ERRORCALLBACK_INSTANCETYPE.CHANNELCONTROL) if ((callbackInfo.instancetype == FMOD.ERRORCALLBACK_INSTANCETYPE.CHANNEL || callbackInfo.instancetype == FMOD.ERRORCALLBACK_INSTANCETYPE.CHANNELCONTROL)

View File

@ -19,7 +19,7 @@ namespace FMOD
*/ */
public partial class VERSION public partial class VERSION
{ {
public const int number = 0x00020224; public const int number = 0x00020225;
#if !UNITY_2019_4_OR_NEWER #if !UNITY_2019_4_OR_NEWER
public const string dll = "fmod"; public const string dll = "fmod";
#endif #endif
@ -701,47 +701,47 @@ namespace FMOD
public SOUND_PCMREAD_CALLBACK pcmreadcallback public SOUND_PCMREAD_CALLBACK pcmreadcallback
{ {
set { pcmreadcallback_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); } set { pcmreadcallback_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); }
get { return pcmreadcallback_internal == IntPtr.Zero ? null : (SOUND_PCMREAD_CALLBACK)Marshal.GetDelegateForFunctionPointer(pcmreadcallback_internal, typeof(SOUND_PCMREAD_CALLBACK)); } get { return pcmreadcallback_internal == IntPtr.Zero ? null : Marshal.GetDelegateForFunctionPointer<SOUND_PCMREAD_CALLBACK>(pcmreadcallback_internal); }
} }
public SOUND_PCMSETPOS_CALLBACK pcmsetposcallback public SOUND_PCMSETPOS_CALLBACK pcmsetposcallback
{ {
set { pcmsetposcallback_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); } set { pcmsetposcallback_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); }
get { return pcmsetposcallback_internal == IntPtr.Zero ? null : (SOUND_PCMSETPOS_CALLBACK)Marshal.GetDelegateForFunctionPointer(pcmsetposcallback_internal, typeof(SOUND_PCMSETPOS_CALLBACK)); } get { return pcmsetposcallback_internal == IntPtr.Zero ? null : Marshal.GetDelegateForFunctionPointer<SOUND_PCMSETPOS_CALLBACK>(pcmsetposcallback_internal); }
} }
public SOUND_NONBLOCK_CALLBACK nonblockcallback public SOUND_NONBLOCK_CALLBACK nonblockcallback
{ {
set { nonblockcallback_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); } set { nonblockcallback_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); }
get { return nonblockcallback_internal == IntPtr.Zero ? null : (SOUND_NONBLOCK_CALLBACK)Marshal.GetDelegateForFunctionPointer(nonblockcallback_internal, typeof(SOUND_NONBLOCK_CALLBACK)); } get { return nonblockcallback_internal == IntPtr.Zero ? null : Marshal.GetDelegateForFunctionPointer<SOUND_NONBLOCK_CALLBACK>(nonblockcallback_internal); }
} }
public FILE_OPEN_CALLBACK fileuseropen public FILE_OPEN_CALLBACK fileuseropen
{ {
set { fileuseropen_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); } set { fileuseropen_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); }
get { return fileuseropen_internal == IntPtr.Zero ? null : (FILE_OPEN_CALLBACK)Marshal.GetDelegateForFunctionPointer(fileuseropen_internal, typeof(FILE_OPEN_CALLBACK)); } get { return fileuseropen_internal == IntPtr.Zero ? null : Marshal.GetDelegateForFunctionPointer<FILE_OPEN_CALLBACK>(fileuseropen_internal); }
} }
public FILE_CLOSE_CALLBACK fileuserclose public FILE_CLOSE_CALLBACK fileuserclose
{ {
set { fileuserclose_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); } set { fileuserclose_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); }
get { return fileuserclose_internal == IntPtr.Zero ? null : (FILE_CLOSE_CALLBACK)Marshal.GetDelegateForFunctionPointer(fileuserclose_internal, typeof(FILE_CLOSE_CALLBACK)); } get { return fileuserclose_internal == IntPtr.Zero ? null : Marshal.GetDelegateForFunctionPointer<FILE_CLOSE_CALLBACK>(fileuserclose_internal); }
} }
public FILE_READ_CALLBACK fileuserread public FILE_READ_CALLBACK fileuserread
{ {
set { fileuserread_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); } set { fileuserread_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); }
get { return fileuserread_internal == IntPtr.Zero ? null : (FILE_READ_CALLBACK)Marshal.GetDelegateForFunctionPointer(fileuserread_internal, typeof(FILE_READ_CALLBACK)); } get { return fileuserread_internal == IntPtr.Zero ? null : Marshal.GetDelegateForFunctionPointer<FILE_READ_CALLBACK>(fileuserread_internal); }
} }
public FILE_SEEK_CALLBACK fileuserseek public FILE_SEEK_CALLBACK fileuserseek
{ {
set { fileuserseek_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); } set { fileuserseek_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); }
get { return fileuserseek_internal == IntPtr.Zero ? null : (FILE_SEEK_CALLBACK)Marshal.GetDelegateForFunctionPointer(fileuserseek_internal, typeof(FILE_SEEK_CALLBACK)); } get { return fileuserseek_internal == IntPtr.Zero ? null : Marshal.GetDelegateForFunctionPointer<FILE_SEEK_CALLBACK>(fileuserseek_internal); }
} }
public FILE_ASYNCREAD_CALLBACK fileuserasyncread public FILE_ASYNCREAD_CALLBACK fileuserasyncread
{ {
set { fileuserasyncread_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); } set { fileuserasyncread_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); }
get { return fileuserasyncread_internal == IntPtr.Zero ? null : (FILE_ASYNCREAD_CALLBACK)Marshal.GetDelegateForFunctionPointer(fileuserasyncread_internal, typeof(FILE_ASYNCREAD_CALLBACK)); } get { return fileuserasyncread_internal == IntPtr.Zero ? null : Marshal.GetDelegateForFunctionPointer<FILE_ASYNCREAD_CALLBACK>(fileuserasyncread_internal); }
} }
public FILE_ASYNCCANCEL_CALLBACK fileuserasynccancel public FILE_ASYNCCANCEL_CALLBACK fileuserasynccancel
{ {
set { fileuserasynccancel_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); } set { fileuserasynccancel_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); }
get { return fileuserasynccancel_internal == IntPtr.Zero ? null : (FILE_ASYNCCANCEL_CALLBACK)Marshal.GetDelegateForFunctionPointer(fileuserasynccancel_internal, typeof(FILE_ASYNCCANCEL_CALLBACK)); } get { return fileuserasynccancel_internal == IntPtr.Zero ? null : Marshal.GetDelegateForFunctionPointer<FILE_ASYNCCANCEL_CALLBACK>(fileuserasynccancel_internal); }
} }
} }
@ -1114,12 +1114,12 @@ namespace FMOD
} }
public RESULT setAdvancedSettings(ref ADVANCEDSETTINGS settings) public RESULT setAdvancedSettings(ref ADVANCEDSETTINGS settings)
{ {
settings.cbSize = MarshalHelper.SizeOf(typeof(ADVANCEDSETTINGS)); settings.cbSize = Marshal.SizeOf<ADVANCEDSETTINGS>();
return FMOD5_System_SetAdvancedSettings(this.handle, ref settings); return FMOD5_System_SetAdvancedSettings(this.handle, ref settings);
} }
public RESULT getAdvancedSettings(ref ADVANCEDSETTINGS settings) public RESULT getAdvancedSettings(ref ADVANCEDSETTINGS settings)
{ {
settings.cbSize = MarshalHelper.SizeOf(typeof(ADVANCEDSETTINGS)); settings.cbSize = Marshal.SizeOf<ADVANCEDSETTINGS>();
return FMOD5_System_GetAdvancedSettings(this.handle, ref settings); return FMOD5_System_GetAdvancedSettings(this.handle, ref settings);
} }
public RESULT setCallback(SYSTEM_CALLBACK callback, SYSTEM_CALLBACK_TYPE callbackmask = SYSTEM_CALLBACK_TYPE.ALL) public RESULT setCallback(SYSTEM_CALLBACK callback, SYSTEM_CALLBACK_TYPE callbackmask = SYSTEM_CALLBACK_TYPE.ALL)
@ -1321,7 +1321,7 @@ namespace FMOD
public RESULT createSound(string name, MODE mode, out Sound sound) public RESULT createSound(string name, MODE mode, out Sound sound)
{ {
CREATESOUNDEXINFO exinfo = new CREATESOUNDEXINFO(); CREATESOUNDEXINFO exinfo = new CREATESOUNDEXINFO();
exinfo.cbsize = MarshalHelper.SizeOf(typeof(CREATESOUNDEXINFO)); exinfo.cbsize = Marshal.SizeOf<CREATESOUNDEXINFO>();
return createSound(name, mode, ref exinfo, out sound); return createSound(name, mode, ref exinfo, out sound);
} }
@ -1343,7 +1343,7 @@ namespace FMOD
public RESULT createStream(string name, MODE mode, out Sound sound) public RESULT createStream(string name, MODE mode, out Sound sound)
{ {
CREATESOUNDEXINFO exinfo = new CREATESOUNDEXINFO(); CREATESOUNDEXINFO exinfo = new CREATESOUNDEXINFO();
exinfo.cbsize = MarshalHelper.SizeOf(typeof(CREATESOUNDEXINFO)); exinfo.cbsize = Marshal.SizeOf<CREATESOUNDEXINFO>();
return createStream(name, mode, ref exinfo, out sound); return createStream(name, mode, ref exinfo, out sound);
} }
@ -3385,7 +3385,7 @@ namespace FMOD
{ {
IntPtr descPtr; IntPtr descPtr;
RESULT result = FMOD5_DSP_GetParameterInfo(this.handle, index, out descPtr); RESULT result = FMOD5_DSP_GetParameterInfo(this.handle, index, out descPtr);
desc = (DSP_PARAMETER_DESC)MarshalHelper.PtrToStructure(descPtr, typeof(DSP_PARAMETER_DESC)); desc = (DSP_PARAMETER_DESC)Marshal.PtrToStructure<DSP_PARAMETER_DESC>(descPtr);
return result; return result;
} }
public RESULT getDataParameterIndex(int datatype, out int index) public RESULT getDataParameterIndex(int datatype, out int index)
@ -4063,22 +4063,5 @@ namespace FMOD
} }
} }
// Some of the Marshal functions were marked as deprecated / obsolete, however that decision was reversed: https://github.com/dotnet/corefx/pull/10541
// Use the old syntax (non-generic) to ensure maximum compatibility (especially with Unity) ignoring the warnings
public static class MarshalHelper
{
#pragma warning disable 618
public static int SizeOf(Type t)
{
return Marshal.SizeOf(t); // Always use Type version, never Object version as it boxes causes GC allocations
}
public static object PtrToStructure(IntPtr ptr, Type structureType)
{
return Marshal.PtrToStructure(ptr, structureType);
}
#pragma warning restore 618
}
#endregion #endregion
} }

View File

@ -20,10 +20,46 @@ namespace FMOD
public struct DSP_BUFFER_ARRAY public struct DSP_BUFFER_ARRAY
{ {
public int numbuffers; public int numbuffers;
public int[] buffernumchannels; public IntPtr buffernumchannels;
public CHANNELMASK[] bufferchannelmask; public IntPtr bufferchannelmask;
public IntPtr[] buffers; public IntPtr buffers;
public SPEAKERMODE speakermode; public SPEAKERMODE speakermode;
/*
These properties take advantage of the fact that numbuffers is always zero or one
*/
public int numchannels
{
get
{
if (buffernumchannels != IntPtr.Zero && numbuffers != 0)
return Marshal.ReadInt32(buffernumchannels);
return 0;
}
set
{
if (buffernumchannels != IntPtr.Zero && numbuffers != 0)
Marshal.WriteInt32(buffernumchannels, value);
}
}
public IntPtr buffer
{
get
{
if (buffers != IntPtr.Zero && numbuffers != 0)
return Marshal.ReadIntPtr(buffers);
return IntPtr.Zero;
}
set
{
if (buffers != IntPtr.Zero && numbuffers != 0)
Marshal.WriteIntPtr(buffers, value);
}
}
} }
public enum DSP_PROCESS_OPERATION public enum DSP_PROCESS_OPERATION

View File

@ -395,7 +395,7 @@ namespace FMOD.Studio
} }
public RESULT setAdvancedSettings(ADVANCEDSETTINGS settings) public RESULT setAdvancedSettings(ADVANCEDSETTINGS settings)
{ {
settings.cbsize = MarshalHelper.SizeOf(typeof(ADVANCEDSETTINGS)); settings.cbsize = Marshal.SizeOf<ADVANCEDSETTINGS>();
return FMOD_Studio_System_SetAdvancedSettings(this.handle, ref settings); return FMOD_Studio_System_SetAdvancedSettings(this.handle, ref settings);
} }
public RESULT setAdvancedSettings(ADVANCEDSETTINGS settings, string encryptionKey) public RESULT setAdvancedSettings(ADVANCEDSETTINGS settings, string encryptionKey)
@ -411,7 +411,7 @@ namespace FMOD.Studio
} }
public RESULT getAdvancedSettings(out ADVANCEDSETTINGS settings) public RESULT getAdvancedSettings(out ADVANCEDSETTINGS settings)
{ {
settings.cbsize = MarshalHelper.SizeOf(typeof(ADVANCEDSETTINGS)); settings.cbsize = Marshal.SizeOf<ADVANCEDSETTINGS>();
return FMOD_Studio_System_GetAdvancedSettings(this.handle, out settings); return FMOD_Studio_System_GetAdvancedSettings(this.handle, out settings);
} }
public RESULT initialize(int maxchannels, INITFLAGS studioflags, FMOD.INITFLAGS flags, IntPtr extradriverdata) public RESULT initialize(int maxchannels, INITFLAGS studioflags, FMOD.INITFLAGS flags, IntPtr extradriverdata)
@ -679,7 +679,7 @@ namespace FMOD.Studio
} }
public RESULT loadBankCustom(BANK_INFO info, LOAD_BANK_FLAGS flags, out Bank bank) public RESULT loadBankCustom(BANK_INFO info, LOAD_BANK_FLAGS flags, out Bank bank)
{ {
info.size = MarshalHelper.SizeOf(typeof(BANK_INFO)); info.size = Marshal.SizeOf<BANK_INFO>();
return FMOD_Studio_System_LoadBankCustom(this.handle, ref info, flags, out bank.handle); return FMOD_Studio_System_LoadBankCustom(this.handle, ref info, flags, out bank.handle);
} }
public RESULT unloadAll() public RESULT unloadAll()