コード例 #1
0
 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);
        }
コード例 #3
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>
        /// <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);
        }
コード例 #5
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>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);
        }
コード例 #6
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>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
ファイル: BASSNative.cs プロジェクト: prshreshtha/ultraviolet
 public static extern Boolean SetConfig(BASSConfig option, UInt32 value);
コード例 #9
0
ファイル: BASSNative.cs プロジェクト: prshreshtha/ultraviolet
 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
ファイル: Bass.cs プロジェクト: safawu/project2006
 public static extern int BASS_GetConfig(BASSConfig option);
コード例 #15
0
ファイル: Bass.cs プロジェクト: safawu/project2006
 public static extern bool BASS_SetConfig(BASSConfig option, int newvalue);
コード例 #16
0
ファイル: BASSNative.cs プロジェクト: hayate891/ultraviolet
 public static extern Boolean SetConfig(BASSConfig option, UInt32 value);
コード例 #17
0
ファイル: BASSNative.cs プロジェクト: hayate891/ultraviolet
 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
ファイル: Bass.cs プロジェクト: safawu/project2006
 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
ファイル: Bass.cs プロジェクト: safawu/project2006
 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
ファイル: Bass.cs プロジェクト: safawu/project2006
 public static extern bool BASS_SetConfigPtr(BASSConfig option, IntPtr newvalue);
コード例 #27
0
 public bool SetConfig(BASSConfig config, bool value)
 {
     return Bass.BASS_SetConfig(config, value);
 }
コード例 #28
0
ファイル: Bass.cs プロジェクト: safawu/project2006
 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
ファイル: Bass.cs プロジェクト: safawu/project2006
 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));
     }
 }