diff --git a/src/single_window/render.cpp b/src/single_window/render.cpp index cdbb626..64fafed 100644 --- a/src/single_window/render.cpp +++ b/src/single_window/render.cpp @@ -548,7 +548,7 @@ int Render::AudioDeviceInit() { int Render::AudioDeviceDestroy() { SDL_PauseAudioDevice(output_dev_, 1); - // SDL_CloseAudioDevice(output_dev_); + SDL_CloseAudioDevice(output_dev_); // SDL_CloseAudioDevice(input_dev_); return 0; @@ -1084,11 +1084,16 @@ void Render::Cleanup() { mouse_controller_ = nullptr; } + if (keyboard_capturer_) { + delete keyboard_capturer_; + keyboard_capturer_ = nullptr; + } + CleanupFactories(); CleanupPeers(); AudioDeviceDestroy(); - DestroyMainWindow(); DestroyMainWindowContext(); + DestroyMainWindow(); SDL_Quit(); } diff --git a/src/speaker_capturer/linux/speaker_capturer_linux.cpp b/src/speaker_capturer/linux/speaker_capturer_linux.cpp index 4b58799..5b442fa 100644 --- a/src/speaker_capturer/linux/speaker_capturer_linux.cpp +++ b/src/speaker_capturer/linux/speaker_capturer_linux.cpp @@ -14,7 +14,8 @@ constexpr pa_sample_format_t kFormat = PA_SAMPLE_S16LE; constexpr int kChannels = 1; constexpr size_t kFrameSizeBytes = 480 * sizeof(int16_t); -SpeakerCapturerLinux::SpeakerCapturerLinux() {} +SpeakerCapturerLinux::SpeakerCapturerLinux() + : inited_(false), paused_(false), stop_flag_(false) {} SpeakerCapturerLinux::~SpeakerCapturerLinux() { Stop(); Destroy(); @@ -42,36 +43,39 @@ std::string SpeakerCapturerLinux::GetDefaultMonitorSourceName() { pa_mainloop_api* api = pa_mainloop_get_api(mainloop); pa_context* context = pa_context_new(api, "GetMonitor"); + struct CallbackState { + std::string* name; + std::mutex* mtx; + std::condition_variable* cv; + bool* ready; + } state{&monitor_name, &mtx, &cv, &ready}; + pa_context_set_state_callback( context, [](pa_context* c, void* userdata) { - auto* state = - static_cast*>(userdata); + auto* state = static_cast(userdata); if (pa_context_get_state(c) == PA_CONTEXT_READY) { - pa_operation* o = pa_context_get_server_info( + pa_operation* operation = pa_context_get_server_info( c, [](pa_context*, const pa_server_info* info, void* userdata) { - auto* state = - static_cast*>( - userdata); + auto* state = static_cast(userdata); if (info && info->default_sink_name) { - *(std::get<0>(*state)) = + *(state->name) = std::string(info->default_sink_name) + ".monitor"; } { - std::lock_guard lock(*std::get<1>(*state)); - *std::get<3>(*state) = true; + std::lock_guard lock(*(state->mtx)); + *(state->ready) = true; } - std::get<2>(*state)->notify_one(); + state->cv->notify_one(); }, userdata); - if (o) pa_operation_unref(o); + if (operation) { + pa_operation_unref(operation); + } } }, - new std::tuple(&monitor_name, &mtx, &cv, &ready)); + &state); pa_context_connect(context, nullptr, PA_CONTEXT_NOFLAGS, nullptr); diff --git a/thirdparty/minirtc b/thirdparty/minirtc index c9f8859..74c8e10 160000 --- a/thirdparty/minirtc +++ b/thirdparty/minirtc @@ -1 +1 @@ -Subproject commit c9f88596054133aba8f9d73ca536fa5ee8863a64 +Subproject commit 74c8e1062af9e7998b14cd43049a415abbef2c26