Exemple #1
0
        private static unsafe IntPtr CreateXAudio2Instance(XAudio2Processor processor)
        {
            IntPtr ptr    = IntPtr.Zero;
            var    pptr   = new IntPtr(&ptr);
            int    result = NativeMethods.XAudio2Create(pptr, 0, processor);

            XAudio2Exception.Try(result, "Interop", "XAudio2Create");
            return(ptr);
        }
Exemple #2
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="XAudio2_8" /> class.
        /// </summary>
        /// <param name="processor">
        ///     Specifies which CPU to use. Use <see cref="XAudio2Processor.Xaudio28DefaultProcessor" /> as
        ///     default value.
        /// </param>
        public unsafe XAudio2_8(XAudio2Processor processor)
        {
            IntPtr ptr    = IntPtr.Zero;
            var    pptr   = new IntPtr(&ptr);
            int    result = NativeMethods.XAudio2Create(pptr, 0, processor);

            XAudio2Exception.Try(result, "Interop", "XAudio2Create");

            Version = XAudio2Version.XAudio2_8;
            BasePtr = ptr;
        }
Exemple #3
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="XAudio2_7" /> class.
        /// </summary>
        /// <param name="debug">
        ///     Specifies whether the XAudio2 engine should be created in debug mode. Pass true to enable the debug
        ///     mode.
        /// </param>
        /// <param name="processor">
        ///     Specifies which CPU to use. Use <see cref="XAudio2Processor.XAudio27DefaultProcessor" /> as
        ///     default value.
        /// </param>
        /// <remarks>This constructor already calls <see cref="Initialize" />. Don't call it a second time.</remarks>
        public XAudio2_7(bool debug, XAudio2Processor processor)
        {
            Guid guid = debug
                ? new Guid("db05ea35-0329-4d4b-a53a-6dead03d3852")
                : new Guid("5a508685-a254-4fba-9b82-9a24b00306af");

            IntPtr  ptr0;
            HResult result = Win32.NativeMethods.CoCreateInstance(guid,
                                                                  IntPtr.Zero, CLSCTX.CLSCTX_INPROC_SERVER, typeof(XAudio2_7).GUID, out ptr0);

            if (result != HResult.S_OK)
            {
                throw new Win32Exception((int)result, "Could not create XAudio2.7 instance.");
            }


            BasePtr = ptr0;
            Version = XAudio2Version.XAudio2_7;
            Initialize(0, processor);
        }
Exemple #4
0
 /// <summary>
 ///     Sets XAudio2 parameters and prepares XAudio2 for use.
 /// </summary>
 /// <param name="flags">Flags that specify the behavior of the XAudio2 object. This value must be 0.</param>
 /// <param name="processor">
 ///     Specifies which CPU to use. Use <see cref="XAudio2Processor.XAudio27DefaultProcessor" /> as default value.
 /// </param>
 public void Initialize(int flags, XAudio2Processor processor)
 {
     XAudio2Exception.Try(InitializeNative(flags, processor), N, "Initialize");
 }
Exemple #5
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="XAudio2_7" /> class.
        /// </summary>
        /// <param name="debug">
        ///     Specifies whether the XAudio2 engine should be created in debug mode. Pass true to enable the debug
        ///     mode.
        /// </param>
        /// <param name="processor">
        ///     Specifies which CPU to use. Use <see cref="XAudio2Processor.XAudio27DefaultProcessor" /> as
        ///     default value.
        /// </param>
        /// <remarks>This constructor already calls <see cref="Initialize" />. Don't call it a second time.</remarks>
        public XAudio2_7(bool debug, XAudio2Processor processor)
        {
            Guid guid = debug
                ? new Guid("db05ea35-0329-4d4b-a53a-6dead03d3852")
                : new Guid("5a508685-a254-4fba-9b82-9a24b00306af");

            IntPtr ptr0;
            HResult result = Win32.NativeMethods.CoCreateInstance(guid,
                IntPtr.Zero, CLSCTX.CLSCTX_INPROC_SERVER, typeof (XAudio2_7).GUID, out ptr0);

            if (result != HResult.S_OK)
                throw new Win32Exception((int) result, "Could not create XAudio2.7 instance.");

            BasePtr = ptr0;
            Version = XAudio2Version.XAudio2_7;
            Initialize(0, processor);
        }
 internal static extern int XAudio2Create(IntPtr ptr, int flags, XAudio2Processor flags0);
Exemple #7
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="XAudio2_7" /> class.
 /// </summary>
 /// <param name="debug">
 ///     Specifies whether the XAudio2 engine should be created in debug mode. Pass true to enable the debug
 ///     mode.
 /// </param>
 /// <param name="processor">
 ///     Specifies which CPU to use. Use <see cref="XAudio2Processor.XAudio27DefaultProcessor" /> as
 ///     default value.
 /// </param>
 /// <remarks>This constructor already calls <see cref="Initialize" />. Don't call it a second time.</remarks>
 public XAudio2_7(bool debug, XAudio2Processor processor)
     : base(CreateXAudioInstance(debug), XAudio2Version.XAudio2_7)
 {
     Initialize(0, processor);
 }
Exemple #8
0
 /// <summary>
 ///     Sets XAudio2 parameters and prepares XAudio2 for use.
 /// </summary>
 /// <param name="flags">Flags that specify the behavior of the XAudio2 object. This value must be 0.</param>
 /// <param name="processor">
 ///     Specifies which CPU to use. Use <see cref="XAudio2Processor.XAudio27DefaultProcessor" /> as default value.
 /// </param>
 public void Initialize(int flags, XAudio2Processor processor)
 {
     XAudio2Exception.Try(InitializeNative(flags, processor), N, "Initialize");
 }
