Merged revisions 205599 via svnmerge from
authorDavid Vossel <dvossel@digium.com>
Thu, 9 Jul 2009 16:19:09 +0000 (16:19 +0000)
committerDavid Vossel <dvossel@digium.com>
Thu, 9 Jul 2009 16:19:09 +0000 (16:19 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r205599 | dvossel | 2009-07-09 11:18:09 -0500 (Thu, 09 Jul 2009) | 2 lines

  Changing ast_samp2tv to not use floating point.
........

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@205600 65c4cc65-6c06-0410-ace0-fbb531ad65f3

include/asterisk/time.h

index fa8006e..895d6df 100644 (file)
@@ -171,7 +171,7 @@ struct timeval ast_tv(ast_time_t sec, ast_suseconds_t usec),
 AST_INLINE_API(
 struct timeval ast_samp2tv(unsigned int _nsamp, unsigned int _rate),
 {
-       return ast_tv(_nsamp / _rate, (_nsamp % _rate) * (1000000 / (float) _rate));
+       return ast_tv(_nsamp / _rate, ((_nsamp % _rate) * (4000000 / _rate)) / 4); /* this calculation is accurate up to 32000Hz. */
 }
 )