Commit Graph

2462 Commits (62ca01e1813803539f8889907f5a65c3bd6bcef0)

Author SHA1 Message Date
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 1982ee2597 libobs: Handle filter_texrender format mismatch
This is a possibility in the future where a target might switch between
SDR and HDR.
2022-03-08 12:56:35 -08:00
jpark37 16637baf88 libobs/graphics: Add gs_texrender_get_format 2022-03-08 12:56:35 -08:00
Exeldro 0751416db0 libobs: Fix overflow subtracting unsigned numbers
When offset_size is greater than size, size would overflow
2022-03-08 12:31:43 -08:00
Clayton Groeneveld 3df2f3e069 libobs: Add function to load private sources
If a private source is loaded with the obs_load_source function,
it is loaded as a normal source, so add a new function
to load private sources.
2022-03-08 01:49:24 -08:00
jp9000 c5dabb805f libobs: Update version to 27.2.3 2022-03-02 04:25:58 -08:00
jp9000 a8fd2e42df libobs: Update version to 27.2.2 2022-03-01 11:40:16 -08: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
jpark37 4e5906d2b0 libobs: Clamp video timing for safety
os_gettime_ns and os_sleepto_ns may not match up exactly.
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
obiwac c50c625555 libobs/graphics: gs_query_dmabuf_* on FreeBSD too 2022-02-26 15:36:08 -08:00
jpark37 5d1261eddb libobs: Only resize display if dimensions change 2022-02-26 01:09:07 -08:00
jp9000 f5b64ee33f libobs: Update version to 27.2.1 2022-02-20 16:35:15 -08:00
derrod 269d48f681 libobs: Adjust path for legacy browser source block
The current path would prevent the browser source from loading if OBS
itself is in the "Application Support" folder, where it might end up
when being installed via certain distribution platforms.
This adjusts the existing hack to specifically check for the obs-studio
subfolder where the old browser source library would reside.
2022-02-19 15:45:36 -08:00
Julian Orth 99a6c97b9e libobs: Map wayland keymap with MAP_PRIVATE
Wayland clients are required to use MAP_PRIVATE starting with version 7
of the wl_seat protocol.

Signed-off-by: Julian Orth <ju.orth@gmail.com>
2022-02-16 14:25:16 -03:00
jpark37 3a1124a5fd libobs/util: Fix VS static analysis warnings 2022-02-12 15:06:10 -08:00
jp9000 b68ee1ccae libobs: Update version to 27.2.0 2022-02-10 16:43:18 -08:00
jp9000 edfd5ad604 libobs: Add obs_object abstraction and functions
With this, you can now cast normal obs objects (services, outputs,
sources, encoders) to an obs_object_t, and then use obs_object_*
functions to get references, release references, and similar for weak
object references as well. This allows the ability for the frontend to
use an object of any of those types interchangeably in certain
situations without having to handle each specific type individually.

This is useful because the properties view in particular doesn't care
what type of object it uses, it just needs to be able to hold weak
references to abstract OBS objects.
2022-02-02 22:35:56 -08:00
jp9000 6b944a2f3c libobs: Rename OBSObj to OBSPtr
Makes it a bit more explicit that it's just a pointer RAII, and because
an OBSObject will be added
2022-02-02 22:35:56 -08:00
jpark37 657c4d0125 libobs: Add effect files to CMakeLists.txt
Makes them easily searchable from Visual Studio.
2022-01-29 17:16:16 -08:00
jpark37 59ab9c98fb libobs/graphics: Fix gs_get_format_bpp
Was missing case for GS_RGBA16F.
2022-01-29 18:51:34 -05:00
jpark37 63db2265dc libobs, libobs-d3d11, libobs-opengl: Add GS_RG16
This format will be useful for P010 chroma in the future.
2022-01-29 15:12:00 -08:00
Richard Stanway 4cc419e3c9 libobs: Free module if obs_module_load callback returns false
Currently if a module fails its load callback, it remains loaded and OBS
continues to call additional exports such as obs_module_post_load. This
goes against the documented behavior, which states that a module that
fails its load callback is unloaded.

