From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Alan Young <consult.awy@gmail.com>, alsa-devel@alsa-project.org
Subject: Re: Overflow in calculating audio timestamp
Date: Fri, 3 Feb 2023 08:45:36 -0600 [thread overview]
Message-ID: <91a45f8e-11a6-f276-1ecf-eae2ce625c98@linux.intel.com> (raw)
In-Reply-To: <70ff4e3a-b171-131c-a039-4fc99aa4bbfc@gmail.com>
On 2/2/23 07:55, Alan Young wrote:
> sound/core/pcm_lib.c:update_audio_tstamp() contains the following
> calculation:
>
> audio_nsecs = div_u64(audio_frames * 1000000000LL,
> runtime->rate);
>
> This will result in a 64-bit overflow after 4.4 days at 48000 Hz, or 1.1
> days at 192000.
>
> Are you interested in a patch to improve this?
>
> The same calculation occurs in a couple of other places.
It's clearly unintentional, thanks for reporting this.
I added this in 2012 in
4eeaaeaea1ce ("ALSA: core: add hooks for audio timestamps")
and probably assumed the use of 64-bit was good enough. You just proved
me wrong!
prev parent reply other threads:[~2023-02-03 15:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 13:55 Overflow in calculating audio timestamp Alan Young
2023-02-03 0:34 ` Takashi Sakamoto
2023-02-03 16:11 ` Alan Young
2023-02-03 18:02 ` Jaroslav Kysela
2023-02-04 0:54 ` Pierre-Louis Bossart
2023-02-06 15:25 ` Alan Young
2023-02-04 9:11 ` Alan Young
2023-02-04 15:40 ` Jaroslav Kysela
2023-02-06 8:52 ` Alan Young
2023-02-06 9:17 ` Jaroslav Kysela
2023-02-03 14:45 ` Pierre-Louis Bossart [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=91a45f8e-11a6-f276-1ecf-eae2ce625c98@linux.intel.com \
--to=pierre-louis.bossart@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=consult.awy@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox