public void GetConfig(BASSConfig[] flags)
 {
     foreach(BASSConfig flag in flags)
     {
         BassConfigList.Add(Bass.BASS_GetConfig(flag));
     }
 }
示例#2
0
        /// <summary>
        /// Set a config with string value type.
        /// </summary>
        /// <param name="config">config name</param>
        /// <param name="value">string value</param>
        /// <returns>success or not</returns>
        private static bool SetConfig(BASSConfig config, string value)
        {
            var configName = config.ToString();

            if (stringHandles.ContainsKey(configName) && stringHandles[configName] != IntPtr.Zero)
            {
                Marshal.FreeHGlobal(stringHandles[configName]);
                stringHandles.Remove(configName);
            }

            var handle = value == null ? IntPtr.Zero : Marshal.StringToHGlobalAnsi(value);

            if (Un4seen.Bass.Bass.BASS_SetConfigPtr(config, handle))
            {
                if (handle != IntPtr.Zero)
                {
                    stringHandles[configName] = handle;
                }
                return(true);
            }
            if (handle != IntPtr.Zero)
            {
                Marshal.FreeHGlobal(handle);
            }
            return(false);
        }
        /// <summary>
        /// Sets the value of a pointer config option
        /// </summary>
        /// <param name="option">The option to set the value of... one of the following</param>
        /// <param name="newvalue">The new option setting. See the option's documentation for details on the possible values. </param>
        public static void BASS_SetConfigPtr(BASSConfig option, IntPtr newvalue)
        {
            bool result = NativeMethods.BASS_SetConfigPtr(option, newvalue);

            //If successful, the value of the requested config option is returned, else -1 is returned. Use BASS_ErrorGetCode to get the error code
            if (!result)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }
        }
示例#4
0
        public static string BASS_GetConfigString(BASSConfig option)
        {
            IntPtr ptr = BASS_GetConfigPtr(option);

            if (ptr != IntPtr.Zero)
            {
                return(Marshal.PtrToStringAnsi(ptr));
            }
            return(null);
        }
        /// <summary>
        /// Retrieves the value of a config option.
        /// </summary>
        /// <param name="option">The option to get the value of... one of the following.</param>
        /// <returns>If successful, the value of the requested config option is returned, else throw WavException. </returns>
        public static int BASS_GetConfig(BASSConfig option)
        {
            int result = NativeMethods.BASS_GetConfig(option);

            //If successful, the value of the requested config option is returned, else -1 is returned. Use BASS_ErrorGetCode to get the error code
            if (result == -1)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }

            return(result);
        }
        /// <summary>
        /// Retrieves the value of a config option.
        /// </summary>
        /// <param name="option">The option to get the value of... one of the following.</param>
        /// <returns>If successful, the value of the requested config option is returned, else throw WavException. </returns>
        public static string BASS_GetConfigString(BASSConfig option)
        {
            IntPtr result = NativeMethods.BASS_GetConfigPtr(option | ((BASSConfig)(-2147483648)));

            //If successful, the value of the requested config option is returned, else NULL is returned. NULL may also be a valid setting with some config options, in which case the error code should be used to confirm whether it's an error. Use BASS_ErrorGetCode to get the error code.
            if (result == IntPtr.Zero)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }

            return(Utils.IntPtrAsStringUnicode(result));
        }
示例#7
0
        /// <summary>
        /// Set configs presented as a string.
        /// </summary>
        /// <param name="configs">The configs.</param>
        /// <exception cref="System.IO.InvalidDataException">
        /// </exception>
        /// <exception cref="System.Exception">
        /// </exception>
        private static void SetConfigs(string configs)
        {
            foreach (var config in configs.Split('|'))
            {
                if (config == string.Empty)
                {
                    continue;
                }

                var spaceIndex = config.IndexOf(' ');
                if (spaceIndex == -1)
                {
                    throw new InvalidDataException(
                              $"Config 'Bass.SetConfigOnInitialization' is invalid. Invalid config string: {config}");
                }
                var        configNameString = config.Substring(0, spaceIndex);
                BASSConfig configName;
                if (!BASSConfig.TryParse(configNameString, out configName) ||
                    !Enum.IsDefined(typeof(BASSConfig), configName))
                {
                    throw new InvalidDataException(
                              $"Config 'Bass.SetConfigOnInitialization' is invalid. Invalid config name: {configNameString}");
                }

                var configValueString = config.Substring(spaceIndex + 1);
                int configValueInt;
                if (int.TryParse(configValueString, out configValueInt))
                {
                    if (!Bass.BASS_SetConfig(configName, configValueInt))
                    {
                        throw new Exception(
                                  $"Set config {configName} with value {configValueInt} failed. Error code {Bass.BASS_ErrorGetCode()}");
                    }
                    continue;
                }
                bool configValueBool;
                if (bool.TryParse(configValueString, out configValueBool))
                {
                    if (!Bass.BASS_SetConfig(configName, configValueBool))
                    {
                        throw new Exception(
                                  $"Set config {configName} with value {configValueBool} failed. Error code {Bass.BASS_ErrorGetCode()}");
                    }
                    continue;
                }
                if (!SetConfig(configName, configValueString))
                {
                    throw new Exception(
                              $"Set config {configName} with value {configValueString} failed. Error code {Bass.BASS_ErrorGetCode()}");
                }
            }
        }
