0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00
Commit Graph

382 Commits

Author SHA1 Message Date
Richard Stanway
e7aa332d38 libobs: Disable function attributes for SWIG 2021-12-09 03:36:40 +01:00
Richard Stanway
b37acbcbc1 libobs: Add OBS_NORETURN and use it for crash handler
Fixes some analyzers flagging code after a crashing path makes it
impossible to reach.
2021-12-09 02:42:37 +01:00
Tommy Vercetti
19fab46ef7 simde: Update README.libobs 2021-10-24 02:26:17 -07:00
Tommy Vercetti
24a6766543 simde: Don't format simde 2021-10-24 02:26:17 -07:00
Ryan Foster
5f68991911 clang-format: Commit file changes for clang-format 12 2021-10-13 20:00:04 +11:00
jpark37
e69f051736 libobs/util: Improve os_sleepto_ns on Windows
Avoid nanosecond abstraction to reduce math operations.

Replace Sleep(0) with YieldProcessor(). We want the thread to remain
scheduled, the current CPU core to do less work, and the hyperthread
sibling to perform better.

Hacky profiling showed maybe 10-25 µs skid reduction per function call.
I think power/performance gains would be hard to measure, so I haven't
tried, but it would be shocking if they got worse.
2021-10-10 19:13:19 -07:00
jpark37
4ca8cdfc0a libobs/util: Simplify emmintrin.h wrapper macro
Also add WIN32_LEAN_AND_MEAN for external Windows.h include.
2021-10-10 19:12:45 -07:00
Norihiro Kamae
93ee7c4775 libobs/util: Add type test in darray macros for GCC
Previously darray macros did not test the types of arguments so that
developers cannot notice even if a wrong type of a variable is passed.
This commit add a type test that relys on GCC's extension. Since OBS
Studio is built with GCC for Ubuntu, testing only under GCC is
sufficient to catch future bugs.
2021-10-01 13:00:00 +09:00
Norihiro Kamae
ef5e04a621 libobs/util: Add a cast for da_push_back_array argument 2021-10-01 12:59:35 +09:00
jpark37
0c0ff1195f libobs: Simplify util_mul_div64 for x64 on Windows
Use intrinsics to perform 128-bit math directly.
2021-09-29 02:22:01 -07:00
Georges Basile Stavracas Neto
62a2513369 libobs: Make portal inhibitor asynchronous
Currently, libobs contains two inhibitors: the portal-based one, and the
regular one based on each desktop environment's session manager. The portal
inhibitor takes precedence over the session manager one, when available.

Like the session manager inhibitor, the portal inhibitor performs all D-Bus
calls synchronously in the calling thread, which can lead to stalls. This is
not a good practice.

Make the portal inhibitor asynchronous, by using g_dbus_connection_call()
instead of g_dbus_connection_call_sync(). If an uninhibit call is made
before the previous inhibit call finishes, cancel the inhibit call instead.

Fixes obsproject/obs-studio#5314
2021-09-23 07:35:47 -07:00
jpark37
23f43f46db libobs: Support move for mismatched ComPtr 2021-09-15 02:52:12 -07:00
jpark37
f20a7c0540 libobs: Remove dependency on psapi.lib 2021-09-12 14:10:36 -07:00
Tommy Vercetti
aed2211dcd libobs: Restrict emmintrin.h to x86(_64) platform
There is a new toolchain called ARM64EC on MSVC which allows linking x64 objects to ARM64 objects.

It defines multiple architecture preprocessor definition including but not limited to `_M_X64`, `_M_ARM64` and `_M_ARM64EC`.

