Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ExecuteOnBrowser wrapper on destroy #181

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
39 changes: 18 additions & 21 deletions obs-browser-source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,27 +185,24 @@ bool BrowserSource::CreateBrowser()
});
}

void BrowserSource::DestroyBrowser(bool async)
void BrowserSource::DestroyBrowser()
{
ExecuteOnBrowser(
[](CefRefPtr<CefBrowser> cefBrowser) {
CefRefPtr<CefClient> client =
cefBrowser->GetHost()->GetClient();
BrowserClient *bc =
reinterpret_cast<BrowserClient *>(client.get());
if (bc) {
bc->bs = nullptr;
}
if (!cefBrowser)
return;

/*
* This stops rendering
* http://magpcss.org/ceforum/viewtopic.php?f=6&t=12079
* https://bitbucket.org/chromiumembedded/cef/issues/1363/washidden-api-got-broken-on-branch-2062)
*/
cefBrowser->GetHost()->WasHidden(true);
cefBrowser->GetHost()->CloseBrowser(true);
},
async);
CefRefPtr<CefClient> client = cefBrowser->GetHost()->GetClient();
BrowserClient *bc = reinterpret_cast<BrowserClient *>(client.get());
if (bc) {
bc->bs = nullptr;
}

/*
* This stops rendering
* http://magpcss.org/ceforum/viewtopic.php?f=6&t=12079
* https://bitbucket.org/chromiumembedded/cef/issues/1363/washidden-api-got-broken-on-branch-2062)
*/
cefBrowser->GetHost()->WasHidden(true);
cefBrowser->GetHost()->CloseBrowser(true);

cefBrowser = nullptr;
}
Expand Down Expand Up @@ -330,7 +327,7 @@ void BrowserSource::SetShowing(bool showing)
if (showing) {
Update();
} else {
DestroyBrowser(true);
DestroyBrowser();
}
} else {
#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
Expand Down Expand Up @@ -453,7 +450,7 @@ void BrowserSource::Update(obs_data_t *settings)
obs_source_set_audio_active(source, reroute_audio);
}

DestroyBrowser(true);
DestroyBrowser();
DestroyTextures();
ClearAudioStreams();
if (!shutdown_on_invisible || obs_source_showing(source))
Expand Down
2 changes: 1 addition & 1 deletion obs-browser-source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct BrowserSource {
/* ---------------------------- */

bool CreateBrowser();
void DestroyBrowser(bool async = false);
void DestroyBrowser();
void ClearAudioStreams();
void ExecuteOnBrowser(BrowserFunc func, bool async = false);

Expand Down