Fix rt-safe PRNG (seed once, not every call)

This commit is contained in:
Robin Gareus 2021-08-15 15:24:23 +02:00
parent 76a01bab63
commit e4d1d82ea7
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
2 changed files with 6 additions and 5 deletions

View file

@ -8,7 +8,6 @@
#include "pbd/basename.h"
#include "pbd/compose.h"
#include "pbd/failed_constructor.h"
#include "pbd/pcg_rand.h"
#include "temporal/tempo.h"
@ -990,8 +989,7 @@ TriggerBox::set_next_trigger (size_t current)
}
int which_follow_action;
PCGRand pcg;
int r = pcg.rand (0, 101);
int r = _pcg.rand (0, 101);
if (r <= all_triggers[current]->follow_action_probability()) {
which_follow_action = 0;
@ -1079,7 +1077,7 @@ TriggerBox::set_next_trigger (size_t current)
case Trigger::AnyTrigger:
while (true) {
n = pcg.rand (0, all_triggers.size() + 1);
n = _pcg.rand (0, all_triggers.size() + 1);
if (!all_triggers[n]->region()) {
continue;
}
@ -1093,7 +1091,7 @@ TriggerBox::set_next_trigger (size_t current)
case Trigger::OtherTrigger:
while (true) {
n = pcg.rand (0, all_triggers.size() + 1);
n = _pcg.rand (0, all_triggers.size() + 1);
if ((size_t) n == current) {
continue;
}