diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index c31ca946..4cb021bb 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -289,12 +289,8 @@ int Session::getDecoderCapabilities(StreamingPreferences::VideoDecoderSelection { IVideoDecoder* decoder; - if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, - "SDL_InitSubSystem(SDL_INIT_VIDEO) failed: %s", - SDL_GetError()); - return false; - } + // Video must already be initialized to use this function + SDL_assert(SDL_WasInit(SDL_INIT_VIDEO)); SDL_Window* window = SDL_CreateWindow("", 0, 0, width, height, SDL_WINDOW_HIDDEN); if (!window) { @@ -319,8 +315,6 @@ int Session::getDecoderCapabilities(StreamingPreferences::VideoDecoderSelection // the renderer may want to interact with the window SDL_DestroyWindow(window); - SDL_QuitSubSystem(SDL_INIT_VIDEO); - return caps; } @@ -601,13 +595,6 @@ bool Session::validateLaunch() return false; } - // Add the capability flags from the chosen decoder/renderer - m_VideoCallbacks.capabilities |= getDecoderCapabilities(m_Preferences->videoDecoderSelection, - m_StreamConfig.supportsHevc ? VIDEO_FORMAT_H265 : VIDEO_FORMAT_H264, - m_StreamConfig.width, - m_StreamConfig.height, - m_StreamConfig.fps); - return true; } @@ -932,6 +919,14 @@ void Session::exec(int displayOriginX, int displayOriginY) hostInfo.serverInfoGfeVersion = siGfeVersion.data(); } + // Add the capability flags from the chosen decoder/renderer + // Requires SDL_INIT_VIDEO already done. + m_VideoCallbacks.capabilities |= getDecoderCapabilities(m_Preferences->videoDecoderSelection, + m_StreamConfig.supportsHevc ? VIDEO_FORMAT_H265 : VIDEO_FORMAT_H264, + m_StreamConfig.width, + m_StreamConfig.height, + m_StreamConfig.fps); + int err = LiStartConnection(&hostInfo, &m_StreamConfig, &k_ConnCallbacks, &m_VideoCallbacks, m_AudioDisabled ? nullptr : &k_AudioCallbacks, diff --git a/app/streaming/session.h b/app/streaming/session.h index 99eaa9ab..8369572c 100644 --- a/app/streaming/session.h +++ b/app/streaming/session.h @@ -28,10 +28,6 @@ public: bool isHardwareDecodeAvailable(StreamingPreferences::VideoDecoderSelection vds, int videoFormat, int width, int height, int frameRate); - static - int getDecoderCapabilities(StreamingPreferences::VideoDecoderSelection vds, - int videoFormat, int width, int height, int frameRate); - static Session* get() { return s_ActiveSession; @@ -64,7 +60,9 @@ private: void emitLaunchWarning(QString text); - int getDecoderCapabilities(); + static + int getDecoderCapabilities(StreamingPreferences::VideoDecoderSelection vds, + int videoFormat, int width, int height, int frameRate); IAudioRenderer* createAudioRenderer();