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

409 Commits

Author SHA1 Message Date
jp9000
a0eae6f33c libobs/util: Add get_plugin_info (internal)
Allows the ability to get additional information about the plugin beyond
just whether it's an OBS plugin. For this case, whether it can load,
which is primarily used on Windows and mostly just determines whether it
has an incompatible Qt version.
2022-07-28 16:36:01 -07:00
jp9000
f6e349f033 libobs/util: Put module load detection in its own func
Puts the detection of obs_module_load in Windows DLLs for the "is this
an obs plugin" check into its own function
2022-07-28 14:53:58 -07:00
gxalpha
9d68c8a848 libobs: Fix crash handler noreturn compiler warning
Maybe not the most correct solution since it never gets hit but much
less code and ifdefs compared to what we'd have else wise.
2022-07-27 12:05:16 -04:00
jpark37
0d129988a9 libobs: Allow Chrome class executable matching
Lets OBS find Spotify.exe even if the window title changes.
2022-07-23 17:41:34 -07:00
jpark37
69ff026647 libobs, win-capture: Share window helper code
Add "ms_" prefix as makeshift namespace.
2022-07-23 17:41:34 -07:00
jpark37
7864c8649a libobs/util: Add WinModule RAII wrapper 2022-07-23 17:41:34 -07:00
tytan652
447f2869ab libobs: Remove OBS_UNUSED 2022-07-20 09:03:31 +02:00
tytan652
12657e4fcc libobs: Replace OBS_UNUSED with UNUSED_PARAMETER
OBS_UNUSED is not portable to MSVC.
2022-07-20 08:22:08 +02:00
Norihiro Kamae
af3890a4a9 libobs: Cleanup unused-parameters
- Add OBS_UNUSED to unused function parameters
- Remove unnecessary UNUSED_PARAMETER
Also update libobs-opengl/
2022-07-19 11:01:00 -04:00
Richard Stanway
c5965c8605 libobs: Log errors for bmalloc(0)
malloc(0) is implementation defined and almost always a mistake. I
believe we should be more like malloc and treat bmalloc(0) as an error
instead of tying to handle it. For now we can log an error in case 3rd
party plugins are broken, in the future I would suggest this becomes a
crash-worthy error.
2022-07-16 15:20:55 -07:00
Richard Stanway
dbdbfe79d2 libobs: Deprecate base_set_allocator and make it no-op
Hopefully nothing is actually using this in the first place. As a
library libobs has alignment requirements so we should probably not
allow an application to replace our aligned mallocs with something else.
This also allows more aggressive optimizations inside libobs as the call
can be completely inlined into a libc malloc.
2022-07-16 15:20:55 -07:00
Tommy Vercetti
3b64e74660 libobs/util: Add function to get Rosetta translation status 2022-06-19 01:37:15 +02:00
tt2468
f6a77ec0a6 libobs/util: Add %s string replacement for unix time
Adds %s which replaces the keyword with the current unix epoch time.

The %s keyword is common in languages like PHP and Python, and even
some C implementations, but it is not standard so this is a fallback.
2022-05-28 18:30:41 -04:00
Norihiro Kamae
c491594a51 libobs/util: Add os_sleepto_ns_fast
The function `os_sleepto_ns` has a spin loop so it will consume CPU
resource. The new function has same interface but consumes less CPU
resource with a drawback of less precision.
2022-05-15 02:31:31 -07:00
tt2468
9168797361 libobs,obs-outputs: Fix librtmp1 interference
Details in #6226, basically this fixes an issue where OBS links
to the system-installed librtmp1, which is incompatible with our
librtmp.

