Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Plugins/uWindowCapture/uWindowCapture/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion Plugins/uWindowCapture/uWindowCapture/WindowTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
22 changes: 7 additions & 15 deletions Plugins/uWindowCapture/uWindowCapture/WindowsGraphicsCapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,13 @@ WindowsGraphicsCapture::WindowsGraphicsCapture(HWND hWnd)
: hWnd_(hWnd)
, hMonitor_(NULL)
{
CreateItem();
}


WindowsGraphicsCapture::WindowsGraphicsCapture(HMONITOR hMonitor)
: hMonitor_(hMonitor)
, hWnd_(NULL)
{
CreateItem();
}


Expand Down Expand Up @@ -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;
}
}
}

Expand All @@ -251,6 +252,7 @@ void WindowsGraphicsCapture::Stop()
isStarted_ = false;

DestroyPoolAndSession();
item_ = nullptr;
}


Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -442,7 +436,6 @@ IDirect3DDevice & WindowsGraphicsCaptureManager::GetDevice()
std::shared_ptr<WindowsGraphicsCapture> WindowsGraphicsCaptureManager::Create(HWND hWnd)
{
auto instance = std::make_shared<WindowsGraphicsCapture>(hWnd);
if (!instance->IsAvailable()) return nullptr;

std::scoped_lock lock(allInstancesMutex_);
allInstances_.push_back(instance);
Expand All @@ -454,7 +447,6 @@ std::shared_ptr<WindowsGraphicsCapture> WindowsGraphicsCaptureManager::Create(HW
std::shared_ptr<WindowsGraphicsCapture> WindowsGraphicsCaptureManager::Create(HMONITOR hMonitor)
{
auto instance = std::make_shared<WindowsGraphicsCapture>(hMonitor);
if (!instance->IsAvailable()) return nullptr;

std::scoped_lock lock(allInstancesMutex_);
allInstances_.push_back(instance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down