From: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
To: alsa-devel@alsa-project.org
Subject: Boundary calculation
Date: Mon, 16 Jul 2018 16:25:07 -0300 [thread overview]
Message-ID: <20180716192507.GA7151@localhost.localdomain> (raw)
Hello.
I can't get the tricky boundary calculation. Perhaps I'm
missing some obvious thing, or maybe it's really some
circumvent for a specific case that was not commented.
The current calculation for boundary is:
boundary = buffer_size;
while (boundary * 2 <= LONG_MAX - buffer_size)
boundary *= 2;
I've checked out some repositories, specially alsa-driver
in ALSA git, and I realized this calculation exists at
least since 2001. I guess it was Jaroslav who wrote.
Visualization of the calculation (B = buffer_size):
LONG_MAX
-------------------------------
\______________/ \__/
B * 4 B
\______/
B * 2
\__/
B
Why isn't a simpler calculation used instead? e.g.:
/* closest multiple of buffer size less or equal LONG_MAX */
boundary = LONG_MAX - LONG_MAX % buffer_size;
LONG_MAX
-------------------------------
\__________________________/
B * 6
Cheers!
pasquali
next reply other threads:[~2018-07-16 19:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-16 19:25 Ricardo Biehl Pasquali [this message]
2018-07-17 6:43 ` Boundary calculation Clemens Ladisch
2018-07-17 7:41 ` Takashi Iwai
-- strict thread matches above, loose matches on Subject: below --
2018-07-17 13:13 Ricardo Biehl Pasquali
2018-07-17 15:33 ` Clemens Ladisch
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=20180716192507.GA7151@localhost.localdomain \
--to=pasqualirb@gmail.com \
--cc=alsa-devel@alsa-project.org \
/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