Browse Source

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.
Ka Ho Ng 5 years ago
parent
commit
b1504b0278
1 changed files with 4 additions and 4 deletions
  1. 4 4
      plugins/oss-audio/oss-input.c

+ 4 - 4
plugins/oss-audio/oss-input.c

@@ -29,7 +29,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #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) {