mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-17 22:23:31 +00:00
Improve robustness of DRM property value handling
This commit is contained in:
@@ -53,14 +53,6 @@ extern "C" {
|
|||||||
#define DRM_FORMAT_XYUV8888 fourcc_code('X', 'Y', 'U', 'V')
|
#define DRM_FORMAT_XYUV8888 fourcc_code('X', 'Y', 'U', 'V')
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Values for "Colorspace" connector property
|
|
||||||
#ifndef DRM_MODE_COLORIMETRY_DEFAULT
|
|
||||||
#define DRM_MODE_COLORIMETRY_DEFAULT 0
|
|
||||||
#endif
|
|
||||||
#ifndef DRM_MODE_COLORIMETRY_BT2020_RGB
|
|
||||||
#define DRM_MODE_COLORIMETRY_BT2020_RGB 9
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -785,7 +777,8 @@ void DrmRenderer::setHdrMode(bool enabled)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (auto prop = m_Connector.property("max bpc")) {
|
if (auto prop = m_Connector.property("max bpc")) {
|
||||||
m_PropSetter.set(*prop, enabled ? 10 : 8);
|
auto range = prop->range();
|
||||||
|
m_PropSetter.set(*prop, std::clamp<uint64_t>(enabled ? 10 : 8, range.first, range.second));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto prop = m_Connector.property("HDR_OUTPUT_METADATA")) {
|
if (auto prop = m_Connector.property("HDR_OUTPUT_METADATA")) {
|
||||||
|
|||||||
@@ -96,8 +96,13 @@ class DrmRenderer : public IFFmpegRenderer {
|
|||||||
return m_Values.find(name) != m_Values.end();
|
return m_Values.find(name) != m_Values.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t value(const std::string &name) const {
|
std::optional<uint64_t> value(const std::string &name) const {
|
||||||
return m_Values.find(name)->second;
|
if (auto it = m_Values.find(name); it != m_Values.end()) {
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t objectId() const {
|
uint32_t objectId() const {
|
||||||
@@ -267,7 +272,16 @@ class DrmRenderer : public IFFmpegRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool set(const DrmProperty& prop, const std::string &value) {
|
bool set(const DrmProperty& prop, const std::string &value) {
|
||||||
if (set(prop, prop.value(value), false)) {
|
std::optional<uint64_t> propValue = prop.value(value);
|
||||||
|
if (!propValue) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Property '%s' has no supported enum value '%s'",
|
||||||
|
prop.name(),
|
||||||
|
value.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (set(prop, *propValue, false)) {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Set property '%s': %s",
|
"Set property '%s': %s",
|
||||||
prop.name(),
|
prop.name(),
|
||||||
|
|||||||
Reference in New Issue
Block a user