This commit releases locale resources and frees the module's
information, preventing further callbacks from libobs. The module itself
(the DLL) is not yet unloaded from memory as os_dlclose is commented out
for causing unspecified issues - this should be revisited in the future.
2022-01-28 19:14:00 -08:00
Matt Gajownik 67dbb316a5 libobs: Respect push to talk/mute status in volmeter
The audio capture callback's mute parameter internally respects the
push to talk/mute state, whereas obs_source_muted() and the "mute"
signal don't. This resulted in meters looking entirely unmuted even
though both monitoring and output were not receiving audio.
2022-01-26 16:37:36 +11: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
Jim 0523c2e5e9 libobs: Replace addref calls with get_ref 2022-01-24 14:06:50 -08:00
Jim 77a35e93ea libobs: Use get_ref calls for obs.hpp helper classes 2022-01-24 14:06:50 -08:00
Jim f29e5ffbc7 libobs: Add obs_scene_get_ref() 2022-01-24 14:06:47 -08:00
jp9000 2416dfbd5e libobs: Prevent and log double destroy on sources
This prevents double destroys from happening on sources and causing
crashes. If someone's doing a double destroy it'll probably crash anyway
but at least we'll know what happened if it does. (Jim note: I suspect
third party plugins are calling addref on sources when they shouldn't
be. Either that or we're missing something ourselves, but I suppose
we'll see.)
2022-01-23 11:56:28 -08:00
Exeldro b2360b4332 libobs: Don't destroy mutex before destroying sources is done 2022-01-22 15:32:42 -08:00
Richard Stanway 82b5a39ea4 libobs: Mark raw_active and gpu_encoder_active as volatile
These were operated on by atomic functions but were not marked as
volatile or loaded with os_atomic_load_long, potentially introducing
subtle race conditions. Detected by ThreadSanitizer.
2022-01-18 03:49:20 -08:00
Richard Stanway dccf569982 libobs: Specify format string for bcrash
Detected by PVS Studio.
2022-01-15 00:31:31 +01:00
tytan652 30b8987bad libobs: Fix type mismatch on obs_property_text_monospace 2022-01-14 21:02:29 +11:00
Kurt Kartaltepe bcb04bb800 libobs: Open a separate X11 connection for hotkeys
Qt will mask certain input events. In order to avoid them masking things
like mouse button events we open a new display here.

Fixes #4843
2022-01-08 19:20:35 -03:00
Cody Jung e7837e30ce UI: Fix push-to-talk/mute delay not saving
Fixes a couple copy/paste errors preventing push-to-talk and push-to-mute delays
not saving when choosing Apply or OK.
2022-01-08 17:38:04 +11:00
jp9000 a5a8a7c32f libobs: Stop all source processing on destroy
Stops all video/audio IO when a source enters the destroy process.
Prevents any internal callbacks from being triggered and improves
performance.
2022-01-04 13:35:37 -08:00
jp9000 7fa07afd21 libobs: Call destroy signal after waiting
No real reason to have it above. Any other sources will still wait
anyway, so just makes things a bit more consistent.
2022-01-04 13:35:37 -08:00
jp9000 47d8f2e497 libobs: Remove all callbacks on source destroy
Removes all callbacks in use on sources right when a source is about to
be destroyed.

Fixes a crash where callbacks would still be executed while in a
destroyed state (particularly sidechain filters). Could also just mark
the source as being in a destroyed state and not accept anymore
obs_source_output_[audio/video] calls.
2022-01-04 01:45:49 -08:00
wangshaohui bb59dfd060 libobs: Move position for calling execute_graphics_tasks
The new order is as below:
[message pump]
output_frame
render_displays
execute_graphics_tasks
2021-12-31 17:34:20 -08:00
jp9000 2f13d92d25 libobs: Fix template errors on non-MS compilers
Because apparently Microsoft's compilers are bad at following language
specs.
2021-12-30 22:02:11 -08:00
jp9000 52cc1d533e libobs, UI: Fix cpp auto-release assignment from OBSRefs
The *AutoRelease helpers should not take references from OBSRef objects.
Instead, make an OBSRefAutoRelease base class, and OBSRef a subclass of
that to allow moves, and then perform moves from those objects.

