Exemplo n.º 1
0
        /// <summary>
        /// Inits the vTable method from GUID. This is a tricky part of this class.
        /// </summary>
        /// <param name="ASIOGuid">The ASIO GUID.</param>
        // Token: 0x060006EE RID: 1774 RVA: 0x000156B4 File Offset: 0x000138B4
        private void initFromGuid(Guid ASIOGuid)
        {
            int num = ASIODriver.CoCreateInstance(ref ASIOGuid, IntPtr.Zero, 1u, ref ASIOGuid, out this.pASIOComObject);

            if (num != 0)
            {
                throw new COMException("Unable to instantiate ASIO. Check if STAThread is set", num);
            }
            IntPtr ptr = Marshal.ReadIntPtr(this.pASIOComObject);

            this.asioDriverVTable = new ASIODriver.ASIODriverVTable();
            FieldInfo[] fields = typeof(ASIODriver.ASIODriverVTable).GetFields();
            for (int i = 0; i < fields.Length; i++)
            {
                FieldInfo fieldInfo = fields[i];
                IntPtr    ptr2      = Marshal.ReadIntPtr(ptr, (i + 3) * IntPtr.Size);
                object    delegateForFunctionPointer = Marshal.GetDelegateForFunctionPointer(ptr2, fieldInfo.FieldType);
                fieldInfo.SetValue(this.asioDriverVTable, delegateForFunctionPointer);
            }
        }