mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
[fix] do not use smart pointer to manage std::thread objects
This commit is contained in:
@@ -10,8 +10,8 @@ unsigned char nv12_buffer_[NV12_BUFFER_SIZE];
|
|||||||
ScreenCapturerX11::ScreenCapturerX11() {}
|
ScreenCapturerX11::ScreenCapturerX11() {}
|
||||||
|
|
||||||
ScreenCapturerX11::~ScreenCapturerX11() {
|
ScreenCapturerX11::~ScreenCapturerX11() {
|
||||||
if (inited_ && capture_thread_->joinable()) {
|
if (inited_ && capture_thread_.joinable()) {
|
||||||
capture_thread_->join();
|
capture_thread_.join();
|
||||||
inited_ = false;
|
inited_ = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,7 @@ int ScreenCapturerX11::Destroy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ScreenCapturerX11::Start() {
|
int ScreenCapturerX11::Start() {
|
||||||
capture_thread_.reset(new std::thread([this]() {
|
capture_thread_ = std::thread([this]() {
|
||||||
while (running_) {
|
while (running_) {
|
||||||
if (av_read_frame(pFormatCtx_, packet_) >= 0) {
|
if (av_read_frame(pFormatCtx_, packet_) >= 0) {
|
||||||
if (packet_->stream_index == videoindex_) {
|
if (packet_->stream_index == videoindex_) {
|
||||||
@@ -131,7 +131,7 @@ int ScreenCapturerX11::Start() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class ScreenCapturerX11 : public ScreenCapturer {
|
|||||||
struct SwsContext *img_convert_ctx_ = nullptr;
|
struct SwsContext *img_convert_ctx_ = nullptr;
|
||||||
|
|
||||||
// thread
|
// thread
|
||||||
std::unique_ptr<std::thread> capture_thread_ = nullptr;
|
std::thread capture_thread_;
|
||||||
std::atomic_bool running_;
|
std::atomic_bool running_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ unsigned char nv12_buffer_[NV12_BUFFER_SIZE];
|
|||||||
ScreenCapturerAvf::ScreenCapturerAvf() {}
|
ScreenCapturerAvf::ScreenCapturerAvf() {}
|
||||||
|
|
||||||
ScreenCapturerAvf::~ScreenCapturerAvf() {
|
ScreenCapturerAvf::~ScreenCapturerAvf() {
|
||||||
if (inited_ && capture_thread_->joinable()) {
|
if (inited_ && capture_thread_.joinable()) {
|
||||||
capture_thread_->join();
|
capture_thread_.join();
|
||||||
inited_ = false;
|
inited_ = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ int ScreenCapturerAvf::Start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
running_ = true;
|
running_ = true;
|
||||||
capture_thread_.reset(new std::thread([this]() {
|
capture_thread_ = std::thread([this]() {
|
||||||
while (running_) {
|
while (running_) {
|
||||||
if (av_read_frame(pFormatCtx_, packet_) >= 0) {
|
if (av_read_frame(pFormatCtx_, packet_) >= 0) {
|
||||||
if (packet_->stream_index == videoindex_) {
|
if (packet_->stream_index == videoindex_) {
|
||||||
@@ -137,7 +137,7 @@ int ScreenCapturerAvf::Start() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class ScreenCapturerAvf : public ScreenCapturer {
|
|||||||
struct SwsContext *img_convert_ctx_ = nullptr;
|
struct SwsContext *img_convert_ctx_ = nullptr;
|
||||||
|
|
||||||
// thread
|
// thread
|
||||||
std::unique_ptr<std::thread> capture_thread_ = nullptr;
|
std::thread capture_thread_;
|
||||||
std::atomic_bool running_;
|
std::atomic_bool running_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ int Render::CreateConnectionPeer() {
|
|||||||
ConfigCenter::VIDEO_ENCODE_FORMAT::AV1
|
ConfigCenter::VIDEO_ENCODE_FORMAT::AV1
|
||||||
? true
|
? true
|
||||||
: false;
|
: false;
|
||||||
params_.enable_turn = true;
|
params_.enable_turn = false;
|
||||||
params_.on_receive_video_buffer = OnReceiveVideoBufferCb;
|
params_.on_receive_video_buffer = OnReceiveVideoBufferCb;
|
||||||
params_.on_receive_audio_buffer = OnReceiveAudioBufferCb;
|
params_.on_receive_audio_buffer = OnReceiveAudioBufferCb;
|
||||||
params_.on_receive_data_buffer = OnReceiveDataBufferCb;
|
params_.on_receive_data_buffer = OnReceiveDataBufferCb;
|
||||||
@@ -446,20 +446,6 @@ int Render::Run() {
|
|||||||
: true;
|
: true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_create_connection_ && rejoin_ &&
|
|
||||||
"Failed" == connection_status_str_) {
|
|
||||||
LeaveConnection(peer_, client_id_);
|
|
||||||
DestroyPeer(&peer_);
|
|
||||||
peer_ = CreatePeer(¶ms_);
|
|
||||||
if (peer_) {
|
|
||||||
LOG_INFO("[{}] Create peer instance successful", client_id_);
|
|
||||||
Init(peer_, client_id_);
|
|
||||||
LOG_INFO("[{}] Peer init finish", client_id_);
|
|
||||||
} else {
|
|
||||||
LOG_INFO("Create peer instance failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!inited_ ||
|
if (!inited_ ||
|
||||||
localization_language_index_last_ != localization_language_index_) {
|
localization_language_index_last_ != localization_language_index_) {
|
||||||
connect_button_label_ =
|
connect_button_label_ =
|
||||||
|
|||||||
@@ -198,9 +198,6 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, void *user_data) {
|
|||||||
} else if (ConnectionStatus::Failed == status) {
|
} else if (ConnectionStatus::Failed == status) {
|
||||||
render->connection_status_str_ = "Failed";
|
render->connection_status_str_ = "Failed";
|
||||||
render->password_validating_time_ = 0;
|
render->password_validating_time_ = 0;
|
||||||
render->is_create_connection_ = false;
|
|
||||||
render->params_.enable_turn = true;
|
|
||||||
render->rejoin_ = true;
|
|
||||||
} else if (ConnectionStatus::Closed == status) {
|
} else if (ConnectionStatus::Closed == status) {
|
||||||
render->connection_status_str_ = "Closed";
|
render->connection_status_str_ = "Closed";
|
||||||
render->password_validating_time_ = 0;
|
render->password_validating_time_ = 0;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class SpeakerCapturerLinux : public SpeakerCapturer {
|
|||||||
private:
|
private:
|
||||||
bool inited_ = false;
|
bool inited_ = false;
|
||||||
// thread
|
// thread
|
||||||
std::unique_ptr<std::thread> capture_thread_ = nullptr;
|
std::thread capture_thread_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -32,7 +32,7 @@ class SpeakerCapturerMacosx : public SpeakerCapturer {
|
|||||||
private:
|
private:
|
||||||
bool inited_ = false;
|
bool inited_ = false;
|
||||||
// thread
|
// thread
|
||||||
std::unique_ptr<std::thread> capture_thread_ = nullptr;
|
std::thread capture_thread_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
2
thirdparty/projectx
vendored
2
thirdparty/projectx
vendored
Submodule thirdparty/projectx updated: 0b11646619...98bd477af5
Reference in New Issue
Block a user