From b1504b027848ff8459553f8ca3a1ef8e0d8f307a Mon Sep 17 00:00:00 2001 From: Ka Ho Ng Date: Fri, 31 Jul 2020 01:59:31 +0800 Subject: [PATCH] oss-audio: Use util_mul_div64() to do time scaling util_mul_div64() is a new helper to do scaling. This commit sweeps the oss-audio plugin code to generalize the way of doing scaling. --- plugins/oss-audio/oss-input.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/oss-audio/oss-input.c b/plugins/oss-audio/oss-input.c index 30e85a473..699cf9ec0 100644 --- a/plugins/oss-audio/oss-input.c +++ b/plugins/oss-audio/oss-input.c @@ -29,7 +29,7 @@ along with this program. If not, see . #define blog(level, msg, ...) blog(level, "oss-audio: " msg, ##__VA_ARGS__) -#define NSEC_PER_SEC 1000000000LL +#define NSEC_PER_SEC 1000000000ULL #define OSS_MAX_CHANNELS 8 @@ -255,9 +255,9 @@ static void *oss_reader_thr(void *vptr) oss_channels_to_obs_speakers(handle->channels); out.samples_per_sec = handle->rate; out.frames = nbytes / framesize; - out.timestamp = - os_gettime_ns() - - ((out.frames * NSEC_PER_SEC) / handle->rate); + out.timestamp = os_gettime_ns() - + util_mul_div64(out.frames, NSEC_PER_SEC, + handle->rate); obs_source_output_audio(handle->source, &out); } if (fds[1].revents & POLLIN) {