Exemple #1
0
        private void LoadX3DAudio()
        {
            _hModule = Win32.NativeMethods.LoadLibrary("X3DAudio1_7.dll");
            if (_hModule == IntPtr.Zero)
            {
                _hModule = Win32.NativeMethods.LoadLibrary("X3DAudio2_8.dll");
            }
            if (_hModule == IntPtr.Zero)
            {
                _hModule = Win32.NativeMethods.LoadLibrary("XAudio2_8.dll");
            }
            if (_hModule == IntPtr.Zero)
            {
                _hModule = Win32.NativeMethods.LoadLibrary("XAudio2_9.dll");
            }

            if (_hModule == IntPtr.Zero)
            {
                throw new NotSupportedException("No supported X3DAudio version could be found.");
            }

            _initializeDelegate = GetUnmanagedProc <X3DAudioInitializeDelegate>(_hModule, "X3DAudioInitialize");
            _calculateDelegate  = GetUnmanagedProc <X3DAudioCalculateDelegate>(_hModule, "X3DAudioCalculate");

            if (_initializeDelegate == null || _calculateDelegate == null)
            {
                _initializeDelegate = null;
                _calculateDelegate  = null;
                Win32.NativeMethods.FreeLibrary(_hModule);
                throw new Exception("Could not load X3DAudio functions.");
            }
        }
Exemple #2
0
        /// <summary>
        ///     Disposes the <see cref="X3DAudioCore" /> instance.
        /// </summary>
        public void Dispose()
        {
            _calculateDelegate  = null;
            _initializeDelegate = null;

            if (_hModule != IntPtr.Zero)
            {
                Win32.NativeMethods.FreeLibrary(_hModule);
                _hModule = IntPtr.Zero;
            }
        }