libobs: Implement and use better scaling function for 64-bit integers
As os_gettime_ns() gets large the current scaling methods, mostly by casting to uint64_t, may lead to numerical overflows. Sweep the code and use util_mul_div64() where applicable. Signed-off-by: Hans Petter Selasky <hps@selasky.org>
This commit is contained in:
parent
47058d9b69
commit
0e4ea14ba1
22 changed files with 97 additions and 57 deletions
|
|
@ -8,6 +8,7 @@
|
|||
#include <util/windows/WinHandle.hpp>
|
||||
#include <util/windows/CoTaskMemPtr.hpp>
|
||||
#include <util/threading.h>
|
||||
#include <util/util_uint64.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
@ -464,8 +465,8 @@ bool WASAPISource::ProcessCaptureData()
|
|||
data.timestamp = useDeviceTiming ? ts * 100 : os_gettime_ns();
|
||||
|
||||
if (!useDeviceTiming)
|
||||
data.timestamp -= (uint64_t)frames * 1000000000ULL /
|
||||
(uint64_t)sampleRate;
|
||||
data.timestamp -= util_mul_div64(frames, 1000000000ULL,
|
||||
sampleRate);
|
||||
|
||||
obs_source_output_audio(source, &data);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue