diff options
author | Max Kellermann <max@duempel.org> | 2009-01-03 14:51:47 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-01-03 14:51:47 +0100 |
commit | 962f2407d2a3579b7125f937d93d04ccbeb9a453 (patch) | |
tree | e4e2fd55c02e53f94b3d63be8b8d2f714428f0b9 /src/pcm_utils.c | |
parent | 8ebb3196a854d7e870bbbe904b534641df7d5f89 (diff) | |
download | mpd-962f2407d2a3579b7125f937d93d04ccbeb9a453.tar.gz mpd-962f2407d2a3579b7125f937d93d04ccbeb9a453.tar.xz mpd-962f2407d2a3579b7125f937d93d04ccbeb9a453.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 'src/pcm_utils.c')
-rw-r--r-- | src/pcm_utils.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/pcm_utils.c b/src/pcm_utils.c index 46c5f2884..a7e7a3990 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 "utils.h" #include "conf.h" #include "audio_format.h" @@ -33,7 +34,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); } /** |