The original implementation will fail if compiling to ARM64EC.
2021-09-11 15:52:47 -07:00
jpark37
aa342ab6fc libobs/util: Const-correct win_version_compare 2021-09-10 20:19:24 -07:00
jpark37
920a160600 libobs: FIx missing noexcept warnings
warning C26439: This kind of function may not throw. Declare it
'noexcept' (f.6).
2021-09-05 20:35:46 -07:00
jpark37
1eb20ad5aa libobs/util: Improve SetThreadDescription usage
Fix warning about potential passing of NULL to FreeLibrary, and switch
from Kernel32.dll to KernelBase.dll based on MS documentation.
2021-08-30 22:33:17 -07:00
Jim
9b6cc99828
Merge pull request #5180 from jpark37/leaks
Fix a bunch of pthread leaks
2021-08-27 22:55:58 -07:00
tt2468
3e4c275efc libobs/util: Remove old ifdefs
These defs inadvertently redefinine `std::strtoll` in C++ code
that includes the header, causing lots of problems. They only
serve to provide compatability with very old MSVC versions.
As such, they can just be removed entirely.
2021-08-27 08:12:53 -07:00
jpark37
8a43c55918 libobs/util: Fix pthread mutex leaks 2021-08-23 22:57:10 -07:00
jpark37
b9657f6239 libobs/util: pthread_mutex_init_recursive helper
Add helper for creating a recursive mutex because it's easy to forget to
destroy the pthread_mutexattr_t.
2021-08-23 22:09:08 -07:00
Norihiro Kamae
bdb8f3f27b libobs/util: Fix reading memory usage on Linux
Memory usage displayed on Stats was too small due to a misaligned unit
of `resident_size` read from `statm` file and libobs.
2021-08-09 11:42:34 -07:00
Norihiro Kamae
7b4ae8611c libobs: Fix da_push_back taking a wrong type of item
Since the darray `sys_include_dirs` is an array of `char *`, it is
required to take a pointer to `char *`, that is `char **`. However,
`char *` was passed.
Since this function never called, another fix is removing entire
function `cf_preprocessor_add_sys_include_dir`.
2021-07-31 15:29:26 -07:00
Georges Basile Stavracas Neto
99559aab5a libobs: Add portal inhibitor
XDG Portals provide a plethora of features meant to be used inside and
outside sandboxed environments. OBS Studio currently uses portals to
implement Wayland-compatible monitor and window captures.

However, OBS Studio performs another action that can be done through
portals: inhibit the screensaver. Under the Desktop portal (the same
used by the captures mentioned above), there is an "Inhibit" portal
that provides session inhibition.

Add a new portal-based inhibitor. This inhibitor is only used when the
Desktop portal is available and running; the previous D-Bus implementation
is used in the absence of the portal. Because it's basically another set
of D-Bus operations, wrap the new portal inhibitor under the HAVE_DBUS
call too.
2021-07-18 14:04:44 -07:00
jpark37
83cb43f166 libobs: Mark unused parameters 2021-05-08 14:12:54 -07:00
jpark37
3c09074ed5 libobs/util: Skip pointless free for null 2021-03-31 06:07:11 -07:00
jpark37
d5e265d7dd libobs/util: Fix warnings for about null usages 2021-03-31 06:07:11 -07:00
jpark37
a20b4c67eb libobs/util: Compiler barriers for ARM64 atomics
Unsure if the intrinsics imply ordering. Safer to assume they don't.
2021-03-07 21:11:32 -08:00
Richard Stanway
6c0d234385 libobs: Minor fixes / code cleanups
Fixes some warnings generated by code analysis tools, removing redundant
checks etc.
2021-03-04 19:29:33 +01:00
Doug Kelly
4ab5a3bea1 libobs: use clock_gettime_nsec_np() for macOS
macOS should use the function clock_gettime_nsec_np() to get the
current clock in nanoseconds, instead of manually using
mach_absolute_time() and manually adjusting the timebase. This
greatly simplifies the platform-specific code to manage the
current time in nanoseconds.
2021-02-28 19:00:43 -08:00
Georges Basile Stavracas Neto
7f27963caa libobs/util: Split bus name from interface
When calling D-Bus methods, three fields are required:

 * The bus name, which is what applications own when they
   want to expose themselves to D-Bus;

 * The object path, which represents a D-Bus object exported
   under a bus name;

 * The interface, which holds the methods and signals;

While out of pure coincidence all the D-Bus buses have a
matching interface name, it is technically incorrect to assume
that.

Add a new 'interface' field to service_info, and split the bus
name.
2021-02-25 12:32:44 -08:00
Georges Basile Stavracas Neto
ec1b07cc85 libobs/util: Replace libdbus by GDBus
GDBus is more and better maintained than libdbus these days. In the
future, a potential Wayland-compatible capture plugin will need to
interact with D-Bus in a way that's way too complicated for libdbus,
and it won't be nice to have both libraries talking to the D-Bus
socket.