This fixes an issue where *AutoRelease OBSRef objects would cause an
unintended double release of objects after having been assigned values
from non-*AutoRelease OBSRef objects.
2021-12-30 21:19:34 -08:00
jp9000 1655ebf18f libobs, UI: Add support for beta builds
Allows the ability to specify beta builds in addition to release
candidate builds
2021-12-27 10:01:07 -08:00
Richard Stanway 5be6681687 libobs: Check memory allocation in Windows crash handler
If we're crashing due to a low memory condition, it's dangerous to
try to allocate more memory without checking for success.
2021-12-26 17:48:54 +01:00
Richard Stanway 7d64e9d598 libobs: Use size_t for obs_encoder_get_frame_size 2021-12-26 17:32:00 +01:00
jp9000 8212cedf03 Revert "libobs, docs: Add function to get source version"
This reverts commit 1a7a10048c1a22ea969545e385a456b240baad5e.
2021-12-25 17:10:45 -08:00
Norihiro Kamae d1b87e1642 libobs: Add API to get encoder frame size
When muxing to some format, duration of the packet is used. We need an
API for encoder to return the frame size.
2021-12-23 10:48:37 -08:00
Clayton Groeneveld 5878856ce4 UI: Display grayscale volume meter if muted
Currently, the volume meters don't show volume levels when
muted. This shows the levels and makes it grayscale when
the source is muted.
2021-12-23 06:35:29 -08:00
columbarius 4cda05f270 libobs/graphics: Add Linux-only gs_query_dmabuf_* functions
When sharing DMA-BUFs it is required the announce the underlying
hardware capabilities via supported modifiers.

Add new device_query_dmabuf_capabilities vfunc to gs_exports and connect it
to the egl implementation stubs in the supported render platforms. Add a new
public method gs_query_dmabuf_capabilities() that calls the vfunc above.

Add new device_query_dmabuf_modifiers vfunc to gs_exports and connect it
to the egl implementation in the supported render platforms. Add a new
public method gs_query_dmabuf_modifiers() that calls the vfunc above.
2021-12-22 14:27:53 -03:00
tt2468 167f539416 libobs: Rename obs_audio_monitoring_supported to _available
With the reasonable possibility of monitoring support becoming a
runtime check, the phrase `available` is more fitting.
2021-12-22 02:43:14 -08:00
jp9000 49f9a055dc libobs: Fix destruction order for destruction task queue
Destruction of the task queue should probably happen after the audio and
video threads have been destroyed and all audio/video processing has
stopped.
2021-12-21 11:48:29 -08:00
jw0z96 447b17e75e libobs: Implement additional source blending modes 2021-12-20 09:06:38 -08:00
jw0z96 33a6d2a5fd libobs: Expose blending operation types 2021-12-20 09:06:38 -08:00
jp9000 8b3416c1e7 libobs: Implement deferred destruction of sources
(This also modifies the UI)

The purpose of deferring destruction of sources is to ensure that:
1.) Hard locks from enumeration cannot occur with source destruction.
  For example, if the browser source is destroyed while in the graphics
  thread, the browser thread would wait for the graphics thread, but the
  graphics thread would still be waiting for the browser thread, causing
  a hard lock.
2.) When destroys occur during source enumeration, that the integrity of
  the context's next pointer in the linked list can no longer be
  compromised
3.) Source releases are fully asynchronous rather than having the risk
  of stalling the calling thread
4.) We can wait for source destruction when switching scene collections
  or when shutting down rather than hoping for threads to be finished
  with sources.

This introduces a new requirement when cleaning up scene/source data:
the obs_wait_for_destroy_queue() function. It is highly recommended that
this function be called after cleaning up sources. It will return true
if at least one or more sources were destroyed. Otherwise it will return
false. Forks are highly advised to call this function manually on source
cleanup -- preferably in a loop, in conjunction with processing
outstanding OBS signals and UI events.
2021-12-19 11:53:19 -08:00
jp9000 ab84214356 libobs: Add obs_in_task_thread() function
Allows determining which thread the caller is currently in, if any
2021-12-19 11:53:19 -08:00
jp9000 cf492ca271 libobs: Add ability to queue audio task
This is mostly framework for allowing the ability to wait for certain
threads
2021-12-19 11:53:14 -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 408ce92146 Revert "libobs: Do not release while traversing sources for tick"
This reverts commit 080090c40e.
2021-12-19 11:25:57 -08:00
tt2468 d07bd7dff2 libobs: Hold source ref during `source_remove` signal
Holds an active reference to a source during signaling of the
`source_remove` signal, to prevent receivers from being given an
already-destroyed source.

