13
0

dramatically reduce ShuttleControl CPU usage

This commit is contained in:
Robin Gareus 2015-03-10 10:52:44 +01:00
parent 3547540f98
commit 2d20bcab4a
3 changed files with 13 additions and 16 deletions

View File

@ -1141,7 +1141,8 @@ ARDOUR_UI::every_second ()
void
ARDOUR_UI::every_point_one_seconds ()
{
shuttle_box->update_speed_display ();
// TODO get rid of this..
// ShuttleControl is updated directly via TransportStateChange signal
}
void

View File

@ -132,6 +132,15 @@ ShuttleControl::map_transport_state ()
{
float speed = _session->transport_speed ();
if ( (fabsf( speed - last_speed_displayed) < 0.005f) // dead-zone
&& !( speed == 1.f && last_speed_displayed != 1.f)
&& !( speed == 0.f && last_speed_displayed != 0.f)
)
{
return; // nothing to see here, move along.
}
// Q: is there a good reason why we re-calculate this every time?
if (fabs(speed) <= (2*DBL_EPSILON)) {
shuttle_fract = 0;
} else {
@ -232,6 +241,7 @@ void
ShuttleControl::set_shuttle_max_speed (float speed)
{
shuttle_max_speed = speed;
last_speed_displayed = -99999999;
}
bool
@ -637,19 +647,6 @@ ShuttleControl::set_shuttle_units (ShuttleUnits s)
Config->set_shuttle_units (s);
}
void
ShuttleControl::update_speed_display ()
{
const float speed = _session->transport_speed();
if ( (fabsf( speed - last_speed_displayed) > 0.009f) // dead-zone just below 1%, except..
|| ( speed == 1.f && last_speed_displayed != 1.f)
|| ( speed == 0.f && last_speed_displayed != 0.f)
)
{
queue_draw ();
}
}
ShuttleControl::ShuttleControllable::ShuttleControllable (ShuttleControl& s)
: PBD::Controllable (X_("Shuttle"))
, sc (s)

View File

@ -39,8 +39,7 @@ class ShuttleControl : public CairoWidget, public ARDOUR::SessionHandlePtr
~ShuttleControl ();
void map_transport_state ();
void update_speed_display ();
void set_shuttle_fract (double, bool zero_ok = false);
void set_shuttle_fract (double, bool zero_ok = false);
double get_shuttle_fract () const { return shuttle_fract; }
void set_session (ARDOUR::Session*);