Dear Marcus,
Thanks for pointing out, I've corrected it to std::max.
It still doesn't seem to produce correct output when the d_iFactor changes on the fly.
BTW this flow graph consists of other built-in blocks like Low Pass Filter, Signal Source etc, whose outputs also depends on the instantaneous Sample Rate (samp_rate). If one of these built-in blocks doesn't work well when samp_rate changes on the fly, then that could cause the flow graph to produce wrong result too.
My main concern is whether set_output_multiple() and set_min_noutput_items() works on the fly in general.
As your answer is yes to both, then I think that is good enough for this thread.
The general_work() is called repeatedly and problematically only if it return 0 and consume 0. With the set_min_noutput_items() works on the fly, this problem doesn't happen anymore. Now the problem is the incorrect output when the d_iFactor changes on the fly.
Meanwhile, as you had advised, I had tried to see the parameters that forecast() and general_work() are called with. Refer below verbose message.
When the flow chart started, the initial values are samp_rate=32k, change_rate=64; hence d_iFactor = 32k/64 = 500.
At line 24 the samp_rate is changed to 64k on the fly by the user. So now d_iFactor = 64k/64 = 1000.
Every parameters and return values seem to be correct, but the flow graph output becomes wrong after line 24.
1 forecast(): ninput_items_required[0] is set to 16 while noutput_items is 8000 , d_iFactor is 500
2 general_work(): consumed 16 at port 0, noutput_items is 8000 , d_iFactor is 500
3 forecast(): ninput_items_required[0] is set to 16 while noutput_items is 8000 , d_iFactor is 500
4 general_work(): consumed 16 at port 0, noutput_items is 8000 , d_iFactor is 500
5 forecast(): ninput_items_required[0] is set to 16 while noutput_items is 8000 , d_iFactor is 500
6 general_work(): consumed 16 at port 0, noutput_items is 8000 , d_iFactor is 500
7 forecast(): ninput_items_required[0] is set to 16 while noutput_items is 8000 , d_iFactor is 500
8 general_work(): consumed 16 at port 0, noutput_items is 8000 , d_iFactor is 500
9 forecast(): ninput_items_required[0] is set to 16 while noutput_items is 8000 , d_iFactor is 500
10 general_work(): consumed 16 at port 0, noutput_items is 8000 , d_iFactor is 500
11 forecast(): ninput_items_required[0] is set to 16 while noutput_items is 8000 , d_iFactor is 500
12 general_work(): consumed 16 at port 0, noutput_items is 8000 , d_iFactor is 500
13 forecast(): ninput_items_required[0] is set to 16 while noutput_items is 8000 , d_iFactor is 500
14 general_work(): consumed 16 at port 0, noutput_items is 8000 , d_iFactor is 500
15 forecast(): ninput_items_required[0] is set to 16 while noutput_items is 8000 , d_iFactor is 500
16 general_work(): consumed 16 at port 0, noutput_items is 8000 , d_iFactor is 500
17 forecast(): ninput_items_required[0] is set to 16 while noutput_items is 8000 , d_iFactor is 500
18 general_work(): consumed 16 at port 0, noutput_items is 8000 , d_iFactor is 500
19 forecast(): ninput_items_required[0] is set to 16 while noutput_items is 8000 , d_iFactor is 500
20 general_work(): consumed 16 at port 0, noutput_items is 8000 , d_iFactor is 500
21 forecast(): ninput_items_required[0] is set to 16 while noutput_items is 8000 , d_iFactor is 500
22 general_work(): consumed 16 at port 0, noutput_items is 8000 , d_iFactor is 500
23 forecast(): ninput_items_required[0] is set to 16 while noutput_items is 8000 , d_iFactor is 500
24 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
25 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
26 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
27 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
28 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
29 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
30 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
31 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
32 forecast(): ninput_items_required[0] is set to 4 while noutput_items is 4000 , d_iFactor is 1000
33 forecast(): ninput_items_required[0] is set to 2 while noutput_items is 2000 , d_iFactor is 1000
34 forecast(): ninput_items_required[0] is set to 1 while noutput_items is 1000 , d_iFactor is 1000
35 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
36 forecast(): ninput_items_required[0] is set to 4 while noutput_items is 4000 , d_iFactor is 1000
37 forecast(): ninput_items_required[0] is set to 2 while noutput_items is 2000 , d_iFactor is 1000
38 forecast(): ninput_items_required[0] is set to 1 while noutput_items is 1000 , d_iFactor is 1000
39 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
40 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
41 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
42 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
43 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
44 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
45 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
46 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
47 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
48 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
49 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
50 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
51 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
52 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
53 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
54 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
55 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
56 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
57 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
58 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
59 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
60 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
61 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
62 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
63 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
64 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
65 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
66 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
67 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
68 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
69 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
70 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
71 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
72 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
73 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
74 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
75 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
76 general_work(): consumed 8 at port 0, noutput_items is 8000 , d_iFactor is 1000
77 forecast(): ninput_items_required[0] is set to 8 while noutput_items is 8000 , d_iFactor is 1000
>>> Done