aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcm_utils.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-03 14:51:47 +0100
committerMax Kellermann <max@duempel.org>2009-01-13 23:09:19 +0100
commita0141dbe4f868413d78c94737846279124415479 (patch)
treee917b22e3eced7f9a8d9a4fa9e1121b899246a86 /src/pcm_utils.c
parentd93477d1369e55d76476952f30463461e47af443 (diff)
downloadmpd-a0141dbe4f868413d78c94737846279124415479.tar.gz
mpd-a0141dbe4f868413d78c94737846279124415479.tar.xz
mpd-a0141dbe4f868413d78c94737846279124415479.zip
pcm_utils: use the custom PRNG for volume dithering
Don't use libc's rand() function, because it is slow. Our own trivial linear congruential generator is good enough for dithering.
Diffstat (limited to '')
-rw-r--r--src/pcm_utils.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/pcm_utils.c b/src/pcm_utils.c
index f73df8aef..3ce9b5fd0 100644
--- a/src/pcm_utils.c
+++ b/src/pcm_utils.c
@@ -18,6 +18,7 @@
#include "pcm_utils.h"
#include "pcm_channels.h"
+#include "pcm_prng.h"
#include "log.h"
#include "utils.h"
#include "conf.h"
@@ -31,7 +32,12 @@
static inline int
pcm_dither(void)
{
- return (rand() & 511) - (rand() & 511);
+ static unsigned long state;
+ uint32_t r;
+
+ r = state = prng(state);
+
+ return (r & 511) - ((r >> 9) & 511);
}
/**