mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Added AMD ADL Exception handling
This commit is contained in:
parent
a01d5defaa
commit
9065735ad9
@ -605,7 +605,11 @@ namespace DisplayMagicianShared.AMD
|
|||||||
int NumberOfDisplays = 0;
|
int NumberOfDisplays = 0;
|
||||||
|
|
||||||
List<string> displayIdentifiers = new List<string>();
|
List<string> displayIdentifiers = new List<string>();
|
||||||
|
IntPtr AdapterBuffer = IntPtr.Zero;
|
||||||
|
IntPtr DisplayBuffer = IntPtr.Zero;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (null != ADL.ADL2_Adapter_NumberOfAdapters_Get)
|
if (null != ADL.ADL2_Adapter_NumberOfAdapters_Get)
|
||||||
{
|
{
|
||||||
ADL.ADL2_Adapter_NumberOfAdapters_Get(_adlContextHandle, ref NumberOfAdapters);
|
ADL.ADL2_Adapter_NumberOfAdapters_Get(_adlContextHandle, ref NumberOfAdapters);
|
||||||
@ -618,7 +622,7 @@ namespace DisplayMagicianShared.AMD
|
|||||||
ADLAdapterInfoX2Array OSAdapterInfoData;
|
ADLAdapterInfoX2Array OSAdapterInfoData;
|
||||||
OSAdapterInfoData = new ADLAdapterInfoX2Array();
|
OSAdapterInfoData = new ADLAdapterInfoX2Array();
|
||||||
|
|
||||||
IntPtr AdapterBuffer = IntPtr.Zero;
|
|
||||||
if (ADL.ADL2_Adapter_AdapterInfoX4_Get != null)
|
if (ADL.ADL2_Adapter_AdapterInfoX4_Get != null)
|
||||||
{
|
{
|
||||||
SharedLogger.logger.Trace($"ADLWrapper/GenerateProfileDisplayIdentifiers: ADL2_Adapter_AdapterInfoX4_Get DLL function exists.");
|
SharedLogger.logger.Trace($"ADLWrapper/GenerateProfileDisplayIdentifiers: ADL2_Adapter_AdapterInfoX4_Get DLL function exists.");
|
||||||
@ -720,7 +724,7 @@ namespace DisplayMagicianShared.AMD
|
|||||||
|
|
||||||
if (ADL.ADL2_Display_DisplayInfo_Get != null)
|
if (ADL.ADL2_Display_DisplayInfo_Get != null)
|
||||||
{
|
{
|
||||||
IntPtr DisplayBuffer = IntPtr.Zero;
|
DisplayBuffer = IntPtr.Zero;
|
||||||
|
|
||||||
// Force the display detection and get the Display Info. Use 0 as last parameter to NOT force detection
|
// Force the display detection and get the Display Info. Use 0 as last parameter to NOT force detection
|
||||||
ADLRet = ADL.ADL2_Display_DisplayInfo_Get(_adlContextHandle, oneAdapter.AdapterIndex, ref NumberOfDisplays, out DisplayBuffer, 0);
|
ADLRet = ADL.ADL2_Display_DisplayInfo_Get(_adlContextHandle, oneAdapter.AdapterIndex, ref NumberOfDisplays, out DisplayBuffer, 0);
|
||||||
@ -1024,7 +1028,7 @@ namespace DisplayMagicianShared.AMD
|
|||||||
SharedLogger.logger.Warn($"ADLWrapper/GenerateProfileDisplayIdentifiers: Error running ADL2_Display_DisplayInfo_Get on Adapter #{oneAdapter.AdapterIndex}: {ADL.ConvertADLReturnValueIntoWords(ADLRet)}");
|
SharedLogger.logger.Warn($"ADLWrapper/GenerateProfileDisplayIdentifiers: Error running ADL2_Display_DisplayInfo_Get on Adapter #{oneAdapter.AdapterIndex}: {ADL.ConvertADLReturnValueIntoWords(ADLRet)}");
|
||||||
}
|
}
|
||||||
// Release the memory for the DisplayInfo structure
|
// Release the memory for the DisplayInfo structure
|
||||||
if (IntPtr.Zero != DisplayBuffer)
|
if (DisplayBuffer != IntPtr.Zero)
|
||||||
Marshal.FreeCoTaskMem(DisplayBuffer);
|
Marshal.FreeCoTaskMem(DisplayBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1040,7 +1044,7 @@ namespace DisplayMagicianShared.AMD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Release the memory for the AdapterInfo structure
|
// Release the memory for the AdapterInfo structure
|
||||||
if (IntPtr.Zero != AdapterBuffer)
|
if (AdapterBuffer != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
Marshal.FreeCoTaskMem(AdapterBuffer);
|
Marshal.FreeCoTaskMem(AdapterBuffer);
|
||||||
}
|
}
|
||||||
@ -1054,5 +1058,22 @@ namespace DisplayMagicianShared.AMD
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
SharedLogger.logger.Warn(ex, $"ADLWrapper/GenerateProfileDisplayIdentifiers: Exception somewhere while trying to generate an AMD display identifier");
|
||||||
|
|
||||||
|
// Release the memory for the AdapterInfo structure
|
||||||
|
if (AdapterBuffer != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
Marshal.FreeCoTaskMem(AdapterBuffer);
|
||||||
|
}
|
||||||
|
// Release the memory for the DisplayInfo structure
|
||||||
|
if (DisplayBuffer != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
Marshal.FreeCoTaskMem(DisplayBuffer);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -799,7 +799,7 @@ namespace DisplayMagicianShared
|
|||||||
|
|
||||||
List<string> displayIdentifiers = new List<string>();
|
List<string> displayIdentifiers = new List<string>();
|
||||||
bool isNvidia = false;
|
bool isNvidia = false;
|
||||||
bool isAMD = false;
|
//bool isAMD = false;
|
||||||
|
|
||||||
// If the Video Card is an NVidia, then we should generate specific NVidia displayIdentifiers
|
// If the Video Card is an NVidia, then we should generate specific NVidia displayIdentifiers
|
||||||
|
|
||||||
@ -918,7 +918,7 @@ namespace DisplayMagicianShared
|
|||||||
// else if there is an AMD video card then we use that mode
|
// else if there is an AMD video card then we use that mode
|
||||||
else if (AMDLibrary.IsInstalled)
|
else if (AMDLibrary.IsInstalled)
|
||||||
{
|
{
|
||||||
isAMD = true;
|
//isAMD = true;
|
||||||
SharedLogger.logger.Debug($"ProfileRepository/GenerateProfileDisplayIdentifiers: The video card is an AMD video card.");
|
SharedLogger.logger.Debug($"ProfileRepository/GenerateProfileDisplayIdentifiers: The video card is an AMD video card.");
|
||||||
// Needs a lot of work here! We need to check if the AMD returned the right stuff, and then use Windows if there is an error.
|
// Needs a lot of work here! We need to check if the AMD returned the right stuff, and then use Windows if there is an error.
|
||||||
return AMDLibrary.GenerateProfileDisplayIdentifiers();
|
return AMDLibrary.GenerateProfileDisplayIdentifiers();
|
||||||
|
Loading…
Reference in New Issue
Block a user