Skip to content

Commit bd8da20

Browse files
authored
Merge branch 'obs_merge_31.1.2' into update-libobs-v31.1.2sl1
2 parents f2bded7 + 75712f5 commit bd8da20

File tree

14 files changed

+206
-42
lines changed

14 files changed

+206
-42
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -254,22 +254,6 @@ jobs:
254254
steps:
255255
- name: 'Add msbuild to PATH'
256256
uses: microsoft/setup-msbuild@v1
257-
- name: Install older build components
258-
run: |
259-
# For versions update see here: https://learn.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022
260-
Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
261-
$InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
262-
$componentsToInstall= @(
263-
"Microsoft.VisualStudio.Component.VC.v141.x86.x64"
264-
"Microsoft.VisualStudio.Component.VC.14.39.17.9.x86.x64"
265-
"Microsoft.VisualStudio.Component.VC.14.39.17.9.ATL"
266-
)
267-
[string]$workloadArgs = $componentsToInstall | ForEach-Object {" --add " + $_}
268-
$Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
269-
# should be run twice
270-
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
271-
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
272-
shell: powershell
273257
- name: 'Checkout'
274258
uses: actions/checkout@v3
275259
with:

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,14 @@ if(NOT libcurl_POPULATED)
136136
set(USE_LIBIDN2 OFF CACHE BOOL "" FORCE)
137137
set(USE_LIBPSL OFF CACHE BOOL "" FORCE)
138138
set(CURL_ZLIB OFF CACHE BOOL "" FORCE)
139+
140+
if(APPLE)
141+
# Enable Secure Transport on Apple platforms
142+
set(CURL_USE_SECTRANSP ON CACHE BOOL "" FORCE)
143+
set(CMAKE_USE_SCHANNEL OFF CACHE BOOL "" FORCE)
144+
else()
139145
set(CMAKE_USE_SCHANNEL ON CACHE BOOL "" FORCE)
146+
endif()
140147

141148
FetchContent_Populate(libcurl)
142149
add_subdirectory(${libcurl_SOURCE_DIR} ${libcurl_BINARY_DIR} EXCLUDE_FROM_ALL)

