Remove some more unsafe calls to gettimeofday
It isn't even rt-safe, prefer clock_gettime whenever possible.
This commit is contained in:
@@ -1777,8 +1777,8 @@ private:
|
||||
void mmc_shuttle (MIDI::MachineControl &mmc, float speed, bool forw);
|
||||
void mmc_record_enable (MIDI::MachineControl &mmc, size_t track, bool enabled);
|
||||
|
||||
struct timeval last_mmc_step;
|
||||
double step_speed;
|
||||
int64_t _last_mmc_step;
|
||||
double step_speed;
|
||||
|
||||
typedef std::function<bool()> MidiTimeoutCallback;
|
||||
typedef std::list<MidiTimeoutCallback> MidiTimeoutList;
|
||||
|
||||
@@ -207,21 +207,14 @@ Session::mmc_step (MIDI::MachineControl &/*mmc*/, int steps)
|
||||
return;
|
||||
}
|
||||
|
||||
struct timeval now;
|
||||
struct timeval diff = { 0, 0 };
|
||||
int64_t now = g_get_monotonic_time ();
|
||||
int64_t diff = now - _last_mmc_step;
|
||||
|
||||
gettimeofday (&now, 0);
|
||||
|
||||
timersub (&now, &last_mmc_step, &diff);
|
||||
|
||||
gettimeofday (&now, 0);
|
||||
timersub (&now, &last_mmc_step, &diff);
|
||||
|
||||
if (last_mmc_step.tv_sec != 0 && (diff.tv_usec + (diff.tv_sec * 1000000)) < _engine.usecs_per_cycle()) {
|
||||
if (_last_mmc_step != 0 && diff < _engine.usecs_per_cycle()) {
|
||||
return;
|
||||
}
|
||||
|
||||
double diff_secs = diff.tv_sec + (diff.tv_usec / 1000000.0);
|
||||
double diff_secs = diff * 1e-6;
|
||||
double cur_speed = (((steps * 0.5) * timecode_frames_per_second()) / diff_secs) / timecode_frames_per_second();
|
||||
|
||||
if (_transport_fsm->transport_speed() == 0 || cur_speed * _transport_fsm->transport_speed() < 0) {
|
||||
@@ -243,7 +236,7 @@ Session::mmc_step (MIDI::MachineControl &/*mmc*/, int steps)
|
||||
#endif
|
||||
|
||||
request_transport_speed_nonzero (step_speed);
|
||||
last_mmc_step = now;
|
||||
_last_mmc_step = now;
|
||||
|
||||
if (!step_queued) {
|
||||
if (midi_control_ui) {
|
||||
@@ -654,15 +647,9 @@ Session::send_immediate_mmc (MachineControlCommand c)
|
||||
bool
|
||||
Session::mmc_step_timeout ()
|
||||
{
|
||||
struct timeval now;
|
||||
struct timeval diff;
|
||||
double diff_usecs;
|
||||
gettimeofday (&now, 0);
|
||||
int64_t diff_usecs = g_get_monotonic_time () - _last_mmc_step;
|
||||
|
||||
timersub (&now, &last_mmc_step, &diff);
|
||||
diff_usecs = diff.tv_sec * 1000000 + diff.tv_usec;
|
||||
|
||||
if (diff_usecs > 1000000.0 || fabs (_transport_fsm->transport_speed()) < 0.0000001) {
|
||||
if (diff_usecs > 1000000 || fabs (_transport_fsm->transport_speed()) < 0.0000001) {
|
||||
/* too long or too slow, stop transport */
|
||||
request_stop ();
|
||||
step_queued = false;
|
||||
|
||||
@@ -179,7 +179,7 @@ Session::pre_engine_init (string fullpath)
|
||||
definition.
|
||||
*/
|
||||
|
||||
timerclear (&last_mmc_step);
|
||||
_last_mmc_step = 0;
|
||||
_processing_prohibited.store (0);
|
||||
_record_status.store (Disabled);
|
||||
_playback_load.store (100);
|
||||
|
||||
Reference in New Issue
Block a user