diff --git a/src/streaming/GameStreamClient.hpp b/src/streaming/GameStreamClient.hpp index 3a4fce3..ff9ac2a 100644 --- a/src/streaming/GameStreamClient.hpp +++ b/src/streaming/GameStreamClient.hpp @@ -8,8 +8,6 @@ #pragma once -extern void perform_async(std::function task); - template struct GSResult { public: diff --git a/src/streaming/MoonlightSession.cpp b/src/streaming/MoonlightSession.cpp index 8582023..1885aeb 100644 --- a/src/streaming/MoonlightSession.cpp +++ b/src/streaming/MoonlightSession.cpp @@ -157,7 +157,7 @@ void MoonlightSession::audio_renderer_decode_and_play_sample(char* sample_data, // MARK: MoonlightSession -void MoonlightSession::start(std::function callback) { +void MoonlightSession::start(ServerCallback callback) { LiInitializeStreamConfiguration(&m_config); int h = Settings::settings()->resolution(); @@ -218,17 +218,18 @@ void MoonlightSession::start(std::function callback) { if (result.isSuccess()) { m_config = result.value(); - perform_async([this, callback] { - auto m_data = GameStreamClient::client()->server_data(m_address); - LiStartConnection(&m_data.serverInfo, &m_config, &m_connection_callbacks, &m_video_callbacks, &m_audio_callbacks, NULL, 0, NULL, 0); - - nanogui::async([this, callback] { - callback(true); - }); - }); + auto m_data = GameStreamClient::client()->server_data(m_address); + int result = LiStartConnection(&m_data.serverInfo, &m_config, &m_connection_callbacks, &m_video_callbacks, &m_audio_callbacks, NULL, 0, NULL, 0); + + if (result != 0) { + LiStopConnection(); + callback(GSResult::failure("Failed to start stream...")); + } else { + callback(GSResult::success(true)); + } } else { LOG_FMT("Failed to start stream: %s\n", result.error().c_str()); - callback(false); + callback(GSResult::failure(result.error())); } }); } diff --git a/src/streaming/MoonlightSession.hpp b/src/streaming/MoonlightSession.hpp index ac72f59..2dc7713 100644 --- a/src/streaming/MoonlightSession.hpp +++ b/src/streaming/MoonlightSession.hpp @@ -26,7 +26,7 @@ public: m_audio_renderer = audio_renderer; } - void start(std::function callback); + void start(ServerCallback callback); void stop(int terminate_app); void draw(); diff --git a/src/ui/windows/StreamWindow.cpp b/src/ui/windows/StreamWindow.cpp index c19b795..532dba3 100644 --- a/src/ui/windows/StreamWindow.cpp +++ b/src/ui/windows/StreamWindow.cpp @@ -45,9 +45,11 @@ StreamWindow::StreamWindow(Widget *parent, const std::string &address, int app_i m_loader = NULL; } - if (result) { + if (result.isSuccess()) { // } else { + screen()->add(MessageDialog::Type::Information, "Error", result.error()); + auto app = static_cast(screen()); app->pop_window(); }