diff --git a/src/gui/panels/remote_peer_panel.cpp b/src/gui/panels/remote_peer_panel.cpp index 6da5f3c..962e1fc 100644 --- a/src/gui/panels/remote_peer_panel.cpp +++ b/src/gui/panels/remote_peer_panel.cpp @@ -90,7 +90,7 @@ int Render::RemoteWindow() { target_remote_id = props.remote_id; target_password = props.password; { - std::shared_lock lock(client_properties_mutex_); + // std::shared_lock lock(client_properties_mutex_); if (client_properties_.find(remote_id) != client_properties_.end()) { if (!client_properties_[remote_id]->connection_established_) { @@ -126,7 +126,7 @@ int Render::RemoteWindow() { if (elapsed >= 1000) { last_rejoin_check_time_ = now; need_to_rejoin_ = false; - std::shared_lock lock(client_properties_mutex_); + // std::shared_lock lock(client_properties_mutex_); for (const auto& [_, props] : client_properties_) { if (props->rejoin_) { ConnectTo(props->remote_id_, props->remote_password_, @@ -161,17 +161,17 @@ int Render::ConnectTo(const std::string& remote_id, const char* password, LOG_INFO("Connect to [{}]", remote_id); focused_remote_id_ = remote_id; - std::shared_lock shared_lock(client_properties_mutex_); + // std::shared_lock shared_lock(client_properties_mutex_); bool exists = (client_properties_.find(remote_id) != client_properties_.end()); - shared_lock.unlock(); + // shared_lock.unlock(); if (!exists) { PeerPtr* peer_to_init = nullptr; std::string local_id; { - std::unique_lock unique_lock(client_properties_mutex_); + // std::unique_lock unique_lock(client_properties_mutex_); if (client_properties_.find(remote_id) == client_properties_.end()) { client_properties_[remote_id] = std::make_shared(); @@ -208,7 +208,7 @@ int Render::ConnectTo(const std::string& remote_id, const char* password, } int ret = -1; - std::shared_lock read_lock(client_properties_mutex_); + // std::shared_lock read_lock(client_properties_mutex_); auto props = client_properties_[remote_id]; if (!props->connection_established_) { props->remember_password_ = remember_password; @@ -230,7 +230,7 @@ int Render::ConnectTo(const std::string& remote_id, const char* password, } } } - read_lock.unlock(); + // read_lock.unlock(); return 0; } diff --git a/src/gui/render.cpp b/src/gui/render.cpp index 4815f97..1cabf8e 100644 --- a/src/gui/render.cpp +++ b/src/gui/render.cpp @@ -947,7 +947,7 @@ int Render::DrawStreamWindow() { ImGui::Render(); SDL_RenderClear(stream_renderer_); - std::shared_lock lock(client_properties_mutex_); + // std::shared_lock lock(client_properties_mutex_); for (auto& it : client_properties_) { auto props = it.second; if (props->tab_selected_) { @@ -1285,7 +1285,7 @@ void Render::CleanupPeers() { } { - std::shared_lock lock(client_properties_mutex_); + // std::shared_lock lock(client_properties_mutex_); for (auto& it : client_properties_) { auto props = it.second; CleanupPeer(props); @@ -1293,7 +1293,7 @@ void Render::CleanupPeers() { } { - std::unique_lock lock(client_properties_mutex_); + // std::unique_lock lock(client_properties_mutex_); client_properties_.clear(); } } @@ -1312,7 +1312,7 @@ void Render::CleanSubStreamWindowProperties( } void Render::UpdateRenderRect() { - std::shared_lock lock(client_properties_mutex_); + // std::shared_lock lock(client_properties_mutex_); for (auto& [_, props] : client_properties_) { if (!props->reset_control_bar_pos_) { props->mouse_diff_control_bar_pos_x_ = 0; @@ -1388,7 +1388,7 @@ void Render::ProcessSdlEvent(const SDL_Event& event) { DestroyStreamWindowContext(); { - std::shared_lock lock(client_properties_mutex_); + // std::shared_lock lock(client_properties_mutex_); for (auto& [host_name, props] : client_properties_) { thumbnail_->SaveToThumbnail( (char*)props->dst_buffer_, props->video_width_, @@ -1419,7 +1419,7 @@ void Render::ProcessSdlEvent(const SDL_Event& event) { } { - std::unique_lock lock(client_properties_mutex_); + // std::unique_lock lock(client_properties_mutex_); client_properties_.clear(); } diff --git a/src/gui/render_callback.cpp b/src/gui/render_callback.cpp index 924cd6b..665568a 100644 --- a/src/gui/render_callback.cpp +++ b/src/gui/render_callback.cpp @@ -21,7 +21,7 @@ int Render::SendKeyCommand(int key_code, bool is_down) { remote_action.k.key_value = key_code; if (!controlled_remote_id_.empty()) { - std::shared_lock lock(client_properties_mutex_); + // std::shared_lock lock(client_properties_mutex_); if (client_properties_.find(controlled_remote_id_) != client_properties_.end()) { auto props = client_properties_[controlled_remote_id_]; @@ -45,7 +45,7 @@ int Render::ProcessMouseEvent(const SDL_Event& event) { float ratio_x, ratio_y = 0; RemoteAction remote_action; - std::shared_lock lock(client_properties_mutex_); + // std::shared_lock lock(client_properties_mutex_); for (auto& it : client_properties_) { auto props = it.second; if (!props->control_mouse_) { @@ -162,7 +162,7 @@ void Render::SdlCaptureAudioIn(void* userdata, Uint8* stream, int len) { } if (1) { - std::shared_lock lock(render->client_properties_mutex_); + // std::shared_lock lock(render->client_properties_mutex_); for (const auto& it : render->client_properties_) { auto props = it.second; if (props->connection_status_ == ConnectionStatus::Connected) { @@ -218,7 +218,7 @@ void Render::OnReceiveVideoBufferCb(const XVideoFrame* video_frame, } std::string remote_id(user_id, user_id_size); - std::shared_lock lock(render->client_properties_mutex_); + // std::shared_lock lock(render->client_properties_mutex_); if (render->client_properties_.find(remote_id) == render->client_properties_.end()) { return; @@ -314,7 +314,7 @@ void Render::OnReceiveDataBufferCb(const char* data, size_t size, } std::string remote_id(user_id, user_id_size); - std::shared_lock lock(render->client_properties_mutex_); + // std::shared_lock lock(render->client_properties_mutex_); if (render->client_properties_.find(remote_id) != render->client_properties_.end()) { // local @@ -386,7 +386,7 @@ void Render::OnSignalStatusCb(SignalStatus status, const char* user_id, } std::string remote_id(client_id.begin() + 2, client_id.end()); - std::shared_lock lock(render->client_properties_mutex_); + // std::shared_lock lock(render->client_properties_mutex_); if (render->client_properties_.find(remote_id) == render->client_properties_.end()) { return; @@ -416,7 +416,7 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, const char* user_id, if (!render) return; std::string remote_id(user_id, user_id_size); - std::shared_lock lock(render->client_properties_mutex_); + // std::shared_lock lock(render->client_properties_mutex_); auto it = render->client_properties_.find(remote_id); auto props = (it != render->client_properties_.end()) ? it->second : nullptr; @@ -577,7 +577,7 @@ void Render::NetStatusReport(const char* client_id, size_t client_id_size, } std::string remote_id(user_id, user_id_size); - std::shared_lock lock(render->client_properties_mutex_); + // std::shared_lock lock(render->client_properties_mutex_); if (render->client_properties_.find(remote_id) == render->client_properties_.end()) { return; diff --git a/src/gui/windows/main_window.cpp b/src/gui/windows/main_window.cpp index 2c158e5..b0cd3f0 100644 --- a/src/gui/windows/main_window.cpp +++ b/src/gui/windows/main_window.cpp @@ -32,7 +32,7 @@ int Render::MainWindow() { StatusBar(); if (show_connection_status_window_) { - std::unique_lock lock(client_properties_mutex_); + // std::unique_lock lock(client_properties_mutex_); for (auto it = client_properties_.begin(); it != client_properties_.end();) { auto& props = it->second; diff --git a/src/gui/windows/stream_window.cpp b/src/gui/windows/stream_window.cpp index 937bf6a..6f4d084 100644 --- a/src/gui/windows/stream_window.cpp +++ b/src/gui/windows/stream_window.cpp @@ -32,7 +32,7 @@ void Render::DrawConnectionStatusText( } void Render::CloseTab(decltype(client_properties_)::iterator& it) { - std::unique_lock lock(client_properties_mutex_); + // std::unique_lock lock(client_properties_mutex_); if (it != client_properties_.end()) { CleanupPeer(it->second); it = client_properties_.erase(it); @@ -82,21 +82,21 @@ int Render::StreamWindow() { ImGuiTabBarFlags_AutoSelectNewTabs)) { is_tab_bar_hovered_ = ImGui::IsWindowHovered(); - std::shared_lock lock(client_properties_mutex_); + // std::shared_lock lock(client_properties_mutex_); for (auto it = client_properties_.begin(); it != client_properties_.end();) { auto& props = it->second; if (!props->tab_opened_) { std::string remote_id_to_close = props->remote_id_; - lock.unlock(); + // lock.unlock(); { - std::unique_lock unique_lock(client_properties_mutex_); + // std::unique_lock unique_lock(client_properties_mutex_); auto close_it = client_properties_.find(remote_id_to_close); if (close_it != client_properties_.end()) { CloseTab(close_it); } } - lock.lock(); + // lock.lock(); it = client_properties_.begin(); continue; } @@ -137,9 +137,9 @@ int Render::StreamWindow() { if (!props->peer_) { std::string remote_id_to_erase = props->remote_id_; - lock.unlock(); + // lock.unlock(); { - std::unique_lock unique_lock(client_properties_mutex_); + // std::unique_lock unique_lock(client_properties_mutex_); auto erase_it = client_properties_.find(remote_id_to_erase); if (erase_it != client_properties_.end()) { erase_it = client_properties_.erase(erase_it); @@ -150,7 +150,7 @@ int Render::StreamWindow() { } } } - lock.lock(); + // lock.lock(); it = client_properties_.begin(); continue; } else { @@ -172,21 +172,21 @@ int Render::StreamWindow() { ImGui::End(); // End TabBar } else { - std::shared_lock lock(client_properties_mutex_); + // std::shared_lock lock(client_properties_mutex_); for (auto it = client_properties_.begin(); it != client_properties_.end();) { auto& props = it->second; if (!props->tab_opened_) { std::string remote_id_to_close = props->remote_id_; - lock.unlock(); + // lock.unlock(); { - std::unique_lock unique_lock(client_properties_mutex_); + // std::unique_lock unique_lock(client_properties_mutex_); auto close_it = client_properties_.find(remote_id_to_close); if (close_it != client_properties_.end()) { CloseTab(close_it); } } - lock.lock(); + // lock.lock(); it = client_properties_.begin(); continue; } @@ -218,9 +218,9 @@ int Render::StreamWindow() { fullscreen_button_pressed_ = false; SDL_SetWindowFullscreen(stream_window_, false); std::string remote_id_to_erase = props->remote_id_; - lock.unlock(); + // lock.unlock(); { - std::unique_lock unique_lock(client_properties_mutex_); + // std::unique_lock unique_lock(client_properties_mutex_); auto erase_it = client_properties_.find(remote_id_to_erase); if (erase_it != client_properties_.end()) { client_properties_.erase(erase_it); @@ -231,7 +231,7 @@ int Render::StreamWindow() { } } } - lock.lock(); + // lock.lock(); it = client_properties_.begin(); continue; } else {