public void GetConfig(BASSConfig[] flags) { foreach(BASSConfig flag in flags) { BassConfigList.Add(Bass.BASS_GetConfig(flag)); } }
/// <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()); } }
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)); }
/// <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()}"); } } }
public static extern Boolean SetConfig(BASSConfig option, UInt32 value);
public static extern UInt32 GetConfig(BASSConfig option);
public static extern bool BASS_SetConfig(BASSConfig option, [In, MarshalAs(UnmanagedType.Bool)] bool newvalue);
/// <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)); }
public static extern bool BASS_SetConfig(BASSConfig option, int newvalue);
public static extern bool BASS_GetConfigBool(BASSConfig option);
public static extern int BASS_GetConfig(BASSConfig option);
public static extern bool BASS_SetConfigPtr(BASSConfig option, IntPtr newvalue);
public static extern IntPtr BASS_GetConfigPtr(BASSConfig option);
public bool SetConfig(BASSConfig config, bool value) { return(Bass.BASS_SetConfig(config, value)); }
/// <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); }
/// <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(); } }
public bool SetConfig(BASSConfig config, bool value) { return Bass.BASS_SetConfig(config, value); }
/// <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)); }
public static string BASS_GetConfigString(BASSConfig option) { IntPtr ptr = BASS_GetConfigPtr(option); if (ptr != IntPtr.Zero) { return Marshal.PtrToStringAnsi(ptr); } return null; }
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)); } }