Attempted to reduce the number of video card library calls

Found some calls that were bypassing the video library state buffering I'd put in place earlier. This should generally make DisplayMagician faster and minimise the number of log entries written to DisplayMagician.log.
This commit is contained in:
Terry MacDonald 2021-10-31 12:50:57 +13:00
parent dfe07ae521
commit f72fc6feea
2 changed files with 11 additions and 10 deletions

View File

@ -454,10 +454,11 @@ namespace DisplayMagicianShared
public virtual bool PreSave()
{
// Prepare our profile data for saving
if (_profileDisplayIdentifiers.Count == 0)
// Disabling as this should never happen now
/*if (_profileDisplayIdentifiers.Count == 0)
{
_profileDisplayIdentifiers = ProfileRepository.GetCurrentDisplayIdentifiers();
}
}*/
// Return if it is valid and we should continue
return IsValid();
@ -638,6 +639,7 @@ namespace DisplayMagicianShared
}
else
{
SharedLogger.logger.Warn($"ProfileRepository/IsPossibleRefresh: We have a current video mode we don't understand, or it's not installed! The current video mode is {ProfileRepository.CurrentVideoMode}. The profile {Name} has a {VideoMode.ToString("G")} video mode and NVIDIALibrary IsInstalled is {NVIDIALibrary.GetLibrary().IsInstalled}, AMDLibrary IsInstalled is {AMDLibrary.GetLibrary().IsInstalled} and WinLibrary IsInstalled is {WinLibrary.GetLibrary().IsInstalled} ");
_isPossible = false;
}
}

View File

@ -769,7 +769,7 @@ namespace DisplayMagicianShared
_profilesLoaded = true;
// Update the current active profile
UpdateActiveProfile();
//UpdateActiveProfile();
IsPossibleRefresh();
return true;
@ -998,7 +998,7 @@ namespace DisplayMagicianShared
{
// We need to refresh the cached answer
// Get the list of connected devices
ConnectedDisplayIdentifiers = GetAllConnectedDisplayIdentifiers();
//ConnectedDisplayIdentifiers = GetAllConnectedDisplayIdentifiers();
if (_profilesLoaded && _allProfiles.Count > 0)
{
@ -1029,15 +1029,15 @@ namespace DisplayMagicianShared
{
if (_currentVideoMode == VIDEO_MODE.NVIDIA && NVIDIALibrary.GetLibrary().IsInstalled)
{
return NVIDIALibrary.GetLibrary().GetCurrentDisplayIdentifiers();
return NVIDIALibrary.GetLibrary().CurrentDisplayIdentifiers;
}
else if (_currentVideoMode == VIDEO_MODE.AMD && AMDLibrary.GetLibrary().IsInstalled)
{
return AMDLibrary.GetLibrary().GetCurrentDisplayIdentifiers();
return AMDLibrary.GetLibrary().CurrentDisplayIdentifiers;
}
else
{
return WinLibrary.GetLibrary().GetCurrentDisplayIdentifiers();
return WinLibrary.GetLibrary().CurrentDisplayIdentifiers;
}
}
@ -1143,14 +1143,13 @@ namespace DisplayMagicianShared
if (wasDisplayChangeSuccessful)
{
result = "was successful";
ProfileRepository.UpdateActiveProfile();
}
// Display the TimeSpan time and result.
SharedLogger.logger.Debug($"ProfileRepository/ApplyProfile: Display change attempt took {ts.Minutes}:{ts.Seconds}.{ts.Milliseconds} and {result}.");
}
ProfileRepository.UpdateActiveProfile();
return ApplyProfileResult.Successful;
}