From a0141dbe4f868413d78c94737846279124415479 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 3 Jan 2009 14:51:47 +0100 Subject: 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. --- src/pcm_utils.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/pcm_utils.c') 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); } /** -- cgit v1.2.3