- Call obs_source_remove(source)
- Receiver 1 gets signal, calls `obs_source_release(source)`
- Receiver 2 gets signal, calls `obs_source_release(source)`,
refs == -1, source destroyed
- Receiver 3 gets signal, source already destroyed, is forced to ignore
signal due to invalid source

This is a theoretical situation which is currently possible in
obs-websocket.
2021-12-19 11:25:43 -08:00
tt2468 647fb1376d libobs: Add preprocessor directive for AutoRelease types
Since these helpers come from obs-websocket, obs-websocket needs a way
to disable its own helpers if OBS is new enough to include them
already.
2021-12-18 16:42:51 +11:00
Kurt Kartaltepe 0729007f19 libobs: Add Wayland hotkey infrastructure
Users on Wayland are displeased that they cannot see their hotkey
bindings. This enables key reporting like X11, and has the infrastructure
in place in case Wayland ever decides to allow for capturing input.
2021-12-16 10:54:29 -03:00
Kurt Kartaltepe 21fdd83b7e libobs: Fix Numpad Minus naming in UI
OBS_KEY_NUMMINUS was not included in the key to string function so it
was reported as a regular minus.
2021-12-16 10:54:29 -03:00
jp9000 080090c40e libobs: Do not release while traversing sources for tick
obs_source_release should not be called while iterating through the
global sources linked list, otherwise the linked list will be
compromised. Annoying.

Basically the same fix as obsproject/obs-studio#5600, but should be
slightly more optimal and a bit more explicit.
2021-12-15 11:57:52 -08:00
jp9000 b2c09d3523 libobs: Fix potentially unsafe linked list traversal
Fixes an issue pointed out in obsproject/obs-browser#333 where a source
may destroy the next source in obs_source_video_tick(), thus
invalidating the next source in the linked list. Get the next source in
the list *after* calling obs_source_video_tick() rather than before.

Closes obsproject/obs-studio#5600
2021-12-14 10:34:53 -08:00
Jim 83f08725e4
Merge pull request #5580 from VodBox/add-cpp-templates
libobs: Add AutoRelease OBSRef wrappers for OBS types
2021-12-13 21:31:27 -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
jp9000 b92e941b4f libobs: Add source cap to hint not to show properties
(This commit also modifies UI)

Adds a source capability flag to indicate that properties should not be
shown on creation
2021-12-07 20:54:37 -08:00
wangshaohui 00e6f6e023 libobs: Fix missing return when loading non-OBS DLL 2021-12-06 14:30:26 +01:00
jp9000 243880b9ce libobs: Fix add/remove of raw audio callbacks 2021-11-28 02:49:04 -08:00
VodBox a8c30373d6 libobs: Add AutoRelease OBSRef wrappers for OBS types
These AutoRelease versions of the C++ OBSRef types do not add a ref on
construction, which is useful when accepting the result of a function
that turns a raw C pointer type that has had a reference added.

Not having these types has resulted in multiple awkward anti-patterns.
Such as immediately releasing after construction to account for the
extra addref, or avoiding using the C++ type entirely and manually
releasing it later.

Example:
```
OBSSource source = obs_get_source_by_name(name.c_str());
obs_source_release(source);
```

The whole point of these types is to avoid the need for manual releases,
and rely on the RAII mechanisms inside of C++. Additionally, the
immediate release isn't commented anywhere, resulting in confusion for
other developers looking at the code as to why things are being
immediately released.

The AutoRelease types and names are taken from obs-websocket.
2021-11-26 22:35:03 +13:00
Clayton Groeneveld d45e92c10c libobs: Add raw audio callback function
This complements the already existing raw video callback function.
2021-11-24 01:32:31 -08:00
tt2468 079e6cebee libobs: Free async cache when sources output NULL frames
When sources output NULL frames, it is generally used to disable the
source and prevent the last frame from being left on screen. However,
when the source begins outputting video again, the last frame is
still in the async cache.

Depending on the stability of the source's frame output, this still
frame can end up being shown for 5+ output frames.

