Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6910333

Browse files
authored
create browser source on main thread (#1561)
* create 1st browser_source on main thread to satisfy requirementCEFInitialize() must be called on main thread (obs-browser plugin -> CEF)* bump LibOBSVersion
1 parente441565 commit6910333

File tree

6 files changed

+36
-3
lines changed

6 files changed

+36
-3
lines changed

‎.github/workflows/main.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ env:
2222
SLGenerator:Visual Studio 17 2022
2323
SLDistributeDirectory:distribute
2424
SLFullDistributePath:"streamlabs-build.app/distribute"# The .app extension is required to run macOS tests correctly.
25-
LibOBSVersion:30.2.4sl35
25+
LibOBSVersion:30.2.4sl36
2626
PACKAGE_NAME:osn
2727

2828
jobs:

‎obs-studio-server/source/osn-input.cpp‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,22 @@ void osn::Input::Create(void *data, const int64_t id, const std::vector<ipc::val
111111
break;
112112
}
113113

114+
#if defined(__APPLE__)
115+
staticbool hasInitializedBrowserSources =false;
116+
obs_source_t *source =nullptr;
117+
118+
if (!hasInitializedBrowserSources && sourceId =="browser_source") {
119+
// CEFInitialize must be invoked on main thread (first time a browser source is created)
120+
hasInitializedBrowserSources =true;
121+
122+
g_util_osx->runOnMainThreadSync(
123+
[&source, &sourceId, &name, &settings, &hotkeys]() { source =obs_source_create(sourceId.c_str(), name.c_str(), settings, hotkeys); });
124+
}else {
125+
source =obs_source_create(sourceId.c_str(), name.c_str(), settings, hotkeys);
126+
}
127+
#else
114128
obs_source_t *source =obs_source_create(sourceId.c_str(), name.c_str(), settings, hotkeys);
129+
#endif
115130
obs_data_release(hotkeys);
116131
obs_data_release(settings);
117132

@@ -660,4 +675,4 @@ void osn::Input::GetMediaState(void *data, const int64_t id, const std::vector<i
660675
rval.push_back(ipc::value((uint64_t)ErrorCode::Ok));
661676
rval.push_back(ipc::value(obs_source_media_get_state(input)));
662677
AUTO_DEBUG;
663-
}
678+
}

‎obs-studio-server/source/util-osx-impl.mm‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,11 @@ @implementation UtilImplObj
170170
NSString *workindDirPath = [[NSProcessInfoprocessInfo]environment][@"PWD"];
171171
returnstd::string([workindDirPathUTF8String]);
172172
}
173+
174+
voidUtilObjCInt::runOnMainThreadSync(std::function<void()> func)
175+
{
176+
dispatch_sync(dispatch_get_main_queue(), ^{
177+
func();
178+
});
179+
}
173180
@end

‎obs-studio-server/source/util-osx-int.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class UtilObjCInt {
3939
std::stringgetWorkingDirectory(void);
4040
voidwait_terminate(void);
4141

42+
// Runs a function on the main thread and waits for the function to finish before proceeding.
43+
voidrunOnMainThreadSync(std::function<void()> func);
44+
4245
private:
4346
void *self;
4447
std::atomic<bool> appRunning;

‎obs-studio-server/source/util-osx.cpp‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,9 @@ std::string UtilInt::getUserDataPath(void)
7272
std::stringUtilInt::getWorkingDirectory(void)
7373
{
7474
return _impl->getWorkingDirectory();
75-
}
75+
}
76+
77+
voidUtilInt::runOnMainThreadSync(std::function<void()> func)
78+
{
79+
_impl->runOnMainThreadSync(func);
80+
}

‎obs-studio-server/source/util-osx.hpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#ifndef __UTIL_CLASS_H__
2020
#define__UTIL_CLASS_H__
2121

22+
#include<functional>
2223
#include<string>
2324
#include<vector>
2425

@@ -38,6 +39,8 @@ class UtilInt {
3839
std::vector<std::pair<uint32_t,uint32_t>>getAvailableScreenResolutions(void);
3940
std::stringgetUserDataPath(void);
4041
std::stringgetWorkingDirectory(void);
42+
// Runs a function on the main thread and waits for the function to finish before proceeding.
43+
voidrunOnMainThreadSync(std::function<void()> func);
4144

4245
private:
4346
UtilObjCInt *_impl;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp