Ejemplo n.º 1
0
 public XRamExtension()
 {
     this._valid = false;
     if (!AL.IsExtensionPresent("EAX-RAM"))
     {
         return;
     }
     this.AL_EAX_RAM_SIZE       = AL.GetEnumValue("AL_EAX_RAM_SIZE");
     this.AL_EAX_RAM_FREE       = AL.GetEnumValue("AL_EAX_RAM_FREE");
     this.AL_STORAGE_AUTOMATIC  = AL.GetEnumValue("AL_STORAGE_AUTOMATIC");
     this.AL_STORAGE_HARDWARE   = AL.GetEnumValue("AL_STORAGE_HARDWARE");
     this.AL_STORAGE_ACCESSIBLE = AL.GetEnumValue("AL_STORAGE_ACCESSIBLE");
     if (this.AL_EAX_RAM_SIZE == 0 || this.AL_EAX_RAM_FREE == 0 || (this.AL_STORAGE_AUTOMATIC == 0 || this.AL_STORAGE_HARDWARE == 0))
     {
         return;
     }
     if (this.AL_STORAGE_ACCESSIBLE == 0)
     {
         return;
     }
     try
     {
         this.Imported_GetBufferMode = (XRamExtension.Delegate_GetBufferMode)Marshal.GetDelegateForFunctionPointer(AL.GetProcAddress("EAXGetBufferMode"), typeof(XRamExtension.Delegate_GetBufferMode));
         this.Imported_SetBufferMode = (XRamExtension.Delegate_SetBufferMode)Marshal.GetDelegateForFunctionPointer(AL.GetProcAddress("EAXSetBufferMode"), typeof(XRamExtension.Delegate_SetBufferMode));
     }
     catch (Exception ex)
     {
         return;
     }
     this._valid = true;
 }
        /// <summary>
        /// Constructs a new XRamExtension instance.
        /// </summary>
        public XRamExtension()
        {
            // Query if Extension supported and retrieve Tokens/Pointers if it is.
            _valid = false;
            if (AL.IsExtensionPresent("EAX-RAM") == false)
            {
                return;
            }

            AL_EAX_RAM_SIZE       = AL.GetEnumValue("AL_EAX_RAM_SIZE");
            AL_EAX_RAM_FREE       = AL.GetEnumValue("AL_EAX_RAM_FREE");
            AL_STORAGE_AUTOMATIC  = AL.GetEnumValue("AL_STORAGE_AUTOMATIC");
            AL_STORAGE_HARDWARE   = AL.GetEnumValue("AL_STORAGE_HARDWARE");
            AL_STORAGE_ACCESSIBLE = AL.GetEnumValue("AL_STORAGE_ACCESSIBLE");

            // Console.WriteLine("RamSize: {0} RamFree: {1} StorageAuto: {2} StorageHW: {3} StorageAccess: {4}",AL_EAX_RAM_SIZE,AL_EAX_RAM_FREE,AL_STORAGE_AUTOMATIC,AL_STORAGE_HARDWARE,AL_STORAGE_ACCESSIBLE);

            if (AL_EAX_RAM_SIZE == 0 ||
                AL_EAX_RAM_FREE == 0 ||
                AL_STORAGE_AUTOMATIC == 0 ||
                AL_STORAGE_HARDWARE == 0 ||
                AL_STORAGE_ACCESSIBLE == 0)
            {
                Debug.WriteLine("X-Ram: Token values could not be retrieved.");
                return;
            }

            // Console.WriteLine("Free Ram: {0} / {1}",GetRamFree( ),GetRamSize( ));

            try
            {
                Imported_GetBufferMode = (Delegate_GetBufferMode)Marshal.GetDelegateForFunctionPointer(AL.GetProcAddress("EAXGetBufferMode"), typeof(Delegate_GetBufferMode));
                Imported_SetBufferMode = (Delegate_SetBufferMode)Marshal.GetDelegateForFunctionPointer(AL.GetProcAddress("EAXSetBufferMode"), typeof(Delegate_SetBufferMode));
            }
            catch (Exception e)
            {
                Debug.WriteLine("X-Ram: Attempt to marshal function pointers with AL.GetProcAddress failed. " + e.ToString());
                return;
            }

            _valid = true;
        }