By freeing the async cache when a NULL frame is submitted, we avoid
the issue of old frames being re-displayed.
2021-11-23 23:04:46 -08:00
Kasin Sparks 67d2b50a91 UI: Fix bug with audio balance slider not updating
Fixes #4763.
2021-11-23 22:06:25 -08:00
gxalpha c104e59bd4 libobs: Add obs_scene_prune_sources
Adds a function that goes through the scene and releases all sources
that have been removed.
2021-11-23 22:00:47 -08:00
tt2468 c90b13f93e libobs: Add `audio_monitoring` source signal
Adds a source signal for audio monitoring type changes
2021-11-20 20:00:59 -08:00
tt2468 ff22897d68 libobs/UI: Stop using preprocessor directives for monitor
**Code Cleanup**
Stop using preprocessor directives to determine if audio monitoring
is supported. Use runtime function instead
2021-11-20 20:00:59 -08:00
tt2468 6e9644ec15 libobs: Add obs_audio_monitoring_supported()
Currently, ifdefs are used to determine if monitoring is supported.
This is difficult to maintain and restricts plugins from knowing if
monitoring is supported by OBS. This adds a runtime function to fix
that issue.
2021-11-20 20:00:59 -08:00
VodBox c8e417057a libobs, libobs-d3d11: Add support for NT Handle shared textures
Adds support for using shared textures that were made with the
D3D11_RESOURCE_MISC_SHARED_NTHANDLE flag.

This increases the minimum required Windows version to Windows 8 or the
Platform Update for Windows 7. As official support is only for Win 8+
this does not change official support.
2021-11-20 16:34:28 +13:00
jp9000 0815d5c887 Revert "libobs: Avoid recycling async frames"
This reverts commit 96c1a76523.

Closes obsproject/obs-studio#5474
2021-11-10 16:54:27 -08:00
gxalpha c36a5ae92b libobs: Add obs_get_transition_by_name 2021-11-07 07:40:03 -08:00
Kurt Kartaltepe 5142a7685d pulse: fill audio monitor buffer more aggressively
Previously we would wait for pulse to attempt to read from the monitor
source and obs buffered at least 5ms of audio data before we tried to
fill the buffer. In some cases this resulted in consistently triggering
underruns in pulse.

Instead we try to fill the buffer immediately as obs outputs audio data
and while the pa buffer is not full. We also stop trying to grow the
buffer to prevent underruns after we reach 1s of latency.
2021-11-04 13:00:46 -07:00
Clayton Groeneveld af6c719139 UI, libobs, obs-plugins: Fix compiler warnings
Found warnings when compiling OBS.
2021-11-04 06:25:52 -07:00
Clayton Groeneveld 4b00c8566f libobs, docs: Add function to get source version 2021-10-28 09:14:23 -07:00
jp9000 a4146a685b libobs: Allow last encoder error for last output error
(This commit also modifies UI)

This makes it more trivial for encoder plugins to communicate to users
why specifically an encoder error might have occurred mid-stream.
2021-10-25 12:24:16 -07: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
jp9000 48ee5a8ac9 libobs: Mark unused audio functions as deprecated 2021-10-24 02:00:16 -07:00
jp9000 18f97fb494 Revert "libobs: Remove unused volmeter code"
This reverts commit 07d30cbff9.
2021-10-24 01:58:46 -07:00
Clayton Groeneveld 07d30cbff9 libobs: Remove unused volmeter code
This code is unused as the volmeter interval is set on the
UI side.
2021-10-24 01:57:28 -07:00
Norihiro Kamae 85f45a3ef6 libobs/audio-monitoring: Fix PulseAudio monitoring volume for u8 format
Change `char` to `uint8_t` in `process_byte` because the type is
expected unsigned 8-bit.
2021-10-23 23:59:53 -07:00
Norihiro Kamae 0eed7ca98f libobs/audio-monitoring: Fix PulseAudio monitoring volume for s32 format
When signed 32-bit audio arrived to pulseaudio-output and volume was
lowered, audio data was broken. In the function `process_volume`, the
type of the data is switched by `bytes_per_channel`. However the size of
signed 32-bit integer and the size of float are same so that the signed
32-bit integer is processed as float.
This commit changes these items.
- Use `format` instead of `bytes_per_channel` so that all the sample
  types can be differentiated.
- Change `short` to `int16_t` and renames existing function
  `process_short` to `process_s16` to clarify the function is
  processing signed 16-bit.
