mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35: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() {
|
||||
if (inited_ && capture_thread_->joinable()) {
|
||||
capture_thread_->join();
|
||||
if (inited_ && capture_thread_.joinable()) {
|
||||
capture_thread_.join();
|
||||
inited_ = false;
|
||||
}
|
||||
}
|
||||
@@ -107,7 +107,7 @@ int ScreenCapturerX11::Destroy() {
|
||||
}
|
||||
|
||||
int ScreenCapturerX11::Start() {
|
||||
capture_thread_.reset(new std::thread([this]() {
|
||||
capture_thread_ = std::thread([this]() {
|
||||
while (running_) {
|
||||
if (av_read_frame(pFormatCtx_, packet_) >= 0) {
|
||||
if (packet_->stream_index == videoindex_) {
|
||||
@@ -131,7 +131,7 @@ int ScreenCapturerX11::Start() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ class ScreenCapturerX11 : public ScreenCapturer {
|
||||
struct SwsContext *img_convert_ctx_ = nullptr;
|
||||
|
||||
// thread
|
||||
std::unique_ptr<std::thread> capture_thread_ = nullptr;
|
||||
std::thread capture_thread_;
|
||||
std::atomic_bool running_;
|
||||
};
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ unsigned char nv12_buffer_[NV12_BUFFER_SIZE];
|
||||
ScreenCapturerAvf::ScreenCapturerAvf() {}
|
||||
|
||||
ScreenCapturerAvf::~ScreenCapturerAvf() {
|
||||
if (inited_ && capture_thread_->joinable()) {
|
||||
capture_thread_->join();
|
||||
if (inited_ && capture_thread_.joinable()) {
|
||||
capture_thread_.join();
|
||||
inited_ = false;
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ int ScreenCapturerAvf::Start() {
|
||||
}
|
||||
|
||||
running_ = true;
|
||||
capture_thread_.reset(new std::thread([this]() {
|
||||
capture_thread_ = std::thread([this]() {
|
||||
while (running_) {
|
||||
if (av_read_frame(pFormatCtx_, packet_) >= 0) {
|
||||
if (packet_->stream_index == videoindex_) {
|
||||
@@ -137,7 +137,7 @@ int ScreenCapturerAvf::Start() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ class ScreenCapturerAvf : public ScreenCapturer {
|
||||
struct SwsContext *img_convert_ctx_ = nullptr;
|
||||
|
||||
// thread
|
||||
std::unique_ptr<std::thread> capture_thread_ = nullptr;
|
||||
std::thread capture_thread_;
|
||||
std::atomic_bool running_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user