js/module.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,6 @@ export interface IVolmeterFactory {
625625
create(type: EFaderType): IVolmeter;
626626
}
627627
export interface IVolmeter {
628-
updateInterval: number;
629628
destroy(): void;
630629
attach(source: IInput): void;
631630
detach(): void;

js/module.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,11 +1383,6 @@ export interface IVolmeterFactory {
13831383
* Object representing a volmeter control corresponding to a source.
13841384
*/
13851385
export interface IVolmeter {
1386-
/**
1387-
* The interval at which the volmeter will call the callback.
1388-
*/
1389-
updateInterval: number;
1390-
13911386
/**
13921387
* Destroy the volmeter object object
13931388
*/

obs-studio-client/source/volmeter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ Napi::Value osn::Volmeter::Create(const Napi::CallbackInfo &info)
7777
if (!ValidateResponse(info, response))
7878
return info.Env().Undefined();
7979

80-
auto instance = osn::Volmeter::constructor.New({Napi::Number::New(info.Env(), static_cast<double>(response[1].value_union.ui64)),
81-
Napi::Number::New(info.Env(), static_cast<double>(response[2].value_union.ui32))});
80+
auto instance = osn::Volmeter::constructor.New({Napi::Number::New(info.Env(), static_cast<double>(response[1].value_union.ui64))});
8281

8382
globalCallback::add_volmeter(response[1].value_union.ui64);
8483

obs-studio-server/source/nodeobs_api.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,18 @@ void OBS_API::OBS_API_initAPI(void *data, const int64_t id, const std::vector<ip
972972
SetPrivilegeForGPUPriority();
973973
#endif
974974

975+
// This code initializes the graphics susbsystem and hardware acceleration features
976+
obs_video_info *ovi = obs_create_video_info();
977+
const auto resetResult = obs_reset_video(ovi);
978+
if (resetResult != OBS_VIDEO_SUCCESS) {
979+
rval.push_back(ipc::value((uint64_t)ErrorCode::CriticalError));
980+
rval.push_back(ipc::value(resetResult));
981+
}
982+
obs_remove_video_info(ovi);
983+
if (resetResult != OBS_VIDEO_SUCCESS) {
984+
return;
985+
}
986+
975987
osn::Source::initialize_global_signals();
976988

977989
cpuUsageInfo = os_cpu_usage_info_start();
@@ -1032,17 +1044,18 @@ void OBS_API::OBS_API_initAPI(void *data, const int64_t id, const std::vector<ip
10321044

10331045
util::CrashManager::setAppState("idle");
10341046

1035-
blog(LOG_INFO, "---------------------------------");
1036-
obs_log_loaded_modules();
1037-
blog(LOG_INFO, "---------------------------------");
1038-
logEncoders();
1039-
blog(LOG_INFO, "---------------------------------");
1040-
10411047
// We are returning a video result here because the frontend needs to know if we sucessfully
10421048
// initialized the Dx11 API
10431049
rval.push_back(ipc::value((uint64_t)ErrorCode::Ok));
10441050
rval.push_back(ipc::value(OBS_VIDEO_SUCCESS));
10451051

1052+
#if defined(__APPLE__)
1053+
// Block until CEF has been initialized by the main thread.
1054+
g_util_osx->nextState();
1055+
while (!g_util_osx->hasInitCef()) {
1056+
std::this_thread::sleep_for(std::chrono::milliseconds(50));
1057+
}
1058+
#endif
10461059
AUTO_DEBUG;
10471060
}
10481061

obs-studio-server/source/osn-multitrack-video-configuration.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ Config DownloadGoLiveConfig(std::string url, const PostData &post_data)
174174
5); // timeout in seconds
175175

176176
if (!encodeConfigDownloadedOk) {
177+
blog(LOG_ERROR, "Go live error: %s", libraryError.c_str());
177178
throw std::runtime_error("Failed to start stream. Config request failed");
178179
}
179180

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,68 @@
11
#include "osn-multitrack-video-system-info.hpp"
2+
#include "shared.hpp"
3+
#include "util/platform.h"
4+
5+
#import <Foundation/Foundation.h>
6+
#import <Foundation/NSProcessInfo.h>
27

38
namespace osn {
49

5-
// This feature is currently unused on Mac
6-
void system_info(Capabilities &capabilities) {}
10+
void fillSystemInfo(System &sysinfo)
11+
{
12+
NSProcessInfo *procInfo = [NSProcessInfo processInfo];
13+
NSOperatingSystemVersion versionObj = [procInfo operatingSystemVersion];
14+
15+
sysinfo.name = "macOS";
16+
sysinfo.bits = 64; // 32-bit macOS is long deprecated.
17+
sysinfo.version = [[procInfo operatingSystemVersionString] UTF8String];
18+
19+
switch (versionObj.majorVersion) {
20+
case 11:
21+
sysinfo.release = "Big Sur";
22+
break;
23+
case 12:
24+
sysinfo.release = "Monterey";
25+
break;
26+
case 13:
27+
sysinfo.release = "Ventura";
28+
break;
29+
case 14:
30+
sysinfo.release = "Sonoma";
31+
break;
32+
case 15:
33+
sysinfo.release = "Sequoia";
34+
break;
35+
case 26:
36+
sysinfo.release = "Tahoe";
37+
break;
38+
default:
39+
sysinfo.release = "unknown";
40+
}
41+
42+
sysinfo.arm = true;
43+
sysinfo.armEmulation = false;
44+
}
45+
46+
void system_info(Capabilities &capabilities)
47+
{
48+
capabilities.cpu.name = g_util_osx->getCpuName();
49+
// Getting the frequency is not supported on Apple Silicon.
50+
capabilities.cpu.physical_cores = os_get_physical_cores();
51+
capabilities.cpu.logical_cores = os_get_logical_cores();
52+
53+
capabilities.memory.total = os_get_sys_total_size();
54+
capabilities.memory.free = os_get_sys_free_size();
55+
56+
// Apple Silicon- there's only going to be gpu
57+
Gpu gpu;
58+
gpu.model = capabilities.cpu.name.value_or("Unknown");
59+
gpu.vendor_id = 0x106b; // Always Apple
60+
gpu.device_id = 0; // Always 0 for Apple Silicon
61+
62+
std::vector<Gpu> gpus;
63+
gpus.push_back(std::move(gpu));
64+
capabilities.gpu = gpus;
65+
fillSystemInfo(capabilities.system);
66+
}
767

868
} // namespace osn

obs-studio-server/source/osn-volmeter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ void osn::Volmeter::Create(void *data, const int64_t id, const std::vector<ipc::
8484

8585
rval.push_back(ipc::value((uint64_t)ErrorCode::Ok));
8686
rval.push_back(ipc::value(meter->id));
87-
rval.push_back(ipc::value(obs_volmeter_get_update_interval(meter->self)));
8887
AUTO_DEBUG;
8988
}
9089

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

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
******************************************************************************/
1818

1919
#include "util-osx-impl.h"
20+
#include "obs.h"
2021
#include <iostream>
2122
#include <unistd.h>
2223
#include <sys/types.h>
@@ -43,13 +44,13 @@
4344
return;
4445

4546
while (true) {
46-
if (!appRunning) {
47+
if (state == UtilObjCInt::EState::Stop) {
4748
break;
4849
}
4950
int ret = ::read(file_descriptor, buffer.data(), count);
5051
if (ret > 0) {
5152
bool appCrashed = *reinterpret_cast<bool *>(buffer.data());
52-
if (appCrashed && appRunning)
53+
if (appCrashed && state != UtilObjCInt::EState::Stop)
5354
this->stopApplication();
5455
break;
5556
}
@@ -86,17 +87,33 @@ @implementation UtilImplObj
8687

8788
void UtilObjCInt::runApplication(void)
8889
{
89-
appRunning = true;
90-
worker = new std::thread(&UtilObjCInt::wait_terminate, this);
90+
// Wait for OBS_API_initAPI to be invoked
91+
while (!hasInitApi() && isRunning()) {
92+
std::this_thread::sleep_for(std::chrono::milliseconds(50));
93+
}
94+
if (isRunning()) {
95+
// Create a dummy source to init obs-browser plugin. Must be init from main thread before [NSApplication run]
96+
obs_source_t *source = obs_source_create("browser_source", "dummy", NULL, NULL);
97+
obs_source_release(source);
98+
nextState();
9199

92-
@autoreleasepool {
93-
NSApplication *app = [NSApplication sharedApplication];
94-
[app run];
100+
worker = new std::thread(&UtilObjCInt::wait_terminate, this);
101+
102+
@autoreleasepool {
103+
NSApplication *app = [NSApplication sharedApplication];
104+
[app run];
105+
}
95106
}
96107
}
97108

98109
void UtilObjCInt::stopApplication(void)
99110
{
111+
if (!hasInitCef()) {
112+
state = UtilObjCInt::EState::Stop;
113+
return;
114+
} else {
115+
state = UtilObjCInt::EState::Stop;
116+
}
100117
dispatch_async(dispatch_get_main_queue(), ^{
101118
[[NSApplication sharedApplication] stop:nil];
102119
NSEvent *event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined
@@ -110,12 +127,17 @@ @implementation UtilImplObj
110127
data2:0];
111128
[NSApp postEvent:event atStart:TRUE];
112129

113-
appRunning = false;
130+
state = UtilObjCInt::EState::Stop;
114131
if (worker->joinable())
115132
worker->join();
116133
});
117134
}
118135

136+
bool UtilObjCInt::isRunning(void)
137+
{
138+
return state != UtilObjCInt::EState::Stop;
139+
}
140+
119141
unsigned long long UtilObjCInt::getTotalPhysicalMemory(void)
120142
{
121143
return [NSProcessInfo processInfo].physicalMemory;
@@ -191,4 +213,37 @@ @implementation UtilImplObj
191213
return 0;
192214
return physical_cores;
193215
}
216+
217+
std::string UtilObjCInt::getCpuName(void)
218+
{
219+
char buffer[256];
220+
size_t size = sizeof(buffer);
221+
std::string name;
222+
223+
if (sysctlbyname("machdep.cpu.brand_string", buffer, &size, nullptr, 0) == 0) {
224+
name = std::string(buffer);
225+
} else if (sysctlbyname("hw.model", buffer, &size, nullptr, 0) == 0) {
226+
name = std::string(buffer);
227+
}
228+
229+
return name;
230+
}
231+
232+
void UtilObjCInt::nextState(void)
233+
{
234+
if (state + 1 < UtilObjCInt::EState::Max) {
235+
state = state + 1;
236+
}
237+
}
238+
239+
bool UtilObjCInt::hasInitApi(void)
240+
{
241+
return state == UtilObjCInt::EState::InitializedApi;
242+
}
243+
244+
bool UtilObjCInt::hasInitCef(void)
245+
{
246+
return state == UtilObjCInt::EState::InitializedCEF;
247+
}
248+
194249
@end

0 commit comments

Comments
 (0)