Replace the libdbus usage by GDBus. As it turns out, it results in less
code.
2021-02-25 12:32:44 -08:00
Georges Basile Stavracas Neto
94d2166951 libobs/util: Rename struct field 'id' to 'cookie'
All D-Bus interfaces call the unique identifier that is returned by their
calls "cookie", so rename the 'id' field to 'cookie' to match that.
2021-02-25 12:32:44 -08:00
jpark37
951acf2dfe libobs/util: More atomic fixes
Use _ARM_BARRIER_ISH for ARM path.

Remove useless conversion in os_atomic_load_bool.
2021-02-04 17:14:46 -08:00
jpark37
3df4a1109c libobs/util: ARM atomic fixes
Use native instructions on ARM64 (dmb is slow).

Use magic number for 32-bit ARM since _ARM64_BARRIER_ISH is for ARM64.
2021-02-03 22:18:26 -08:00
jpark37
1f90f0e36b libobs/util: Various atomic improvements
Add exchange functions to alias the poorly named set functions.

Add store without reading previous. Faster on non-x86 processors.

Add compare-exchange that updates previous to avoid redundant fetch.

On Windows, load bool without conversion from char.

On Windows, load using mov with compiler barrier. Still seq_cst.

On POSIX, use GCC __atomic builtins.
2021-02-03 08:51:31 -08:00
jpark37
54047ef9ca libobs: Avoid strncpy warning 2021-01-30 00:24:16 -08:00
jpark37
98d1f340da libobs: Fix unused parameter 2021-01-29 21:50:06 -08:00
jpark37
ccf16ddb65 libobs: Fix dstr leak 2021-01-22 22:16:17 -08:00
Richard Stanway
900b5341eb libobs: Add os_is_obs_plugin function
This function determines if something is an OBS plugin before attempting
to load it. On Windows, many plugins ship their dependent DLLs alongside
the plugin DLL, so OBS would load things like libcef.dll on startup only
to immediately free it. For other platforms, this is less of a concern
so this function is a no-op for now.

This improves startup time and reduces risk from dependent DLLs
potentially running code with unwanted side effects in DllMain.
2021-01-18 19:05:41 -08:00
Michael R. Crusoe
1e96573328 libobs: Update to SIMDe 0.7.1
c3d7abfaba

Simplify usage of the SIMDe header

This obviates the need for sse2neon as well and fixes compilation of all
plugins that referenced sse-intrin.h on all architectures, not just
arm*.
2021-01-02 04:07:55 -08:00
Vadim Zhukov
0d222b6b56 Add OpenBSD support 2020-11-14 11:55:22 -08:00
Colin Edwards
923f06bfa6 decklink: Add ability to ingest/embed cea 708 captions
(This commit also modifies libobs, UI)
2020-11-01 22:28:49 -08:00
jp9000
18486853a5 obs-ffmpeg: Add ability to debug ffmpeg-mux subprocess
Adds a cmake variable (DEBUG_FFMPEG_MUX) which enables FFmpeg debug
output in the ffmpeg-mux subprocess, and if on Windows, shows the
console window of the ffmpeg-mux subprocess so the current output can be
seen.
2020-10-14 18:42:22 -07:00
Valentin
b7f5cde4e3 libobs: Fix undefined behavior
It is undefined behavior to apply an offset to a null pointer. I would
have liked to reference cppreference but best I found was the PR that
added this check to clang's undefined behavior sanitizer:
https://reviews.llvm.org/D67122 .
2020-08-08 10:41:24 +02:00
venepe
f5d877b393 libobs: Add arm support 2020-07-18 00:53:03 -05:00
jp9000
18b915a47b libobs/util: Use is_padding() for wcsdepad as well
Fix wcsdepad so that it checks for padding in the same way strdepad
does.
2020-07-11 16:15:38 -07:00
sunjingzhao
05826491af libobs/util: Fix potential crash 2020-07-11 16:01:32 -07:00
Jim
0d7b4e1ced
Merge pull request #3006 from mr-c/simde_20200529
libos: Freshen SIMDe code copy
2020-06-21 05:34:38 -07:00
Masato Takahashi
4ded3b39fd libobs: Fix os_get_executable_path_ptr on Linux
Terminate a non-terminated string generated by readlink()
to pass to dirname() that needs terminated string as a parameter.
2020-06-01 09:22:12 +09:00