obs-studio/libobs
jp9000 2d7cda18e9 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 22:22:29 +11:00
..
audio-monitoring libobs: Rename obs_audio_monitoring_supported to _available 2021-12-22 02:43:14 -08:00
callback libobs/callback: Make proc_handler_t threadsafe 2021-10-14 04:28:04 -07:00
data libobs: Remove DrawSrgbDecompressPremultiplied 2021-10-02 05:53:27 -07:00
graphics libobs/graphics: gs_query_dmabuf_* on FreeBSD too 2022-02-28 22:21:41 +11:00
media-io clang-format: Commit file changes for clang-format 12 2021-10-13 20:00:04 +11:00
util libobs/util: Fix rounding error with os_sleepto_ns() 2022-02-28 22:22:29 +11:00
CMakeLists.txt libobs: Add effect files to CMakeLists.txt 2022-01-29 17:16:16 -08:00
libobs.pc.in libobs: add ppc64(le) specific flags to libobs.pc 2020-04-27 00:07:18 +02:00
LibObsConfig.cmake.in cmake: Export plugin data destination 2014-09-27 09:41:32 -07:00
LibObsConfigVersion.cmake.in Export libobs cmake target, so external plugins can be built without ugly hacks 2014-05-08 14:43:16 +02:00
obs-audio-controls.c libobs: Respect push to talk/mute status in volmeter 2022-01-26 16:37:36 +11:00
obs-audio-controls.h libobs: Mark unused audio functions as deprecated 2021-10-24 02:00:16 -07:00
obs-audio.c libobs: Add ability to queue audio task 2021-12-19 11:53:14 -08:00
obs-avc.c clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
obs-avc.h clang-format: Commit file changes for clang-format 11 2021-10-13 20:00:04 +11:00
obs-cocoa.m libobs: Cleanup uses of objc_msgSend in Objective-C code 2021-01-12 10:10:37 -08:00
obs-config.h libobs: Update version to 27.2.1 2022-02-20 16:35:43 -08:00
obs-data.c libobs: Add obs_data_get_last_json() 2021-04-23 12:38:50 -07:00
obs-data.h libobs: Add obs_data_get_last_json() 2021-04-23 12:38:50 -07:00
obs-defs.h clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
obs-display.c clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
obs-encoder.c libobs: Add obs_object abstraction and functions 2022-02-02 22:35:56 -08:00
obs-encoder.h UI: Hide encoder if marked internal 2020-02-18 21:37:41 -08:00
obs-ffmpeg-compat.h clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
obs-hotkey-name-map.c libobs: Remove WIN32_LEAN_AND_MEAN 2021-10-10 19:12:45 -07:00
obs-hotkey.c libobs, linux-v4l2: Set thread names 2021-01-25 04:13:24 -08:00
obs-hotkey.h clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
obs-hotkeys.h libobs: Remove _WIN32 ifdef from enum 2019-11-17 20:30:42 -08:00
obs-interaction.h clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
obs-internal.h libobs: Add obs_object abstraction and functions 2022-02-02 22:35:56 -08:00
obs-missing-files.c libobs: Add missing file API to sources 2021-01-17 10:31:58 +13:00
obs-missing-files.h libobs: Add missing file API to sources 2021-01-17 10:31:58 +13:00
obs-module.c libobs: Adjust path for legacy browser source block 2022-02-20 12:06:03 +11:00
obs-module.h libobs: Add functions to get locale text from modules 2020-08-10 12:24:01 -07:00
obs-nix-platform.c libobs: Introduce the concept of a Unix platform 2021-02-01 19:05:10 -03:00
obs-nix-platform.h libobs: Add a Wayland platform 2021-02-09 09:39:04 -03:00
obs-nix-wayland.c libobs: Map wayland keymap with MAP_PRIVATE 2022-02-21 14:10:36 -05:00
obs-nix-wayland.h libobs: Add a Wayland platform 2021-02-09 09:39:04 -03:00
obs-nix-x11.c libobs: Open a separate X11 connection for hotkeys 2022-01-08 19:20:35 -03:00
obs-nix-x11.h libobs/nix: Move X11-specific code to obs-nix-x11.c 2021-02-01 19:03:43 -03:00
obs-nix.c libobs/nix: List Flatpak search paths 2021-07-08 10:53:15 -07:00
obs-nix.h libobs/nix: Move X11-specific code to obs-nix-x11.c 2021-02-01 19:03:43 -03:00
obs-output-delay.c libobs: Minor fixes / code cleanups 2021-03-04 19:29:33 +01:00
obs-output.c libobs: Add obs_object abstraction and functions 2022-02-02 22:35:56 -08:00
obs-output.h libobs: Implement pausing of outputs 2019-07-07 16:38:22 -07:00
obs-properties.c libobs: Fix type mismatch on obs_property_text_monospace 2022-01-14 21:02:29 +11:00
obs-properties.h libobs: Fix type mismatch on obs_property_text_monospace 2022-01-14 21:02:29 +11:00
obs-scene.c libobs: Replace addref calls with get_ref 2022-01-24 14:06:50 -08:00
obs-scene.h libobs: Implement additional source blending modes 2021-12-20 09:06:38 -08:00
obs-service.c libobs: Add obs_object abstraction and functions 2022-02-02 22:35:56 -08:00
obs-service.h libobs: Change service max res. to res. list 2020-11-13 18:22:53 -08:00
obs-source-deinterlace.c libobs: Deinterlace as linear SRGB when needed 2021-01-21 07:42:57 -08:00
obs-source-transition.c libobs: Replace addref calls with get_ref 2022-01-24 14:06:50 -08:00
obs-source.c libobs: Add obs_object abstraction and functions 2022-02-02 22:35:56 -08:00
obs-source.h libobs: Add source cap to hint not to show properties 2021-12-07 20:54:37 -08:00
obs-ui.h docs/sphinx: Fix various typos 2019-10-14 17:19:38 -07:00
obs-video-gpu-encode.c libobs: Defer reconfiguring encoders to the encode threads 2021-08-23 18:26:37 -07:00
obs-video.c libobs: Mark raw_active and gpu_encoder_active as volatile 2022-01-18 03:49:20 -08:00
obs-view.c libobs: Replace addref calls with get_ref 2022-01-24 14:06:50 -08:00
obs-win-crash-handler.c libobs: Specify format string for bcrash 2022-01-15 00:31:31 +01:00
obs-windows.c libobs: Log Windows 10 Hardware GPU Scheduler 2020-08-26 22:57:52 +02:00
obs.c libobs: Add obs_object abstraction and functions 2022-02-02 22:35:56 -08:00
obs.h libobs: Add obs_object abstraction and functions 2022-02-02 22:35:56 -08:00
obs.hpp libobs: Add obs_object abstraction and functions 2022-02-02 22:35:56 -08:00
obsconfig.h.in libobs, UI: Add support for beta builds 2021-12-27 10:01:07 -08:00