[fix] harden macOS screen capture lifecycle against late callbacks

This commit is contained in:
dijunkun
2026-05-28 04:21:59 +08:00
parent 895e297771
commit 53edf3d57e
2 changed files with 137 additions and 55 deletions
@@ -16,7 +16,11 @@ int ScreenCapturerSck::Init(const int fps, cb_desktop_data cb) {
}
screen_capturer_sck_impl_ = CreateScreenCapturerSck();
screen_capturer_sck_impl_->Init(fps, on_data_);
const int ret = screen_capturer_sck_impl_->Init(fps, on_data_);
if (ret != 0) {
screen_capturer_sck_impl_.reset();
return ret;
}
return 0;
}
@@ -29,8 +33,11 @@ int ScreenCapturerSck::Destroy() {
}
int ScreenCapturerSck::Start(bool show_cursor) {
screen_capturer_sck_impl_->Start(show_cursor);
return 0;
if (!screen_capturer_sck_impl_) {
return -1;
}
return screen_capturer_sck_impl_->Start(show_cursor);
}
int ScreenCapturerSck::Stop() {
@@ -80,4 +87,4 @@ std::vector<DisplayInfo> ScreenCapturerSck::GetDisplayInfoList() {
void ScreenCapturerSck::OnFrame() {}
void ScreenCapturerSck::CleanUp() {}
} // namespace crossdesk
} // namespace crossdesk