diff --git a/Plugins/uWindowCapture/uWindowCapture/Window.cpp b/Plugins/uWindowCapture/uWindowCapture/Window.cpp index e731480..173cf64 100644 --- a/Plugins/uWindowCapture/uWindowCapture/Window.cpp +++ b/Plugins/uWindowCapture/uWindowCapture/Window.cpp @@ -365,14 +365,16 @@ void Window::UpdateTitle() { if (const auto wgc = windowTexture_->GetWindowsGraphicsCapture()) { - data2_.title = wgc->GetDisplayName(); + if (wgc->IsStarted()) + { + data2_.title = wgc->GetDisplayName(); + return; + } } } - else - { - constexpr UINT timeout = 100 /* milliseconds */; - GetWindowTitle(data1_.hWnd, data2_.title, timeout); - } + + constexpr UINT timeout = 100 /* milliseconds */; + GetWindowTitle(data1_.hWnd, data2_.title, timeout); } else { diff --git a/Plugins/uWindowCapture/uWindowCapture/WindowTexture.cpp b/Plugins/uWindowCapture/uWindowCapture/WindowTexture.cpp index d740708..986f078 100644 --- a/Plugins/uWindowCapture/uWindowCapture/WindowTexture.cpp +++ b/Plugins/uWindowCapture/uWindowCapture/WindowTexture.cpp @@ -702,5 +702,5 @@ bool WindowTexture::GetPixels(BYTE* output, int x, int y, int width, int height) bool WindowTexture::IsWindowsGraphicsCaptureAvailable() const { auto wgc = windowsGraphicsCapture_.lock(); - return wgc && wgc->IsAvailable(); + return wgc != nullptr; } diff --git a/Plugins/uWindowCapture/uWindowCapture/WindowsGraphicsCapture.cpp b/Plugins/uWindowCapture/uWindowCapture/WindowsGraphicsCapture.cpp index 63f302a..d119779 100644 --- a/Plugins/uWindowCapture/uWindowCapture/WindowsGraphicsCapture.cpp +++ b/Plugins/uWindowCapture/uWindowCapture/WindowsGraphicsCapture.cpp @@ -117,7 +117,6 @@ WindowsGraphicsCapture::WindowsGraphicsCapture(HWND hWnd) : hWnd_(hWnd) , hMonitor_(NULL) { - CreateItem(); } @@ -125,7 +124,6 @@ WindowsGraphicsCapture::WindowsGraphicsCapture(HMONITOR hMonitor) : hMonitor_(hMonitor) , hWnd_(NULL) { - CreateItem(); } @@ -235,10 +233,13 @@ void WindowsGraphicsCapture::Start() if (isStarted_) return; - if (CreatePoolAndSession()) + if (CreateItem()) { - isStarted_ = true; - restartTimer_ = 0.f; + if (CreatePoolAndSession()) + { + isStarted_ = true; + restartTimer_ = 0.f; + } } } @@ -251,6 +252,7 @@ void WindowsGraphicsCapture::Stop() isStarted_ = false; DestroyPoolAndSession(); + item_ = nullptr; } @@ -278,14 +280,6 @@ void WindowsGraphicsCapture::Restart() } -bool WindowsGraphicsCapture::IsAvailable() const -{ - std::scoped_lock lock(itemMutex_); - - return item_ != nullptr; -} - - void WindowsGraphicsCapture::Update(float dt) { stopTimer_ = stopTimer_ + dt; @@ -442,7 +436,6 @@ IDirect3DDevice & WindowsGraphicsCaptureManager::GetDevice() std::shared_ptr WindowsGraphicsCaptureManager::Create(HWND hWnd) { auto instance = std::make_shared(hWnd); - if (!instance->IsAvailable()) return nullptr; std::scoped_lock lock(allInstancesMutex_); allInstances_.push_back(instance); @@ -454,7 +447,6 @@ std::shared_ptr WindowsGraphicsCaptureManager::Create(HW std::shared_ptr WindowsGraphicsCaptureManager::Create(HMONITOR hMonitor) { auto instance = std::make_shared(hMonitor); - if (!instance->IsAvailable()) return nullptr; std::scoped_lock lock(allInstancesMutex_); allInstances_.push_back(instance); diff --git a/Plugins/uWindowCapture/uWindowCapture/WindowsGraphicsCapture.h b/Plugins/uWindowCapture/uWindowCapture/WindowsGraphicsCapture.h index b62785c..9f51338 100644 --- a/Plugins/uWindowCapture/uWindowCapture/WindowsGraphicsCapture.h +++ b/Plugins/uWindowCapture/uWindowCapture/WindowsGraphicsCapture.h @@ -36,7 +36,6 @@ friend class WindowsGraphicsCaptureManager; int GetHeight() const { return size_.Height; } int GetWidth() const { return size_.Width; } void RequestStart(); - bool IsAvailable() const; bool IsStarted() const { return isStarted_; } void EnableCursorCapture(bool enabled); Result TryGetLatestResult();