示例#8
0
 public static extern Boolean SetConfig(BASSConfig option, UInt32 value);
示例#9
0
 public static extern UInt32 GetConfig(BASSConfig option);
示例#10
0
 public static extern bool BASS_SetConfig(BASSConfig option, [In, MarshalAs(UnmanagedType.Bool)] bool newvalue);
示例#11
0
 /// <summary>
 /// Retrieves the value of a config option.
 /// </summary>
 /// <param name="option">The option to get the value of... one of the following.</param>
 /// <returns>the value of the requested config option is returned </returns>
 public static bool BASS_GetConfigBool(BASSConfig option)
 {
     return(NativeMethods.BASS_GetConfigBool(option));
 }
示例#12
0
 public static extern bool BASS_SetConfig(BASSConfig option, int newvalue);
示例#13
0
 public static extern bool BASS_GetConfigBool(BASSConfig option);
示例#14
0
 public static extern int BASS_GetConfig(BASSConfig option);
示例#15
0
 public static extern bool BASS_SetConfig(BASSConfig option, int newvalue);
示例#16
0
 public static extern Boolean SetConfig(BASSConfig option, UInt32 value);
示例#17
0
 public static extern UInt32 GetConfig(BASSConfig option);
示例#18
0
 public static extern bool BASS_SetConfigPtr(BASSConfig option, IntPtr newvalue);
示例#19
0
 public static extern IntPtr BASS_GetConfigPtr(BASSConfig option);
示例#20
0
 public bool SetConfig(BASSConfig config, bool value)
 {
     return(Bass.BASS_SetConfig(config, value));
 }
示例#21
0
 public static extern IntPtr BASS_GetConfigPtr(BASSConfig option);
示例#22
0
文件: Base.cs 项目: pascalfr/MPfm
 /// <summary>
 /// Gets a BASS configuration value.
 /// </summary>
 /// <param name="option">BASS option</param>
 /// <returns>Value (integer)</returns>
 public static int GetConfig(BASSConfig option)
 {
     return Bass.BASS_GetConfig(option);
 }
示例#23
0
 public static extern int BASS_GetConfig(BASSConfig option);
示例#24
0
 public static extern bool BASS_SetConfig(BASSConfig option, [In, MarshalAs(UnmanagedType.Bool)] bool newvalue);
示例#25
0
文件: Base.cs 项目: pascalfr/MPfm
 /// <summary>
 /// Sets a BASS configuration value.
 /// </summary>
 /// <param name="option">BASS option</param>
 /// <param name="value">Value (integer)</param>
 public static void SetConfig(BASSConfig option, int value)
 {
     // Set configuration value
     if(!Bass.BASS_SetConfig(option, value))
     {
         // Check for error (throw exception if the error is found)
         CheckForError();
     }
 }
示例#26
0
 public static extern bool BASS_SetConfigPtr(BASSConfig option, IntPtr newvalue);
 public bool SetConfig(BASSConfig config, bool value)
 {
     return Bass.BASS_SetConfig(config, value);
 }
示例#28
0
 public static extern bool BASS_GetConfigBool(BASSConfig option);
示例#29
0
 /// <summary>
 /// Sets the value of a pointer config option
 /// </summary>
 /// <param name="option">The option to set the value of... one of the following</param>
 public static bool BASS_SetConfigString(BASSConfig option, string newvalue)
 {
     return(NativeMethods.BASS_SetConfigStringUnicode(option | ((BASSConfig)(-2147483648)), newvalue));
 }
示例#30
0
 public static string BASS_GetConfigString(BASSConfig option)
 {
     IntPtr ptr = BASS_GetConfigPtr(option);
     if (ptr != IntPtr.Zero)
     {
         return Marshal.PtrToStringAnsi(ptr);
     }
     return null;
 }
示例#31
0
 public void SetConfig(BASSConfig flag, object value)
 {
     if (value is int)
     {
         Bass.BASS_SetConfig(flag, Convert.ToInt32(value));
     }
     else
     {
         Bass.BASS_SetConfig(flag, Convert.ToBoolean(value));
     }
 }