Control audio recording using function probe

Hi, have an issue with controlling audio recording with function probe,
that measures signal level. A variable ‘muted’ is set to 0 or 1
on current rf power threshold, and depending on muted state recording
starting and stops. I suppose i would get continous file when level is
above the threshold, but in fact script generatates files every second
(file name contains current time), because filename variable updates
continously and wav sink opens new files or rewrites old ones. So glad
hear your suggestions to solve this task.