MFC: r207330, r207620

- Remove dead code.  Calculated greatest common divisor was not used at all.
- Prefer u_int32_t over unsigned int to make its intention more clearer.
- Move the function to a header file and make it a static inline function.
This commit is contained in:
Jung-uk Kim 2010-05-10 19:21:50 +00:00
parent 88b965f3c8
commit c4879659eb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/stable/8/; revision=207879
2 changed files with 11 additions and 25 deletions

View File

@ -565,30 +565,6 @@ sndbuf_updateprevtotal(struct snd_dbuf *b)
b->prev_total = b->total;
}
unsigned int
snd_xbytes(unsigned int v, unsigned int from, unsigned int to)
{
unsigned int w, x, y;
if (from == to)
return v;
if (from == 0 || to == 0 || v == 0)
return 0;
x = from;
y = to;
while (y != 0) {
w = x % y;
x = y;
y = w;
}
from /= x;
to /= x;
return (unsigned int)(((u_int64_t)v * to) / from);
}
unsigned int
sndbuf_xbytes(unsigned int v, struct snd_dbuf *from, struct snd_dbuf *to)
{

View File

@ -111,7 +111,6 @@ u_int64_t sndbuf_getblocks(struct snd_dbuf *b);
u_int64_t sndbuf_getprevblocks(struct snd_dbuf *b);
u_int64_t sndbuf_gettotal(struct snd_dbuf *b);
u_int64_t sndbuf_getprevtotal(struct snd_dbuf *b);
unsigned int snd_xbytes(unsigned int v, unsigned int from, unsigned int to);
unsigned int sndbuf_xbytes(unsigned int v, struct snd_dbuf *from, struct snd_dbuf *to);
u_int8_t sndbuf_zerodata(u_int32_t fmt);
void sndbuf_updateprevtotal(struct snd_dbuf *b);
@ -132,3 +131,14 @@ void sndbuf_dmabounce(struct snd_dbuf *b);
#ifdef OSSV4_EXPERIMENT
void sndbuf_getpeaks(struct snd_dbuf *b, int *lp, int *rp);
#endif
static inline u_int32_t
snd_xbytes(u_int32_t v, u_int32_t from, u_int32_t to)
{
if (from == to)
return (v);
if (from == 0)
return (0);
return ((u_int64_t)v * to / from);
}