mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-13 10:08:31 +00:00
Compare commits
No commits in common. "d070f0bbcb759843b4a0363700a166246500237a" and "7415c6b4efe0987d5628cb52909b960956e9a7e2" have entirely different histories.
d070f0bbcb
...
7415c6b4ef
@ -12,8 +12,6 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private bool _isDisposed = false;
|
||||
|
||||
private readonly double _defaultUpdateRateHardLimit;
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -62,8 +60,6 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
|
||||
this._defaultUpdateRateHardLimit = defaultUpdateRateHardLimit;
|
||||
}
|
||||
|
||||
~AbstractRGBDeviceProvider() => Dispose(false);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
@ -71,8 +67,6 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
|
||||
/// <inheritdoc />
|
||||
public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool throwExceptions = false)
|
||||
{
|
||||
if (_isDisposed) throw new ObjectDisposedException(GetType().FullName);
|
||||
|
||||
ThrowsExceptions = throwExceptions;
|
||||
|
||||
try
|
||||
@ -114,8 +108,6 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
|
||||
/// <returns>The filtered collection of loaded devices.</returns>
|
||||
protected virtual IEnumerable<IRGBDevice> GetLoadedDevices(RGBDeviceType loadFilter)
|
||||
{
|
||||
if (_isDisposed) throw new ObjectDisposedException(GetType().FullName);
|
||||
|
||||
List<IRGBDevice> devices = new();
|
||||
foreach (IRGBDevice device in LoadDevices())
|
||||
{
|
||||
@ -160,8 +152,6 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
|
||||
/// <returns>The update trigger mapped to the specified id.</returns>
|
||||
protected virtual IDeviceUpdateTrigger GetUpdateTrigger(int id = -1, double? updateRateHardLimit = null)
|
||||
{
|
||||
if (_isDisposed) throw new ObjectDisposedException(GetType().FullName);
|
||||
|
||||
if (!UpdateTriggerMapping.TryGetValue(id, out IDeviceUpdateTrigger? updaeTrigger))
|
||||
UpdateTriggerMapping[id] = (updaeTrigger = CreateUpdateTrigger(id, updateRateHardLimit ?? _defaultUpdateRateHardLimit));
|
||||
|
||||
@ -181,8 +171,6 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
|
||||
/// </summary>
|
||||
protected virtual void Reset()
|
||||
{
|
||||
if (_isDisposed) throw new ObjectDisposedException(GetType().FullName);
|
||||
|
||||
foreach (IDeviceUpdateTrigger updateTrigger in UpdateTriggerMapping.Values)
|
||||
updateTrigger.Dispose();
|
||||
|
||||
@ -204,8 +192,6 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
|
||||
/// <returns><c>true</c> if the device was added successfully; otherwise <c>false</c>.</returns>
|
||||
protected virtual bool AddDevice(IRGBDevice device)
|
||||
{
|
||||
if (_isDisposed) throw new ObjectDisposedException(GetType().FullName);
|
||||
|
||||
if (InternalDevices.Contains(device)) return false;
|
||||
|
||||
InternalDevices.Add(device);
|
||||
@ -221,8 +207,6 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
|
||||
/// <returns><c>true</c> if the device was removed successfully; otherwise <c>false</c>.</returns>
|
||||
protected virtual bool RemoveDevice(IRGBDevice device)
|
||||
{
|
||||
if (_isDisposed) throw new ObjectDisposedException(GetType().FullName);
|
||||
|
||||
if (!InternalDevices.Remove(device)) return false;
|
||||
|
||||
try { OnDevicesChanged(DevicesChangedEventArgs.CreateDevicesRemovedArgs(device)); } catch { /* we don't want to throw due to bad event handlers */ }
|
||||
@ -257,26 +241,12 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
|
||||
protected virtual void OnDevicesChanged(DevicesChangedEventArgs args) => DevicesChanged?.Invoke(this, args);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
public virtual void Dispose()
|
||||
{
|
||||
if (_isDisposed) return;
|
||||
|
||||
try
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
catch { /* don't throw in dispose! */ }
|
||||
Reset();
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
_isDisposed = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the object and frees all resources.
|
||||
/// </summary>
|
||||
/// <param name="disposing"><c>true</c> if explicitely called through the Dispose-Method, <c>false</c> if called by the destructor.</param>
|
||||
protected virtual void Dispose(bool disposing) => Reset();
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -16,21 +16,11 @@ public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static AsusDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="AsusDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static AsusDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new AsusDeviceProvider();
|
||||
}
|
||||
}
|
||||
public static AsusDeviceProvider Instance => _instance ?? new AsusDeviceProvider();
|
||||
|
||||
private IAuraSdk2? _sdk;
|
||||
private IAuraSyncDeviceCollection? _devices; //HACK DarthAffe 05.04.2021: Due to some researches this might fix the access violation in the asus-sdk
|
||||
@ -45,11 +35,8 @@ public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public AsusDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(AsusDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(AsusDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -93,19 +80,15 @@ public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
public override void Dispose()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
base.Dispose();
|
||||
|
||||
try { _sdk?.ReleaseControl(0); }
|
||||
catch { /* at least we tried */ }
|
||||
try { _sdk?.ReleaseControl(0); }
|
||||
catch { /* at least we tried */ }
|
||||
|
||||
_devices = null;
|
||||
_sdk = null;
|
||||
_instance = null;
|
||||
}
|
||||
_devices = null;
|
||||
_sdk = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -17,21 +17,11 @@ public sealed class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static CoolerMasterDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="CoolerMasterDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static CoolerMasterDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new CoolerMasterDeviceProvider();
|
||||
}
|
||||
}
|
||||
public static CoolerMasterDeviceProvider Instance => _instance ?? new CoolerMasterDeviceProvider();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||
@ -55,11 +45,8 @@ public sealed class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public CoolerMasterDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CoolerMasterDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CoolerMasterDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -107,17 +94,12 @@ public sealed class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
public override void Dispose()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
base.Dispose();
|
||||
|
||||
try { _CoolerMasterSDK.Reload(); }
|
||||
catch { /* Unlucky.. */ }
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
try { _CoolerMasterSDK.Reload(); }
|
||||
catch { /* Unlucky.. */ }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -17,21 +17,11 @@ public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static CorsairDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="CorsairDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static CorsairDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new CorsairDeviceProvider();
|
||||
}
|
||||
}
|
||||
public static CorsairDeviceProvider Instance => _instance ?? new CorsairDeviceProvider();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||
@ -90,11 +80,8 @@ public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public CorsairDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CorsairDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CorsairDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -313,20 +300,12 @@ public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
public override void Dispose()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
base.Dispose();
|
||||
|
||||
try { _CUESDK.CorsairDisconnect(); }
|
||||
catch { /* at least we tried */ }
|
||||
|
||||
try { _CUESDK.UnloadCUESDK(); }
|
||||
catch { /* at least we tried */ }
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
try { _CUESDK.CorsairDisconnect(); } catch { /* at least we tried */ }
|
||||
try { _CUESDK.UnloadCUESDK(); } catch { /* at least we tried */ }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -18,21 +18,11 @@ public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static CorsairLegacyDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="CorsairLegacyDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static CorsairLegacyDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new CorsairLegacyDeviceProvider();
|
||||
}
|
||||
}
|
||||
public static CorsairLegacyDeviceProvider Instance => _instance ?? new CorsairLegacyDeviceProvider();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||
@ -66,11 +56,8 @@ public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public CorsairLegacyDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CorsairLegacyDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CorsairLegacyDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -214,17 +201,12 @@ public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
public override void Dispose()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
base.Dispose();
|
||||
|
||||
try { _CUESDK.UnloadCUESDK(); }
|
||||
catch { /* at least we tried */ }
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
try { _CUESDK.UnloadCUESDK(); }
|
||||
catch { /* at least we tried */ }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -16,21 +16,11 @@ public sealed class DMXDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static DMXDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="DMXDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static DMXDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new DMXDeviceProvider();
|
||||
}
|
||||
}
|
||||
public static DMXDeviceProvider Instance => _instance ?? new DMXDeviceProvider();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all defined device-definitions.
|
||||
@ -47,11 +37,8 @@ public sealed class DMXDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public DMXDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(DMXDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(DMXDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -99,16 +86,5 @@ public sealed class DMXDeviceProvider : AbstractRGBDeviceProvider
|
||||
return updateTrigger;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -16,21 +16,11 @@ public sealed class DebugDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static DebugDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="DebugDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static DebugDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new DebugDeviceProvider();
|
||||
}
|
||||
}
|
||||
public static DebugDeviceProvider Instance => _instance ?? new DebugDeviceProvider();
|
||||
|
||||
private List<(IDeviceLayout layout, Action<IEnumerable<Led>>? updateLedsAction)> _fakeDeviceDefinitions = new();
|
||||
|
||||
@ -44,11 +34,8 @@ public sealed class DebugDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public DebugDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(DebugDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(DebugDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -79,16 +66,11 @@ public sealed class DebugDeviceProvider : AbstractRGBDeviceProvider
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
public override void Dispose()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
base.Dispose();
|
||||
|
||||
_fakeDeviceDefinitions.Clear();
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
_fakeDeviceDefinitions.Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -20,21 +20,11 @@ public class LogitechDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static LogitechDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="LogitechDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static LogitechDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new LogitechDeviceProvider();
|
||||
}
|
||||
}
|
||||
public static LogitechDeviceProvider Instance => _instance ?? new LogitechDeviceProvider();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||
@ -122,7 +112,7 @@ public class LogitechDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
{ 0x0A78, RGBDeviceType.Speaker, "G560", LedMappings.ZoneSpeaker, (LogitechDeviceType.Speaker, 4, 0) },
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HID-definitions for wireless per-zone-devices.
|
||||
/// </summary>
|
||||
@ -174,12 +164,8 @@ public class LogitechDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public LogitechDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null)
|
||||
throw new InvalidOperationException($"There can be only one instance of type {nameof(LogitechDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(LogitechDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -268,20 +254,17 @@ public class LogitechDeviceProvider : AbstractRGBDeviceProvider
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
public override void Dispose()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
base.Dispose();
|
||||
|
||||
try { _LogitechGSDK.LogiLedRestoreLighting(); }
|
||||
catch { /* at least we tried */ }
|
||||
try { _LogitechGSDK.LogiLedRestoreLighting(); }
|
||||
catch { /* at least we tried */ }
|
||||
|
||||
try { _LogitechGSDK.UnloadLogitechGSDK(); }
|
||||
catch { /* at least we tried */ }
|
||||
try { _LogitechGSDK.UnloadLogitechGSDK(); }
|
||||
catch { /* at least we tried */ }
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -17,21 +17,11 @@ public class MsiDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static MsiDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="MsiDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static MsiDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new MsiDeviceProvider();
|
||||
}
|
||||
}
|
||||
public static MsiDeviceProvider Instance => _instance ?? new MsiDeviceProvider();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||
@ -55,11 +45,8 @@ public class MsiDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public MsiDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(MsiDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(MsiDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -111,17 +98,14 @@ public class MsiDeviceProvider : AbstractRGBDeviceProvider
|
||||
private void ThrowMsiError(int errorCode, bool isCritical = false) => Throw(new MysticLightException(errorCode, _MsiSDK.GetErrorMessage(errorCode)), isCritical);
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
public override void Dispose()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
base.Dispose();
|
||||
|
||||
try { _MsiSDK.UnloadMsiSDK(); }
|
||||
catch { /* at least we tried */ }
|
||||
try { _MsiSDK.UnloadMsiSDK(); }
|
||||
catch { /* at least we tried */ }
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -17,21 +17,11 @@ public sealed class NovationDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static NovationDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="NovationDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static NovationDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new NovationDeviceProvider();
|
||||
}
|
||||
}
|
||||
public static NovationDeviceProvider Instance => _instance ?? new NovationDeviceProvider();
|
||||
|
||||
#endregion
|
||||
|
||||
@ -43,11 +33,8 @@ public sealed class NovationDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
private NovationDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(NovationDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(NovationDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -80,16 +67,5 @@ public sealed class NovationDeviceProvider : AbstractRGBDeviceProvider
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -14,9 +14,6 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private readonly List<OpenRgbClient> _clients = new();
|
||||
|
||||
private static OpenRGBDeviceProvider? _instance;
|
||||
@ -24,14 +21,7 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="OpenRGBDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static OpenRGBDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new OpenRGBDeviceProvider();
|
||||
}
|
||||
}
|
||||
public static OpenRGBDeviceProvider Instance => _instance ?? new OpenRGBDeviceProvider();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all defined device-definitions.
|
||||
@ -58,11 +48,8 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public OpenRGBDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(OpenRGBDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(OpenRGBDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -120,22 +107,22 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider
|
||||
continue;
|
||||
}
|
||||
|
||||
if (device.Zones.Length == 0)
|
||||
if (device.Zones.Length == 0)
|
||||
continue;
|
||||
if (device.Zones.All(z => z.LedCount == 0))
|
||||
if (device.Zones.All(z => z.LedCount == 0))
|
||||
continue;
|
||||
|
||||
OpenRGBUpdateQueue updateQueue = new(GetUpdateTrigger(), i, openRgb, device);
|
||||
|
||||
|
||||
bool anyZoneHasSegments = device.Zones.Any(z => z.Segments.Length > 0);
|
||||
bool splitDeviceByZones = anyZoneHasSegments || PerZoneDeviceFlag.HasFlag(Helper.GetRgbNetDeviceType(device.Type));
|
||||
bool splitDeviceByZones = anyZoneHasSegments || PerZoneDeviceFlag.HasFlag(Helper.GetRgbNetDeviceType(device.Type));
|
||||
|
||||
if (!splitDeviceByZones)
|
||||
{
|
||||
yield return new OpenRGBGenericDevice(new OpenRGBDeviceInfo(device), updateQueue);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
int totalLedCount = 0;
|
||||
|
||||
foreach (Zone zone in device.Zones)
|
||||
@ -162,23 +149,18 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
public override void Dispose()
|
||||
{
|
||||
lock (_lock)
|
||||
base.Dispose();
|
||||
|
||||
foreach (OpenRgbClient client in _clients)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
foreach (OpenRgbClient client in _clients)
|
||||
{
|
||||
try { client.Dispose(); }
|
||||
catch { /* at least we tried */ }
|
||||
}
|
||||
|
||||
_clients.Clear();
|
||||
DeviceDefinitions.Clear();
|
||||
|
||||
_instance = null;
|
||||
try { client.Dispose(); }
|
||||
catch { /* at least we tried */ }
|
||||
}
|
||||
|
||||
_clients.Clear();
|
||||
DeviceDefinitions.Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -25,21 +25,11 @@ public sealed class PicoPiDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static PicoPiDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="PicoPiDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static PicoPiDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new PicoPiDeviceProvider();
|
||||
}
|
||||
}
|
||||
public static PicoPiDeviceProvider Instance => _instance ?? new PicoPiDeviceProvider();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HID-definitions for PicoPi-devices.
|
||||
@ -67,11 +57,8 @@ public sealed class PicoPiDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public PicoPiDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(PicoPiDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(PicoPiDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -139,16 +126,5 @@ public sealed class PicoPiDeviceProvider : AbstractRGBDeviceProvider
|
||||
_sdks.Clear();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -19,21 +19,11 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static RazerDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="RazerDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static RazerDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new RazerDeviceProvider();
|
||||
}
|
||||
}
|
||||
public static RazerDeviceProvider Instance => _instance ?? new RazerDeviceProvider();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||
@ -265,7 +255,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider
|
||||
{ 0x0F13, RGBDeviceType.Unknown, "Lian Li O11", LedMappings.ChromaLink, RazerEndpointType.ChromaLink },
|
||||
{ 0x0F1D, RGBDeviceType.Unknown, "Mouse Bungee V3 Chroma", LedMappings.ChromaLink, RazerEndpointType.ChromaLink },
|
||||
{ 0x0F1F, RGBDeviceType.LedController, "Addressable RGB Controller", LedMappings.ChromaLink, RazerEndpointType.ChromaLink },
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endregion
|
||||
@ -278,11 +268,8 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public RazerDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(RazerDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(RazerDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -356,20 +343,15 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
public override void Dispose()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
base.Dispose();
|
||||
|
||||
TryUnInit();
|
||||
TryUnInit();
|
||||
|
||||
// DarthAffe 03.03.2020: Fails with an access-violation - verify if an unload is already triggered by uninit
|
||||
//try { _RazerSDK.UnloadRazerSDK(); }
|
||||
//catch { /* at least we tried */ }
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
// DarthAffe 03.03.2020: Fails with an access-violation - verify if an unload is already triggered by uninit
|
||||
//try { _RazerSDK.UnloadRazerSDK(); }
|
||||
//catch { /* at least we tried */ }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -20,21 +20,11 @@ public sealed class SteelSeriesDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static SteelSeriesDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="SteelSeriesDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static SteelSeriesDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new SteelSeriesDeviceProvider();
|
||||
}
|
||||
}
|
||||
public static SteelSeriesDeviceProvider Instance => _instance ?? new SteelSeriesDeviceProvider();
|
||||
|
||||
private const int VENDOR_ID = 0x1038;
|
||||
|
||||
@ -103,11 +93,8 @@ public sealed class SteelSeriesDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public SteelSeriesDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(SteelSeriesDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(SteelSeriesDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -146,17 +133,12 @@ public sealed class SteelSeriesDeviceProvider : AbstractRGBDeviceProvider
|
||||
protected override IDeviceUpdateTrigger CreateUpdateTrigger(int id, double updateRateHardLimit) => new DeviceUpdateTrigger(updateRateHardLimit) { HeartbeatTimer = HEARTBEAT_TIMER };
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
public override void Dispose()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
base.Dispose();
|
||||
|
||||
try { SteelSeriesSDK.Dispose(); }
|
||||
catch { /* shit happens */ }
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
try { SteelSeriesSDK.Dispose(); }
|
||||
catch { /* shit happens */ }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -16,21 +16,11 @@ public sealed class WS281XDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static WS281XDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="WS281XDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static WS281XDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new WS281XDeviceProvider();
|
||||
}
|
||||
}
|
||||
public static WS281XDeviceProvider Instance => _instance ?? new WS281XDeviceProvider();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all defined device-definitions.
|
||||
@ -49,11 +39,8 @@ public sealed class WS281XDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public WS281XDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(WS281XDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(WS281XDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -83,16 +70,11 @@ public sealed class WS281XDeviceProvider : AbstractRGBDeviceProvider
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
public override void Dispose()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
base.Dispose();
|
||||
|
||||
DeviceDefinitions.Clear();
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
DeviceDefinitions.Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -16,21 +16,11 @@ public sealed class WootingDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static WootingDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="WootingDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static WootingDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new WootingDeviceProvider();
|
||||
}
|
||||
}
|
||||
public static WootingDeviceProvider Instance => _instance ?? new WootingDeviceProvider();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 windows applications.
|
||||
@ -67,11 +57,8 @@ public sealed class WootingDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public WootingDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(WootingDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(WootingDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -107,19 +94,14 @@ public sealed class WootingDeviceProvider : AbstractRGBDeviceProvider
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
public override void Dispose()
|
||||
{
|
||||
lock (_lock)
|
||||
base.Dispose();
|
||||
|
||||
lock (_WootingSDK.SdkLock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
lock (_WootingSDK.SdkLock)
|
||||
{
|
||||
try { _WootingSDK.UnloadWootingSDK(); }
|
||||
catch { /* at least we tried */ }
|
||||
}
|
||||
|
||||
_instance = null;
|
||||
try { _WootingSDK.UnloadWootingSDK(); }
|
||||
catch { /* at least we tried */ }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user