2021-10-23 23:59:53 -07:00
jp9000 9819cb2924 libobs: Add obs_weak_source_expired() 2021-10-15 22:10:33 -07:00
tt2468 23cda97a54 libobs/callback: Make proc_handler_t threadsafe
Add mutexes to protect against multi-threaded memory access
violations.
2021-10-14 04:28:04 -07:00
Ryan Foster 5f68991911 clang-format: Commit file changes for clang-format 12 2021-10-13 20:00:04 +11:00
Ryan Foster 424128a825 clang-format: Commit file changes for clang-format 11 2021-10-13 20:00:04 +11:00
jpark37 3c71399650 libobs/audio-monitoring: Add reconnect logic
Automatically tear down if monitor is invalidated, and retry every time
an input sample is played.
2021-10-10 19:22:35 -07:00
jpark37 eb6050f3ce libobs/audio-monitoring: Move variable assignment
Assinged too early for upcoming change that may reset monitor->render.
2021-10-10 19:22:35 -07:00
jpark37 7af886581d libobs/audio-monitoring: Add WASAPI init helper
audio_monitor_init_wasapi will be used for reconnect logic.
2021-10-10 19:22:35 -07:00
jpark37 63ffae7d74 libobs/audio-monitoring: Remove unnecessary device 2021-10-10 19:22:35 -07:00
jpark37 b005e6748e libobs/audio-monitoring: Fix mutex leak
Use SRWLOCK for simplicity. Does not need to be destroyed.
2021-10-10 19:22:35 -07:00
jpark37 e582879303 libobs/media-io: Register audio thread with MMCSS
Ensure audio gets more priority to help prevent glitching.
2021-10-10 19:19:01 -07: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 a3f10cf0be libobs: Remove WIN32_LEAN_AND_MEAN
It should already be defined near the Windows.h include.
2021-10-10 19:12:45 -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
jpark37 02d98b26a0 libobs/graphics: Fix vec2 min/max functions 2021-10-10 19:12:45 -07:00
jpark37 3c45ae2e9d libobs, libobs-opengl: Consistent near/far undef 2021-10-10 19:12:45 -07:00
Jimi Huotari 9d6ecc8beb cmake: Don't link with PulseAudio when disabled
Don't search for, or link with the PulseAudio library when
DISABLE_PULSEAUDIO is true, and set as REQUIRED when false.

Closes https://github.com/obsproject/obs-studio/issues/4025
2021-10-08 15:30:22 +11:00
jp9000 9ef76e1f9b libobs: Clear unused pointers for obs_source_output_audio()
Apparently, some audio filters do not check the audio channel/plane
count, and instead check to see if a pointer is valid. Instead of
requiring the caller to initialize these values to 0 manually (they
shouldn't have to), set them to zero upon input in
obs_source_output_audio() itself.

Closes obsproject/obs-studio#3744
2021-10-06 16:33:31 -07:00
jp9000 3c14e4ece2 libobs: Update version to 27.1.2 2021-10-04 10:38:39 -07:00
jp9000 49dad0a935 Revert "libobs: Don't return/set 0 mixers for non-audio sources"
This reverts commit 1df2789978.

This causes new sources to have their default mixer value overriden,
reverting until a more ideal fix is approved
2021-10-04 10:37:51 -07:00
jp9000 a0595ae45b libobs: Update to version 27.1.2 2021-10-03 13:44:49 -07:00
jp9000 1df2789978 libobs: Don't return/set 0 mixers for non-audio sources
Fixes a bug where if an audio source's implementation disappears (i.e.
a plugin vanishes or is removed), it would turn all mixing channels off,
effectively muting the source
2021-10-02 10:16:24 -07:00
jpark37 4e6765a01b libobs: Remove DrawSrgbDecompressPremultiplied
Technique is no longer referenced, and doesn't seem useful.
2021-10-02 05:53:27 -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
Norihiro Kamae 5e75efd14c libobs: Fix const qualifier mismatch on DARRAY 2021-10-01 12:59:27 +09:00
Norihiro Kamae d65ca911dd libobs: Add casts to da_push_back_array arguments 2021-10-01 12:58:14 +09:00
jpark37 10cf411f99 libobs: DrawSrgbDecompress for default_rect.effect
Necessary for upcoming fix to browser source alpha.
2021-09-30 17:35:06 -07: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
jp9000 516cd32758 libobs: Update version to 27.1.1
Nothing actually changed, it was just a deploy script issue on Windows.
Bumping the version so that people who updated will get a new update.
2021-09-28 08:43:22 -07:00
jp9000 e6effff82f libobs: Update version to 27.1.0 2021-09-24 07:07:05 -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
tt2468 529a412840 libobs: Block sceneitem create if item source is removed
There are some cases where an item may attempt to be created for a
removed source.

