diff --git a/src/screen_capturer/macosx/screen_capturer_sck.cpp b/src/screen_capturer/macosx/screen_capturer_sck.cpp index 4133428..e79bd34 100644 --- a/src/screen_capturer/macosx/screen_capturer_sck.cpp +++ b/src/screen_capturer/macosx/screen_capturer_sck.cpp @@ -29,9 +29,19 @@ int ScreenCapturerSck::Start() { int ScreenCapturerSck::Stop() { return 0; } -int ScreenCapturerSck::Pause(int monitor_index) { return 0; } +int ScreenCapturerSck::Pause(int monitor_index) { + if (screen_capturer_sck_impl_) { + return screen_capturer_sck_impl_->Pause(monitor_index); + } + return 0; +} -int ScreenCapturerSck::Resume(int monitor_index) { return 0; } +int ScreenCapturerSck::Resume(int monitor_index) { + if (screen_capturer_sck_impl_) { + return screen_capturer_sck_impl_->Resume(monitor_index); + } + return 0; +} int ScreenCapturerSck::SwitchTo(int monitor_index) { if (screen_capturer_sck_impl_) { diff --git a/src/screen_capturer/macosx/screen_capturer_sck_impl.mm b/src/screen_capturer/macosx/screen_capturer_sck_impl.mm index c770a2d..2b125cd 100644 --- a/src/screen_capturer/macosx/screen_capturer_sck_impl.mm +++ b/src/screen_capturer/macosx/screen_capturer_sck_impl.mm @@ -114,6 +114,11 @@ ScreenCapturerSckImpl::~ScreenCapturerSckImpl() { display_id_map_.clear(); display_id_map_reverse_.clear(); + if (nv12_frame_) { + delete[] nv12_frame_; + nv12_frame_ = nullptr; + } + [stream_ stopCaptureWithCompletionHandler:nil]; [helper_ releaseCapturer]; } @@ -281,15 +286,10 @@ void ScreenCapturerSckImpl::OnNewIOSurface(IOSurfaceRef io_surface, CFDictionary uint32_t aseed; IOSurfaceLock(io_surface, kIOSurfaceLockReadOnly, &aseed); - if (!nv12_frame_) { - nv12_frame_ = new unsigned char[width * height * 3 / 2]; - width_ = width; - height_ = height; - } - - if (nv12_frame_ && width_ * height_ < width * height) { + size_t required_size = width * height * 3 / 2; + if (!nv12_frame_ || (width_ * height_ * 3 / 2 < required_size)) { delete[] nv12_frame_; - nv12_frame_ = new unsigned char[width * height * 3 / 2]; + nv12_frame_ = new unsigned char[required_size]; width_ = width; height_ = height; } diff --git a/thirdparty/projectx b/thirdparty/projectx index 3a691e2..78804fc 160000 --- a/thirdparty/projectx +++ b/thirdparty/projectx @@ -1 +1 @@ -Subproject commit 3a691e266bb312ce188c4aa2bbe678834e274b00 +Subproject commit 78804fce8143907f0aa873c4b4481d6bbf229ee1