mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-03 00:06:09 +00:00
Refactor plane property loop to avoid leak
This commit is contained in:
parent
fbe5e6f01f
commit
e458682a23
@ -450,7 +450,6 @@ bool DrmRenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
// FIXME: We should check the actual DRM format in a real AVFrame rather
|
// FIXME: We should check the actual DRM format in a real AVFrame rather
|
||||||
// than just assuming it will be a certain hardcoded type like NV12 based
|
// than just assuming it will be a certain hardcoded type like NV12 based
|
||||||
// on the chosen video format.
|
// on the chosen video format.
|
||||||
m_PlaneId = 0;
|
|
||||||
uint64_t maxZpos = 0;
|
uint64_t maxZpos = 0;
|
||||||
for (uint32_t i = 0; i < planeRes->count_planes; i++) {
|
for (uint32_t i = 0; i < planeRes->count_planes; i++) {
|
||||||
drmModePlane* plane = drmModeGetPlane(m_DrmFd, planeRes->planes[i]);
|
drmModePlane* plane = drmModeGetPlane(m_DrmFd, planeRes->planes[i]);
|
||||||
@ -494,18 +493,22 @@ bool DrmRenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
|
|
||||||
drmModeObjectPropertiesPtr props = drmModeObjectGetProperties(m_DrmFd, planeRes->planes[i], DRM_MODE_OBJECT_PLANE);
|
drmModeObjectPropertiesPtr props = drmModeObjectGetProperties(m_DrmFd, planeRes->planes[i], DRM_MODE_OBJECT_PLANE);
|
||||||
if (props != nullptr) {
|
if (props != nullptr) {
|
||||||
// Only consider primary and overlay planes as valid render targets
|
|
||||||
uint64_t type;
|
uint64_t type;
|
||||||
|
uint64_t zPos = 0;
|
||||||
|
|
||||||
|
// Only consider primary and overlay planes as valid render targets
|
||||||
if (!getPropertyByName(props, "type", &type) || (type != DRM_PLANE_TYPE_PRIMARY && type != DRM_PLANE_TYPE_OVERLAY)) {
|
if (!getPropertyByName(props, "type", &type) || (type != DRM_PLANE_TYPE_PRIMARY && type != DRM_PLANE_TYPE_OVERLAY)) {
|
||||||
drmModeFreePlane(plane);
|
drmModeFreePlane(plane);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
// If this plane has a zpos property and it's lower (further from user) than
|
||||||
// If this is a higher Z position than the last candidate plane,
|
// the previous plane we found, avoid this plane in favor of the closer one.
|
||||||
// let's prefer this one over the previous one. Note: zpos is not
|
//
|
||||||
// a required property, but if any plane has it, all planes must.
|
// Note: zpos is not a required property, but if any plane has it, all planes must.
|
||||||
uint64_t zPos = 0;
|
else if (getPropertyByName(props, "zpos", &zPos) && m_PlaneId && zPos < maxZpos) {
|
||||||
if (!getPropertyByName(props, "zpos", &zPos) || !m_Plane || zPos > maxZpos) {
|
drmModeFreePlane(plane);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// This plane is a better match than what we had previously!
|
||||||
m_PlaneId = plane->plane_id;
|
m_PlaneId = plane->plane_id;
|
||||||
maxZpos = zPos;
|
maxZpos = zPos;
|
||||||
|
|
||||||
@ -514,9 +517,6 @@ bool DrmRenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
}
|
}
|
||||||
m_Plane = plane;
|
m_Plane = plane;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
drmModeFreePlane(plane);
|
|
||||||
}
|
|
||||||
|
|
||||||
drmModeFreeObjectProperties(props);
|
drmModeFreeObjectProperties(props);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user