fix crash on startup when no displays are active, set thread execution state when powering off tv on standby

This commit is contained in:
Vincent Maas committed 2021-01-30 15:23:06 +01:00
1 parent 04d52d6062
commit d2aacbb8e0
4 files changed
+28 -8

No files matched your search

+23 -3
View File
@@ -225,7 +225,18 @@ namespace ColorControl
if (_lgService.Config.PowerOffOnStandby)
{
_lgService.PowerOff();
NativeMethods.SetThreadExecutionState(NativeConstants.ES_CONTINUOUS | NativeConstants.ES_SYSTEM_REQUIRED | NativeConstants.ES_AWAYMODE_REQUIRED);
try
{
Logger.Debug("Powering off tv...");
var task = _lgService.PowerOff();
Utils.WaitForTask(task);
Logger.Debug("Done powering off tv");
}
finally
{
NativeMethods.SetThreadExecutionState(NativeConstants.ES_CONTINUOUS);
}
}
}
@@ -369,9 +380,18 @@ namespace ColorControl
return;
}
var text = "ColorControl";
Display[] displays;
try
{
displays = _nvService.GetDisplays();
}
catch (Exception e)
{
Logger.Error("Error while getting displays: " + e.ToLogString());
return;
}
var displays = _nvService.GetDisplays();
var text = TS_TASKNAME;
foreach (var display in displays)
{
var id = Math.Abs((int)display.Handle.MemoryAddress.ToInt64());