13
0

Rate limit progress-report, reduce excessive UI load

Session-archive or region analysis can produce excessive
progress callbacks (for each N samples read from disk).
This commit is contained in:
Robin Gareus 2023-05-18 18:58:40 +02:00
parent b3d3944451
commit d2b24e8689
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 9 additions and 3 deletions

View File

@ -23,19 +23,24 @@
#include "progress_reporter.h" #include "progress_reporter.h"
ProgressReporter::ProgressReporter () ProgressReporter::ProgressReporter ()
: _p (-1)
{ {
} }
ProgressReporter::~ProgressReporter () ProgressReporter::~ProgressReporter ()
{ {
} }
void void
ProgressReporter::set_overall_progress (float p) ProgressReporter::set_overall_progress (float p)
{ {
/* rate-limit, move in 0.2% steps */
int pt = 500 * p;
if (pt == _p && p > 0 && p < 1.0) {
return;
}
_p = pt;
update_progress_gui (p); update_progress_gui (p);
ARDOUR::GUIIdle (); ARDOUR::GUIIdle ();
} }

View File

@ -35,6 +35,7 @@ private:
* @param p Progress, from 0 to 1. * @param p Progress, from 0 to 1.
*/ */
virtual void update_progress_gui (float p) = 0; virtual void update_progress_gui (float p) = 0;
int _p;
}; };
#endif #endif