Previously, items created from removed sources would lead to the item
itself being saved, but the underlying source not being saved. While
this does not break OBS immediately, it means that the source along
with all associated items will disappear on OBS reload.

This prevents the item from being created in the first place, reducing
the chances of user work being lost.
2021-09-13 01:37:51 -07:00
jpark37 f20a7c0540 libobs: Remove dependency on psapi.lib 2021-09-12 14:10:36 -07:00
jp9000 b2839c3ec3 libobs: Actually fix ungroup deadlock
66c27c2cea (#4664) was mistakenly merged. It was also the incorrect
way to fix the deadlock. Because duplicate_item_data() already defers
the texture creation process, we can just add a param to
obs_scene_add_internal() which allows us to exclude the creation of the
item texture for this specific case. The texture will then automatically
be created later before it's used. There was no reason to be creating
the texture there, as it was unnecessary.

Properly fixes obsproject/obs-studio#3166
2021-09-11 22:00:08 -07:00
jp9000 551eff0c26 Revert "libobs: Avoid request graphics lock after full_lock(scene)."
This reverts commit 66c27c2cea.
2021-09-11 21:07:43 -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
Tommy Vercetti e1cf7c0e4b libobs: Fix near and far redefinition on MSVC 2021-09-11 15:50:06 -07:00
Tommy Vercetti 1f4c6fd154 libobs: Fix connect() redefinition on MSVC 2021-09-11 15:50:06 -07:00
wangshaohui 66c27c2cea libobs: Avoid request graphics lock after full_lock(scene).
As logic in video render thread, gs lock (obs_enter_graphics) should be requested before full_lock(scene).
However in function obs_sceneitem_group_ungroup called from UI thread, the order for requesting locks are contrary.
2021-09-11 15:49:25 -07:00
Kurt Kartaltepe b47e4858b8 libobs: Add profiler section for send_packet
This makes it a bit more clear when muxing takes longer than expected
instead of attributing the time to the do_encode.
2021-09-11 15:33:02 -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 f5b65ec5d3 libobs/graphics: Fix gs_generalize_format warning
warning C26819: Unannotated fallthrough between switch labels (es.78).
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 0d282c0715 libobs: Add missing util.hpp to CMakeLists.txt 2021-08-23 23:15:15 -07:00
jpark37 353868e87c libobs: Fix pthread mutex leaks 2021-08-23 22:57:10 -07:00
jpark37 8a43c55918 libobs/util: Fix pthread mutex leaks 2021-08-23 22:57:10 -07:00
jpark37 0c208f1e62 libobs/media-io: Fix leaks and error handling 2021-08-23 22:57:07 -07:00
jpark37 8075e8bb65 libobs/callback: Fix pthread mutex leaks 2021-08-23 22:31:00 -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
Richard Stanway 4772a99e3e libobs: Defer reconfiguring encoders to the encode threads
Fixes a long-standing issue with Dynamic Bitrate where the RTMP output
thread could try to reconfigure an encoder while the encoder is in the
middle of encoding. x264 seems to handle multithreaded calls well, but
NVENC would deadlock in this situation with no error visible to the
user.
2021-08-23 18:26:37 -07:00
Ryan Foster ea9c75bacb cmake: Remove local files for checking threading support
These local copies of CheckForPthreads.c and FindThreads.cmake override
the ones included with CMake. These versions create CMake::Threads, but
Qt6 expects Threads::Threads created by CMake 3.1+. These local versions
seem to be based on old copies from CMake from late 2014 with some
customizations. Let's just use the built-in ones that CMake ships.

This commit also changes CMakeLists.txt files in UI and libobs to
require and link to Threads::Threads.

Co-authored-by: Kurt Kartaltepe <kkartaltepe@gmail.com>
2021-08-17 02:46:09 -07:00
jpark37 96c1a76523 libobs: Avoid recycling async frames
Fixes major cause of lock contention when using lots of media sources.
2021-08-15 00:12:14 -07:00
jpark37 e6ab8106aa libobs/graphics: Avoid darray recycle
Reset size instead of capacity.
2021-08-15 00:12:14 -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