Co-authored-by: ewhac <ewhac@ewhac.org>
2022-04-25 18:45:05 -07:00
jp9000
493f6337f3 libobs/util: Add ConfigFile::OpenString()
For convenience
2022-04-22 12:49:38 -07:00
jp9000
a9ce118794 libobs/util: Add missing extern "C" header guard 2022-04-22 12:48:54 -07:00
tt2468
af67ef8e57 libobs, UI: Fix --verbose logging for stdout
Verbosity of stdout was previously hardcoded to INFO, while log viewer
and log files had correct verbosity. This makes the behavior of
--verbose make sense in all places.
2022-04-09 16:48:37 -07:00
jp9000
5e2c757cd1 libobs/util: Remove deprecation visibility from swig 2022-03-24 22:32:19 -07:00
jpark37
6f8b364565 libobs: Add OBS_COUNTOF for array count 2022-03-23 09:15:25 -07:00
PatTheMav
1fd7770548
libobs: Update CMakeLists.txt for libobs and associated libraries
Also updates libobs-opengl, libobs-d3d11, libobs-winrt
2022-03-16 23:11:08 +01:00
jpark37
fbcb053cfa libobs/util: Use integer math for Windows timing
Cleaner and faster than double math.
2022-02-28 10:11:03 -08:00
jp9000
4f15f1062d libobs/util: Fix rounding error with os_sleepto_ns()
os_sleepto_ns() can occasionally return false on times that the
processor may not have reached yet. The reason is because the
count_target, which converts time_target into a QPC counter, is subject
to a rounding error.

Using numbers I generated from an actual clock cycle on my own CPU, I
can show an example of this occurring: if the clock frequency value is
10000000.0, and you call os_sleepto_ns(42164590320600), it will convert
that number first to a double floating point of its QPC value:
421645903205.99994. Then, because it converts that to a LONGLONG
integer, it of course strips off the decimal point. If you convert
421645903205 *back* to a time value, the new value will be
42164590320500, which is lower than the original value by approximately
100 nanoseconds. While this may seem insignificant, it was apparently
enough to cause the os_sleepto_ns() call in video_sleep() to sometimes
return false despite the current time being lower than the target time,
which would cause it to incorrectly calculate how many frames were
duplicated by subtracting the frame time from the current system time,
divide that by the current frame interval, set the vframe_info.count
value to 0, and thus cause an infinite loop in the encode_gpu()
function because queue_frame now starts returning negative numbers in
perpetuity.

This change fixes some rare reports of users having their video lock up
and disconnect, forcing the user to have to forcibly shut down the
program.

Thanks to Twitch user SNLabat for having the patience to kindly provide
us with a dump file from the freeze, and to Matt for coordinating with
that user to obtain it from them.
2022-02-28 02:07:13 -08:00
jpark37
3a1124a5fd libobs/util: Fix VS static analysis warnings 2022-02-12 15:06:10 -08:00
Jim
03d9bda387 libobs: Deprecate obs object addref functions
Deprecates:
obs_source_addref()
obs_output_addref()
obs_encoder_addref()
obs_service_addref()
obs_scene_addref()

These functions should be considered unsafe and not used. Instead, use:
obs_source_get_ref()
obs_output_get_ref()
obs_encoder_get_ref()
obs_service_get_ref()
obs_scene_get_ref()

These functions return a pointer to the incremented object only if the
object is still valid, otherwise they will return null, indicating that
the object is no longer valid or is unsafe to use.

The reason why this is being done is because certain third party plugins
seem to be using addref, and are somehow managing to call addref on
sources that have already been fully released. For the sake of safety,
almost all usage of these functions within OBS have also been replaced
as well.
2022-01-25 05:20:03 -08:00
jp9000
5a36bd5c9a libobs/util: Add task queue helper
Adds a cool little task queue thing so a dedicated task thread can be
spawned
2021-12-19 11:25:57 -08:00
jp9000
96631d580a libobs/util: Fix end_pos when pushing empty circlebuf front
When pushing to the front of an empty circular buffer, it would not
update the end_pos, so end_pos would be left on 0, and it would break
when trying to push to the back after that. The reason why this bug was
never discovered until now is because breakage only happens when pushing
to the front of an empty buffer, then pushing to the back right after
that.
2021-12-09 20:18:42 -08:00
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