plugins/elements/gstfakesrc.c: Use g_random_int_range(), since it produces better random numbers in a range than almo...

Original commit message from CVS:
* plugins/elements/gstfakesrc.c:
Use g_random_int_range(), since it produces better random
numbers in a range than almost-correct floating point code.
This commit is contained in:
David Schleef 2006-12-21 09:37:56 +00:00
parent c9fbb589a0
commit 05e2413d3e
2 changed files with 8 additions and 5 deletions

View file

@ -1,3 +1,9 @@
2006-12-21 David Schleef <ds@schleef.org>
* plugins/elements/gstfakesrc.c:
Use g_random_int_range(), since it produces better random
numbers in a range than almost-correct floating point code.
2006-12-21 Stefan Kost <ensonic@users.sf.net>
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),

View file

@ -596,7 +596,7 @@ gst_fake_src_prepare_buffer (GstFakeSrc * src, GstBuffer * buf)
guint8 *ptr = GST_BUFFER_DATA (buf);
for (i = GST_BUFFER_SIZE (buf); i; i--) {
*ptr++ = (gint8) ((255.0) * rand () / (RAND_MAX));
*ptr++ = g_random_int_range (0, 256);
}
break;
}
@ -660,10 +660,7 @@ gst_fake_src_get_size (GstFakeSrc * src)
size = src->sizemax;
break;
case FAKE_SRC_SIZETYPE_RANDOM:
size =
src->sizemin +
(guint8) (((gfloat) src->sizemax) * rand () / (RAND_MAX +
(gfloat) src->sizemin));
size = g_random_int_range (src->sizemin, src->sizemax);
break;
case FAKE_SRC_SIZETYPE_EMPTY:
default: