mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-18 10:32:38 +00:00
Fix a few bugs in CVDisplayLink integration in VTRenderer
This commit is contained in:
parent
c975279589
commit
97fb30cdf1
@ -31,15 +31,18 @@ public:
|
|||||||
virtual ~VTRenderer() override
|
virtual ~VTRenderer() override
|
||||||
{
|
{
|
||||||
if (m_DisplayLink != nullptr) {
|
if (m_DisplayLink != nullptr) {
|
||||||
// Wake up the renderer in case it is waiting for v-sync
|
|
||||||
SDL_LockMutex(m_VsyncMutex);
|
|
||||||
SDL_CondSignal(m_VsyncPassed);
|
|
||||||
SDL_UnlockMutex(m_VsyncMutex);
|
|
||||||
|
|
||||||
CVDisplayLinkStop(m_DisplayLink);
|
CVDisplayLinkStop(m_DisplayLink);
|
||||||
CVDisplayLinkRelease(m_DisplayLink);
|
CVDisplayLinkRelease(m_DisplayLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_VsyncPassed != nullptr) {
|
||||||
|
SDL_DestroyCond(m_VsyncPassed);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_VsyncMutex != nullptr) {
|
||||||
|
SDL_DestroyMutex(m_VsyncMutex);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_HwContext != nullptr) {
|
if (m_HwContext != nullptr) {
|
||||||
av_buffer_unref(&m_HwContext);
|
av_buffer_unref(&m_HwContext);
|
||||||
}
|
}
|
||||||
@ -59,14 +62,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
CGDirectDisplayID
|
|
||||||
getDisplayID(NSScreen* screen)
|
|
||||||
{
|
|
||||||
NSNumber* screenNumber = [screen deviceDescription][@"NSScreenNumber"];
|
|
||||||
return [screenNumber unsignedIntValue];
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
static
|
||||||
CVReturn
|
CVReturn
|
||||||
displayLinkOutputCallback(
|
displayLinkOutputCallback(
|
||||||
@ -102,8 +97,7 @@ public:
|
|||||||
status = CVDisplayLinkCreateWithActiveCGDisplays(&m_DisplayLink);
|
status = CVDisplayLinkCreateWithActiveCGDisplays(&m_DisplayLink);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CGDirectDisplayID displayId;
|
CGDirectDisplayID displayId = [[screen deviceDescription][@"NSScreenNumber"] unsignedIntValue];
|
||||||
displayId = getDisplayID(screen);
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"NSWindow on display: %x",
|
"NSWindow on display: %x",
|
||||||
displayId);
|
displayId);
|
||||||
@ -198,7 +192,10 @@ public:
|
|||||||
if (m_DisplayLink != nullptr) {
|
if (m_DisplayLink != nullptr) {
|
||||||
// Vsync is enabled, so wait for a swap before returning
|
// Vsync is enabled, so wait for a swap before returning
|
||||||
SDL_LockMutex(m_VsyncMutex);
|
SDL_LockMutex(m_VsyncMutex);
|
||||||
SDL_CondWait(m_VsyncPassed, m_VsyncMutex);
|
if (SDL_CondWaitTimeout(m_VsyncPassed, m_VsyncMutex, 100) == SDL_MUTEX_TIMEDOUT) {
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"V-sync wait timed out after 100 ms");
|
||||||
|
}
|
||||||
SDL_UnlockMutex(m_VsyncMutex);
|
SDL_UnlockMutex(m_VsyncMutex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user