mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-02-16 02:30:52 +00:00
Don't use separate threads for querying SDL video info
This is no longer necessary now that we force Qt and SDL to use EGL.
This commit is contained in:
@@ -95,36 +95,7 @@ int SystemProperties::getRefreshRate(int displayIndex)
|
|||||||
return monitorRefreshRates.value(displayIndex);
|
return monitorRefreshRates.value(displayIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
class QuerySdlVideoThread : public QThread
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QuerySdlVideoThread(SystemProperties* me) :
|
|
||||||
QThread(nullptr),
|
|
||||||
m_Me(me) {}
|
|
||||||
|
|
||||||
void run() override
|
|
||||||
{
|
|
||||||
m_Me->querySdlVideoInfoInternal();
|
|
||||||
}
|
|
||||||
|
|
||||||
SystemProperties* m_Me;
|
|
||||||
};
|
|
||||||
|
|
||||||
void SystemProperties::querySdlVideoInfo()
|
void SystemProperties::querySdlVideoInfo()
|
||||||
{
|
|
||||||
if (WMUtils::isRunningX11() || WMUtils::isRunningWayland()) {
|
|
||||||
// Use a separate thread to temporarily initialize SDL
|
|
||||||
// video to avoid stomping on Qt's X11 and OGL state.
|
|
||||||
QuerySdlVideoThread thread(this);
|
|
||||||
thread.start();
|
|
||||||
thread.wait();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
querySdlVideoInfoInternal();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SystemProperties::querySdlVideoInfoInternal()
|
|
||||||
{
|
{
|
||||||
hasHardwareAcceleration = false;
|
hasHardwareAcceleration = false;
|
||||||
|
|
||||||
@@ -136,8 +107,7 @@ void SystemProperties::querySdlVideoInfoInternal()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update display related attributes (max FPS, native resolution, etc).
|
// Update display related attributes (max FPS, native resolution, etc).
|
||||||
// We call the internal variant because we're already in a safe thread context.
|
refreshDisplays();
|
||||||
refreshDisplaysInternal();
|
|
||||||
|
|
||||||
SDL_Window* testWindow = SDL_CreateWindow("", 0, 0, 1280, 720,
|
SDL_Window* testWindow = SDL_CreateWindow("", 0, 0, 1280, 720,
|
||||||
SDL_WINDOW_HIDDEN | StreamUtils::getPlatformWindowFlags());
|
SDL_WINDOW_HIDDEN | StreamUtils::getPlatformWindowFlags());
|
||||||
@@ -163,36 +133,7 @@ void SystemProperties::querySdlVideoInfoInternal()
|
|||||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||||
}
|
}
|
||||||
|
|
||||||
class RefreshDisplaysThread : public QThread
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
RefreshDisplaysThread(SystemProperties* me) :
|
|
||||||
QThread(nullptr),
|
|
||||||
m_Me(me) {}
|
|
||||||
|
|
||||||
void run() override
|
|
||||||
{
|
|
||||||
m_Me->refreshDisplaysInternal();
|
|
||||||
}
|
|
||||||
|
|
||||||
SystemProperties* m_Me;
|
|
||||||
};
|
|
||||||
|
|
||||||
void SystemProperties::refreshDisplays()
|
void SystemProperties::refreshDisplays()
|
||||||
{
|
|
||||||
if (WMUtils::isRunningX11() || WMUtils::isRunningWayland()) {
|
|
||||||
// Use a separate thread to temporarily initialize SDL
|
|
||||||
// video to avoid stomping on Qt's X11 and OGL state.
|
|
||||||
RefreshDisplaysThread thread(this);
|
|
||||||
thread.start();
|
|
||||||
thread.wait();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
refreshDisplaysInternal();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SystemProperties::refreshDisplaysInternal()
|
|
||||||
{
|
{
|
||||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
|
if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
|||||||
@@ -38,8 +38,6 @@ signals:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void querySdlVideoInfo();
|
void querySdlVideoInfo();
|
||||||
void querySdlVideoInfoInternal();
|
|
||||||
void refreshDisplaysInternal();
|
|
||||||
|
|
||||||
bool hasHardwareAcceleration;
|
bool hasHardwareAcceleration;
|
||||||
bool rendererAlwaysFullScreen;
|
bool rendererAlwaysFullScreen;
|
||||||
|
|||||||
Reference in New Issue
Block a user