diff options
author | Georg Chini <georg@chini.tk> | 2022-05-13 15:05:36 +0200 |
---|---|---|
committer | PulseAudio Marge Bot <pulseaudio-maintainers@lists.freedesktop.org> | 2022-05-17 11:09:29 +0000 |
commit | 325108e532e770a7b5951b84acb55ff95a568535 (patch) | |
tree | 6c55b1c50eddc1a1dbdf762b6973962b3ecf4623 /src | |
parent | 9811c84a54f2426e2b1898cce209720777bdbd2f (diff) | |
download | pulseaudio-325108e532e770a7b5951b84acb55ff95a568535.tar.gz |
time-smoother-2: Fix integer type problem
The byte_count argument of pa_smoother_2_get_delay() was defined as size_t
which lead to overflow problems on 32-bit architectures. Changed type
to uint_64.
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/700>
Diffstat (limited to 'src')
-rw-r--r-- | src/pulse/stream.c | 4 | ||||
-rw-r--r-- | src/pulsecore/time-smoother_2.c | 2 | ||||
-rw-r--r-- | src/pulsecore/time-smoother_2.h | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/src/pulse/stream.c b/src/pulse/stream.c index 42d833225..0aa627396 100644 --- a/src/pulse/stream.c +++ b/src/pulse/stream.c @@ -1816,8 +1816,8 @@ static pa_usec_t calc_time(const pa_stream *s, bool ignore_transport) { } #ifdef USE_SMOOTHER_2 -static inline size_t calc_bytes(pa_stream *s, bool ignore_transport) { - return pa_usec_to_bytes(calc_time(s, ignore_transport), &s->sample_spec); +static inline uint64_t calc_bytes(pa_stream *s, bool ignore_transport) { + return (uint64_t)(calc_time(s, ignore_transport) * s->sample_spec.rate / PA_USEC_PER_SEC * pa_frame_size(&s->sample_spec)); } #endif diff --git a/src/pulsecore/time-smoother_2.c b/src/pulsecore/time-smoother_2.c index 8f4447e0c..e14b52f72 100644 --- a/src/pulsecore/time-smoother_2.c +++ b/src/pulsecore/time-smoother_2.c @@ -258,7 +258,7 @@ void pa_smoother_2_put(pa_smoother_2 *s, pa_usec_t time_stamp, int64_t byte_coun } /* Calculate the current latency. For a source, the sign must be inverted */ -int64_t pa_smoother_2_get_delay(pa_smoother_2 *s, pa_usec_t time_stamp, size_t byte_count) { +int64_t pa_smoother_2_get_delay(pa_smoother_2 *s, pa_usec_t time_stamp, uint64_t byte_count) { int64_t now, delay; pa_assert(s); diff --git a/src/pulsecore/time-smoother_2.h b/src/pulsecore/time-smoother_2.h index 57fc1e31c..67b3c4815 100644 --- a/src/pulsecore/time-smoother_2.h +++ b/src/pulsecore/time-smoother_2.h @@ -37,7 +37,7 @@ void pa_smoother_2_resume(pa_smoother_2 *s, pa_usec_t time_stamp); void pa_smoother_2_put(pa_smoother_2 *s, pa_usec_t time_stamp, int64_t byte_count); /* Calculate the current latency. For a source, the sign of the result must be inverted */ -int64_t pa_smoother_2_get_delay(pa_smoother_2 *s, pa_usec_t time_stamp, size_t byte_count); +int64_t pa_smoother_2_get_delay(pa_smoother_2 *s, pa_usec_t time_stamp, uint64_t byte_count); /* Convert system time since start to sound card time */ pa_usec_t pa_smoother_2_get(pa_smoother_2 *s, pa_usec_t time_stamp); /* Convert a time interval from sound card time to system time */ |