obs-studio/libobs/util
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
..
apple clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
curl Make cert revocation check fails non-fatal on Win 2020-03-13 07:48:47 -07:00
simde simde: Update README.libobs 2021-10-24 02:26:17 -07:00
windows libobs: Support move for mismatched ComPtr 2021-09-15 02:52:12 -07:00
AlignedNew.hpp clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
array-serializer.c libobs/util: Add a cast for da_push_back_array argument 2021-10-01 12:59:35 +09:00
array-serializer.h clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
base.c libobs: Add OBS_NORETURN and use it for crash handler 2021-12-09 02:42:37 +01:00
base.h libobs: Disable function attributes for SWIG 2021-12-09 03:36:40 +01:00
bitstream.c decklink: Add ability to ingest/embed cea 708 captions 2020-11-01 22:28:49 -08:00
bitstream.h decklink: Add ability to ingest/embed cea 708 captions 2020-11-01 22:28:49 -08:00
bmem.c libobs/util: Skip pointless free for null 2021-03-31 06:07:11 -07:00
bmem.h clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
c99defs.h libobs: Deprecate obs object addref functions 2022-01-25 05:20:03 -08:00
cf-lexer.c clang-format: Commit file changes for clang-format 12 2021-10-13 20:00:04 +11:00
cf-lexer.h libobs: Fix da_push_back taking a wrong type of item 2021-07-31 15:29:26 -07:00
cf-parser.c clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
cf-parser.h clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
circlebuf.h libobs/util: Fix end_pos when pushing empty circlebuf front 2021-12-09 20:18:42 -08:00
config-file.c libobs/util: Fix pthread mutex leaks 2021-08-23 22:57:10 -07:00
config-file.h clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
crc32.c clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
crc32.h libobs/util: Add function to calculate CRC32 2015-10-04 21:16:27 -07:00
darray.h libobs/util: Add type test in darray macros for GCC 2021-10-01 13:00:00 +09:00
dstr.c libobs/util: Use is_padding() for wcsdepad as well 2020-07-11 16:15:38 -07:00
dstr.h libobs/util: Fix warnings for about null usages 2021-03-31 06:07:11 -07:00
dstr.hpp clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
file-serializer.c clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
file-serializer.h clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
lexer.c clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
lexer.h clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
pipe-posix.c libobs/util: Retry pipe writes to avoid short-write failures 2020-02-24 12:29:54 +11:00
pipe-windows.c obs-ffmpeg: Add ability to debug ffmpeg-mux subprocess 2020-10-14 18:42:22 -07:00
pipe.h clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
platform-cocoa.m libobs: use clock_gettime_nsec_np() for macOS 2021-02-28 19:00:43 -08:00
platform-nix-dbus.c libobs/util: Split bus name from interface 2021-02-25 12:32:44 -08:00
platform-nix-portal.c libobs: Make portal inhibitor asynchronous 2021-09-23 07:35:47 -07:00
platform-nix.c libobs/util: Fix reading memory usage on Linux 2021-08-09 11:42:34 -07:00
platform-windows.c libobs/util: Fix rounding error with os_sleepto_ns() 2022-02-28 02:07:13 -08:00
platform.c libobs: Mark unused parameters 2021-05-08 14:12:54 -07:00
platform.h libobs/util: Remove old ifdefs 2021-08-27 08:12:53 -07:00
profiler.c libobs/util: Fix pthread mutex leaks 2021-08-23 22:57:10 -07:00
profiler.h clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
profiler.hpp clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
serializer.h clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
sse-intrin.h libobs/util: Simplify emmintrin.h wrapper macro 2021-10-10 19:12:45 -07:00
task.c libobs/util: Add task queue helper 2021-12-19 11:25:57 -08:00
task.h libobs/util: Add task queue helper 2021-12-19 11:25:57 -08:00
text-lookup.c clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
text-lookup.h clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
threading-posix.c libobs/util: Fix POSIX event bugs 2020-05-09 14:21:35 -07:00
threading-posix.h libobs/util: Various atomic improvements 2021-02-03 08:51:31 -08:00
threading-windows.c libobs/util: Improve SetThreadDescription usage 2021-08-30 22:33:17 -07:00
threading-windows.h libobs/util: Compiler barriers for ARM64 atomics 2021-03-07 21:11:32 -08:00
threading.h libobs/util: pthread_mutex_init_recursive helper 2021-08-23 22:09:08 -07:00
utf8.c libobs: Fix undefined behavior 2020-08-08 10:41:24 +02:00
utf8.h clang-format: Apply formatting 2019-06-23 23:49:10 -07:00
util.hpp libobs: Add move assignment operator for BPtr 2020-03-19 16:18:51 -07:00
util_uint64.h libobs: Simplify util_mul_div64 for x64 on Windows 2021-09-29 02:22:01 -07:00
util_uint128.h libobs/util: Fix undefined behavior and optimize util_mul64_64 2018-09-07 17:28:15 -07:00