mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 14:54:56 +01:00
Remove some more unsafe calls to gettimeofday
It isn't even rt-safe, prefer clock_gettime whenever possible.
This commit is contained in:
parent
ecaeea94e5
commit
057b84dd77
3 changed files with 10 additions and 23 deletions
|
|
@ -1777,8 +1777,8 @@ private:
|
||||||
void mmc_shuttle (MIDI::MachineControl &mmc, float speed, bool forw);
|
void mmc_shuttle (MIDI::MachineControl &mmc, float speed, bool forw);
|
||||||
void mmc_record_enable (MIDI::MachineControl &mmc, size_t track, bool enabled);
|
void mmc_record_enable (MIDI::MachineControl &mmc, size_t track, bool enabled);
|
||||||
|
|
||||||
struct timeval last_mmc_step;
|
int64_t _last_mmc_step;
|
||||||
double step_speed;
|
double step_speed;
|
||||||
|
|
||||||
typedef std::function<bool()> MidiTimeoutCallback;
|
typedef std::function<bool()> MidiTimeoutCallback;
|
||||||
typedef std::list<MidiTimeoutCallback> MidiTimeoutList;
|
typedef std::list<MidiTimeoutCallback> MidiTimeoutList;
|
||||||
|
|
|
||||||
|
|
@ -207,21 +207,14 @@ Session::mmc_step (MIDI::MachineControl &/*mmc*/, int steps)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct timeval now;
|
int64_t now = g_get_monotonic_time ();
|
||||||
struct timeval diff = { 0, 0 };
|
int64_t diff = now - _last_mmc_step;
|
||||||
|
|
||||||
gettimeofday (&now, 0);
|
if (_last_mmc_step != 0 && diff < _engine.usecs_per_cycle()) {
|
||||||
|
|
||||||
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()) {
|
|
||||||
return;
|
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();
|
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) {
|
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
|
#endif
|
||||||
|
|
||||||
request_transport_speed_nonzero (step_speed);
|
request_transport_speed_nonzero (step_speed);
|
||||||
last_mmc_step = now;
|
_last_mmc_step = now;
|
||||||
|
|
||||||
if (!step_queued) {
|
if (!step_queued) {
|
||||||
if (midi_control_ui) {
|
if (midi_control_ui) {
|
||||||
|
|
@ -654,15 +647,9 @@ Session::send_immediate_mmc (MachineControlCommand c)
|
||||||
bool
|
bool
|
||||||
Session::mmc_step_timeout ()
|
Session::mmc_step_timeout ()
|
||||||
{
|
{
|
||||||
struct timeval now;
|
int64_t diff_usecs = g_get_monotonic_time () - _last_mmc_step;
|
||||||
struct timeval diff;
|
|
||||||
double diff_usecs;
|
|
||||||
gettimeofday (&now, 0);
|
|
||||||
|
|
||||||
timersub (&now, &last_mmc_step, &diff);
|
if (diff_usecs > 1000000 || fabs (_transport_fsm->transport_speed()) < 0.0000001) {
|
||||||
diff_usecs = diff.tv_sec * 1000000 + diff.tv_usec;
|
|
||||||
|
|
||||||
if (diff_usecs > 1000000.0 || fabs (_transport_fsm->transport_speed()) < 0.0000001) {
|
|
||||||
/* too long or too slow, stop transport */
|
/* too long or too slow, stop transport */
|
||||||
request_stop ();
|
request_stop ();
|
||||||
step_queued = false;
|
step_queued = false;
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,7 @@ Session::pre_engine_init (string fullpath)
|
||||||
definition.
|
definition.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
timerclear (&last_mmc_step);
|
_last_mmc_step = 0;
|
||||||
_processing_prohibited.store (0);
|
_processing_prohibited.store (0);
|
||||||
_record_status.store (Disabled);
|
_record_status.store (Disabled);
|
||||||
_playback_load.store (100);
|
_playback_load.store (100);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue