diff options
author | Jens Peters <jp7677@gmail.com> | 2021-11-28 12:50:48 +0300 |
---|---|---|
committer | Jens Peters <jp7677@gmail.com> | 2022-02-11 19:04:39 +0300 |
commit | 54ffc120b2f9ed2c5aaa59e8764880dd20daec2a (patch) | |
tree | 623b9f97d6732521088863f361914805955b1567 | |
parent | 2d1e92999a474803426269908f38db5dac8fd86a (diff) |
nvapi-drs: Return error code instead of empty setting
Set a profile handle and improve other return code.
-rw-r--r-- | src/nvapi_drs.cpp | 8 | ||||
-rw-r--r-- | src/util/util_statuscode.h | 10 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/nvapi_drs.cpp b/src/nvapi_drs.cpp index 6369d9a..0e2441a 100644 --- a/src/nvapi_drs.cpp +++ b/src/nvapi_drs.cpp @@ -5,7 +5,7 @@ extern "C" { using namespace dxvk; NvAPI_Status __cdecl NvAPI_DRS_CreateSession(NvDRSSessionHandle *phSession) { - *phSession = reinterpret_cast<NvDRSSessionHandle>(nvapiAdapterRegistry->GetAdapter()); // Just another opaque pointer + *phSession = reinterpret_cast<NvDRSSessionHandle>(nvapiAdapterRegistry->GetAdapter()); // Just another opaque pointer, we don't use it anywhere return Ok(__func__); } @@ -14,7 +14,7 @@ extern "C" { } NvAPI_Status __cdecl NvAPI_DRS_FindProfileByName(NvDRSSessionHandle hSession, NvAPI_UnicodeString profileName, NvDRSProfileHandle* phProfile) { - return ExecutableNotFound(str::format(__func__, " (", str::fromnvs(profileName), ")")); + return ProfileNotFound(str::format(__func__, " (", str::fromnvs(profileName), ")")); } NvAPI_Status __cdecl NvAPI_DRS_FindApplicationByName(NvDRSSessionHandle hSession, NvAPI_UnicodeString appName, NvDRSProfileHandle *phProfile, __inout NVDRS_APPLICATION *pApplication) { @@ -22,12 +22,12 @@ extern "C" { } NvAPI_Status __cdecl NvAPI_DRS_GetBaseProfile(NvDRSSessionHandle hSession, NvDRSProfileHandle *phProfile) { + *phProfile = reinterpret_cast<NvDRSProfileHandle>(nvapiAdapterRegistry->GetAdapter()); // Just another opaque pointer, we don't use it anywhere return Ok(__func__); } NvAPI_Status __cdecl NvAPI_DRS_GetSetting(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NvU32 settingId, NVDRS_SETTING *pSetting) { - *pSetting = NVDRS_SETTING{}; - return Ok(str::format(__func__, " (", settingId, ")")); + return SettingNotFound(str::format(__func__, " (", settingId, ")")); } NvAPI_Status __cdecl NvAPI_DRS_DestroySession(NvDRSSessionHandle hSession) { diff --git a/src/util/util_statuscode.h b/src/util/util_statuscode.h index 96ea81f..8f330f2 100644 --- a/src/util/util_statuscode.h +++ b/src/util/util_statuscode.h @@ -131,8 +131,18 @@ namespace dxvk { return NVAPI_NVIDIA_DEVICE_NOT_FOUND; } + inline NvAPI_Status ProfileNotFound(const std::string& logMessage) { + log::write(str::format(logMessage, ": Profile not found")); + return NVAPI_PROFILE_NOT_FOUND; + } + inline NvAPI_Status ExecutableNotFound(const std::string& logMessage) { log::write(str::format(logMessage, ": Executable not found")); return NVAPI_EXECUTABLE_NOT_FOUND; } + + inline NvAPI_Status SettingNotFound(const std::string& logMessage) { + log::write(str::format(logMessage, ": Setting not found")); + return NVAPI_SETTING_NOT_FOUND; + } } |