Exemple #9
0
 /// <summary>
 ///     Sets XAudio2 parameters and prepares XAudio2 for use.
 /// </summary>
 /// <param name="flags">Flags that specify the behavior of the XAudio2 object. This value must be 0.</param>
 /// <param name="processor">
 ///     Specifies which CPU to use. Use <see cref="XAudio2Processor.XAudio27DefaultProcessor" /> as default value.
 /// </param>
 /// <returns>HRESULT</returns>
 public unsafe int InitializeNative(int flags, XAudio2Processor processor)
 {
     return(InteropCalls.CallI(UnsafeBasePtr, flags, processor, ((void **)(*(void **)UnsafeBasePtr))[5]));
 }
Exemple #10
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="XAudio2_8" /> class.
 /// </summary>
 /// <param name="processor">
 ///     Specifies which CPU to use. Use <see cref="XAudio2Processor.Xaudio28DefaultProcessor" /> as
 ///     default value.
 /// </param>
 public XAudio2_8(XAudio2Processor processor)
     : base(CreateXAudio2Instance(processor), XAudio2Version.XAudio2_8)
 {
 }
Exemple #11
0
 internal static unsafe int CallI(void* _basePtr, int flags, XAudio2Processor processor, void* p)
 {
     throw new NotImplementedException();
 }
Exemple #12
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="XAudio2_8" /> class.
 /// </summary>
 /// <param name="processor">
 ///     Specifies which CPU to use. Use <see cref="XAudio2Processor.Xaudio28DefaultProcessor" /> as
 ///     default value.
 /// </param>
 public XAudio2_8(XAudio2Processor processor)
     : base(CreateXAudio2Instance(processor), XAudio2Version.XAudio2_8)
 {
 }
Exemple #13
0
 /// <summary>
 ///     Creates a new instance of the <see cref="XAudio2" /> class.
 ///     If no supported XAudio2 version is available, the CreateXAudio2 method throws an
 ///     <see cref="NotSupportedException" />.
 /// </summary>
 /// <param name="processor">The <see cref="XAudio2Processor" /> to use.</param>
 /// <returns>A new <see cref="XAudio2" /> instance.</returns>
 public static XAudio2 CreateXAudio2(XAudio2Processor? processor)
 {
     try
     {
         if(processor.HasValue)
             return new XAudio2_8(processor.Value);
         return new XAudio2_8();
     }
     catch (Exception)
     {
         try
         {
             if(processor.HasValue)
                 return new XAudio2_7(false, processor.Value);
             return new XAudio2_7();
         }
         catch (Exception)
         {
             throw new NotSupportedException("No supported XAudio2 version is installed.");
         }
     }
 }
Exemple #14
0
 internal static extern int XAudio2Create(IntPtr ptr, int flags, XAudio2Processor flags0);
Exemple #15
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="XAudio2_8" /> class.
        /// </summary>
        /// <param name="processor">
        ///     Specifies which CPU to use. Use <see cref="XAudio2Processor.Xaudio28DefaultProcessor" /> as
        ///     default value.
        /// </param>
        public unsafe XAudio2_8(XAudio2Processor processor)
        {
            IntPtr ptr = IntPtr.Zero;
            var pptr = new IntPtr(&ptr);
            int result = NativeMethods.XAudio2Create(pptr, 0, processor);
            XAudio2Exception.Try(result, "Interop", "XAudio2Create");

            Version = XAudio2Version.XAudio2_8;
            BasePtr = ptr;
        }
Exemple #16
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="XAudio2_7" /> class.
 /// </summary>
 /// <param name="debug">
 ///     Specifies whether the XAudio2 engine should be created in debug mode. Pass true to enable the debug
 ///     mode.
 /// </param>
 /// <param name="processor">
 ///     Specifies which CPU to use. Use <see cref="XAudio2Processor.XAudio27DefaultProcessor" /> as
 ///     default value.
 /// </param>
 /// <remarks>This constructor already calls <see cref="Initialize" />. Don't call it a second time.</remarks>
 public XAudio2_7(bool debug, XAudio2Processor processor)
     : base(CreateXAudioInstance(debug), XAudio2Version.XAudio2_7)
 {
     Initialize(0, processor);
 }
Exemple #17
0
 /// <summary>
 ///     Sets XAudio2 parameters and prepares XAudio2 for use.
 /// </summary>
 /// <param name="flags">Flags that specify the behavior of the XAudio2 object. This value must be 0.</param>
 /// <param name="processor">
 ///     Specifies which CPU to use. Use <see cref="XAudio2Processor.XAudio27DefaultProcessor" /> as default value.
 /// </param>
 /// <returns>HRESULT</returns>
 public unsafe int InitializeNative(int flags, XAudio2Processor processor)
 {
     return InteropCalls.CallI(UnsafeBasePtr, flags, processor, ((void**) (*(void**) UnsafeBasePtr))[5]);
 }
Exemple #18
0
 internal static unsafe int CallI(void *_basePtr, int flags, XAudio2Processor processor, void *p)
 {
     throw new NotImplementedException();
 }
Exemple #19
0
 private static unsafe IntPtr CreateXAudio2Instance(XAudio2Processor processor)
 {
     IntPtr ptr = IntPtr.Zero;
     var pptr = new IntPtr(&ptr);
     int result = NativeMethods.XAudio2Create(pptr, 0, processor);
     XAudio2Exception.Try(result, "Interop", "XAudio2Create");
     return ptr;
 }