-
Notifications
You must be signed in to change notification settings - Fork 0
/
Effect.cs
58 lines (48 loc) · 2.28 KB
/
Effect.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.Win32.SafeHandles;
namespace AlureWrapper
{
[SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode = true)]
[SecurityPermission(SecurityAction.Demand, UnmanagedCode = true)]
public class Effect : SafeHandleZeroOrMinusOneIsInvalid
{
#region Extern
[DllImport("alure-c-interface", CallingConvention = CallingConvention.Cdecl)]
private static extern void effect_destroy(IntPtr dm, ref IntPtr exceptionPointer);
[DllImport("alure-c-interface", CallingConvention = CallingConvention.Cdecl)]
private static extern void effect_destroyPointer(IntPtr dm, ref IntPtr exceptionPointer);
[DllImport("alure-c-interface", CallingConvention = CallingConvention.Cdecl)]
private static extern void effect_setReverbProperties(IntPtr dm, ref EFXEAXReverbProperties props, ref IntPtr exceptionPointer);
[DllImport("alure-c-interface", CallingConvention = CallingConvention.Cdecl)]
private static extern void effect_setChorusProperties(IntPtr dm, ref EFXChorusProperties props, ref IntPtr exceptionPointer);
#endregion Extern
public Effect() : base(true) { }
public Effect(IntPtr dm, bool ownsHandle = false) : base(ownsHandle)
{
SetHandle(dm);
}
public void SetReverbProperties(EFXEAXReverbProperties props)
{
WrapException.CheckForException((ref IntPtr e) => effect_setReverbProperties(handle, ref props, ref e));
}
public void SetChorusProperties(EFXChorusProperties props)
{
WrapException.CheckForException((ref IntPtr e) => effect_setChorusProperties(handle, ref props, ref e));
}
public void Destroy()
{
WrapException.CheckForException((ref IntPtr e) => effect_destroy(handle, ref e));
}
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
protected override bool ReleaseHandle()
{
WrapException.CheckForException((ref IntPtr e) => effect_destroyPointer(handle, ref e));
SetHandleAsInvalid();
handle = IntPtr.Zero;
return true;
}
}
}