diff options
-rw-r--r-- | gtk2_ardour/ardour_ui.cc | 22 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui.h | 7 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui2.cc | 8 | ||||
-rw-r--r-- | gtk2_ardour/editor.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/editor_canvas_events.cc | 4 | ||||
-rw-r--r-- | gtk2_ardour/editor_mouse.cc | 8 | ||||
-rw-r--r-- | libs/ardour/ardour/ardour.h | 9 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 2 | ||||
-rw-r--r-- | libs/ardour/globals.cc | 6 | ||||
-rw-r--r-- | libs/ardour/session_butler.cc | 35 |
10 files changed, 47 insertions, 56 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 4e474661cc..16dd93f771 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -63,6 +63,8 @@ #include <ardour/port.h> #include <ardour/audio_track.h> +typedef uint64_t microseconds_t; + #include "actions.h" #include "ardour_ui.h" #include "public_editor.h" @@ -195,8 +197,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[]) last_speed_displayed = -1.0f; ignore_dual_punch = false; - last_configure_time.tv_sec = 0; - last_configure_time.tv_usec = 0; + last_configure_time= 0; shuttle_grabbed = false; shuttle_fract = 0.0; @@ -205,8 +206,9 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[]) shuttle_style_menu = 0; shuttle_unit_menu = 0; - gettimeofday (&last_peak_grab, 0); - gettimeofday (&last_shuttle_request, 0); + // We do not have jack linked in yet so; + + last_shuttle_request = last_peak_grab = 0; // get_microseconds(); ARDOUR::Diskstream::DiskOverrun.connect (mem_fun(*this, &ARDOUR_UI::disk_overrun_handler)); ARDOUR::Diskstream::DiskUnderrun.connect (mem_fun(*this, &ARDOUR_UI::disk_underrun_handler)); @@ -398,21 +400,15 @@ ARDOUR_UI::pop_back_splash () gint ARDOUR_UI::configure_timeout () { - struct timeval now; - struct timeval diff; - - if (last_configure_time.tv_sec == 0 && last_configure_time.tv_usec == 0) { + if (last_configure_time == 0) { /* no configure events yet */ return TRUE; } - gettimeofday (&now, 0); - timersub (&now, &last_configure_time, &diff); - /* force a gap of 0.5 seconds since the last configure event */ - if (diff.tv_sec == 0 && diff.tv_usec < 500000) { + if (get_microseconds() - last_configure_time < 500000) { return TRUE; } else { have_configure_timeout = false; @@ -425,7 +421,7 @@ gboolean ARDOUR_UI::configure_handler (GdkEventConfigure* conf) { if (have_configure_timeout) { - gettimeofday (&last_configure_time, 0); + last_configure_time = get_microseconds(); } else { Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::configure_timeout), 100); have_configure_timeout = true; diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 70ce687769..33e7217638 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -58,6 +58,7 @@ #include <gtkmm2ext/bindable_button.h> #include <ardour/ardour.h> #include <ardour/session.h> +#include <ardour/types.h> #include "audio_clock.h" #include "ardour_dialog.h" @@ -643,11 +644,11 @@ class ARDOUR_UI : public Gtkmm2ext::UI void flush_trash (); bool have_configure_timeout; - struct timeval last_configure_time; + ARDOUR::microseconds_t last_configure_time; gint configure_timeout (); - struct timeval last_peak_grab; - struct timeval last_shuttle_request; + ARDOUR::microseconds_t last_peak_grab; + ARDOUR::microseconds_t last_shuttle_request; bool have_disk_speed_dialog_displayed; void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*); diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc index 8a29e64c6d..50fe0e21db 100644 --- a/gtk2_ardour/ardour_ui2.cc +++ b/gtk2_ardour/ardour_ui2.cc @@ -755,17 +755,13 @@ ARDOUR_UI::set_shuttle_fract (double f) void ARDOUR_UI::use_shuttle_fract (bool force) { - struct timeval now; - struct timeval diff; + microseconds_t now = get_microseconds(); /* do not attempt to submit a motion-driven transport speed request more than once per process cycle. */ - gettimeofday (&now, 0); - timersub (&now, &last_shuttle_request, &diff); - - if (!force && (diff.tv_usec + (diff.tv_sec * 1000000)) < engine->usecs_per_cycle()) { + if (!force && (last_shuttle_request - now) < engine->usecs_per_cycle()) { return; } diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 91677acb1f..e521c51a2d 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -2062,7 +2062,7 @@ public: /* tracking step changes of track height */ TimeAxisView* current_stepping_trackview; - struct timeval last_track_height_step_timestamp; + ARDOUR::microseconds_t last_track_height_step_timestamp; gint track_height_step_timeout(); sigc::connection step_timeout; diff --git a/gtk2_ardour/editor_canvas_events.cc b/gtk2_ardour/editor_canvas_events.cc index 00ea97a5f3..4615fda5f4 100644 --- a/gtk2_ardour/editor_canvas_events.cc +++ b/gtk2_ardour/editor_canvas_events.cc @@ -90,7 +90,7 @@ Editor::track_canvas_scroll (GdkEventScroll* ev) return false; } } - gettimeofday (&last_track_height_step_timestamp, 0); + last_track_height_step_timestamp = get_microseconds(); current_stepping_trackview->step_height (true); return true; } else { @@ -125,7 +125,7 @@ Editor::track_canvas_scroll (GdkEventScroll* ev) return false; } } - gettimeofday (&last_track_height_step_timestamp, 0); + last_track_height_step_timestamp = get_microseconds(); current_stepping_trackview->step_height (false); return true; } else { diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 8354e41f5f..721dfb1e94 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -5392,13 +5392,7 @@ Editor::mouse_brush_insert_region (RegionView* rv, nframes_t pos) gint Editor::track_height_step_timeout () { - struct timeval now; - struct timeval delta; - - gettimeofday (&now, 0); - timersub (&now, &last_track_height_step_timestamp, &delta); - - if (delta.tv_sec * 1000000 + delta.tv_usec > 250000) { /* milliseconds */ + if (get_microseconds() - last_track_height_step_timestamp < 250000) { current_stepping_trackview = 0; return false; } diff --git a/libs/ardour/ardour/ardour.h b/libs/ardour/ardour/ardour.h index 22e79e1c12..cab4601d07 100644 --- a/libs/ardour/ardour/ardour.h +++ b/libs/ardour/ardour/ardour.h @@ -32,6 +32,8 @@ #include <ardour/configuration.h> #include <ardour/types.h> +// #include <jack/jack.h> need this to inline jack_get_microseconds + namespace MIDI { class MachineControl; class Port; @@ -63,7 +65,12 @@ namespace ARDOUR { const layer_t max_layer = UCHAR_MAX; microseconds_t get_microseconds (); - +/* { + JACK has exported this functionality for a long time now + but inlining this causes problems + return (microseconds_t) jack_get_time(); + } +*/ Change new_change (); extern Change StartChanged; diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index ea89ab84ec..e5750e8a5b 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -889,7 +889,7 @@ class Session : public PBD::StatefulDestructible void reset_playback_load_min (); void reset_capture_load_min (); - float read_data_rate () const; + float read_data_rate () const; // in usec float write_data_rate () const; /* ranges */ diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index c5f96d6764..916f4cd38e 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -383,11 +383,7 @@ ARDOUR::cleanup () microseconds_t ARDOUR::get_microseconds () { - /* XXX need JACK to export its functionality */ - - struct timeval now; - gettimeofday (&now, 0); - return now.tv_sec * 1000000ULL + now.tv_usec; + return (microseconds_t) jack_get_time (); } ARDOUR::Change diff --git a/libs/ardour/session_butler.cc b/libs/ardour/session_butler.cc index 2ac06e57dd..92ebc50580 100644 --- a/libs/ardour/session_butler.cc +++ b/libs/ardour/session_butler.cc @@ -166,7 +166,8 @@ Session::butler_thread_work () uint32_t err = 0; int32_t bytes; bool compute_io; - struct timeval begin, end; + microseconds_t begin, end; + struct pollfd pfd[1]; bool disk_work_outstanding = false; DiskstreamList::iterator i; @@ -243,7 +244,7 @@ Session::butler_thread_work () bytes = 0; compute_io = true; - gettimeofday (&begin, 0); + begin = get_microseconds(); boost::shared_ptr<DiskstreamList> dsl = diskstreams.reader (); @@ -290,17 +291,16 @@ Session::butler_thread_work () } if (compute_io) { - gettimeofday (&end, 0); - - double b = begin.tv_sec + (begin.tv_usec/1000000.0); - double e = end.tv_sec + (end.tv_usec / 1000000.0); - - _read_data_rate = bytes / (e - b); + end = get_microseconds(); + if(end-begin > 0) { + _read_data_rate = (float) bytes / (float) (end - begin); + } else { _read_data_rate = 0; // infinity better + } } bytes = 0; compute_io = true; - gettimeofday (&begin, 0); + begin = get_microseconds(); for (i = dsl->begin(); !transport_work_requested() && butler_should_run && i != dsl->end(); ++i) { // cerr << "write behind for " << (*i)->name () << endl; @@ -344,12 +344,13 @@ Session::butler_thread_work () } if (compute_io) { - gettimeofday (&end, 0); - - double b = begin.tv_sec + (begin.tv_usec/1000000.0); - double e = end.tv_sec + (end.tv_usec / 1000000.0); - - _write_data_rate = bytes / (e - b); + // there are no apparent users for this calculation? + end = get_microseconds(); + if(end-begin > 0) { + _write_data_rate = (float) bytes / (float) (end - begin); + } else { + _write_data_rate = 0; // Well, infinity would be better + } } if (!disk_work_outstanding) { @@ -416,7 +417,7 @@ Session::read_data_rate () const /* disk i/o in excess of 10000MB/sec indicate the buffer cache in action. ignore it. */ - return _read_data_rate > 10485760000.0f ? 0.0f : _read_data_rate; + return _read_data_rate > 10485.7600000f ? 0.0f : _read_data_rate; } float @@ -425,7 +426,7 @@ Session::write_data_rate () const /* disk i/o in excess of 10000MB/sec indicate the buffer cache in action. ignore it. */ - return _write_data_rate > 10485760000.0f ? 0.0f : _write_data_rate; + return _write_data_rate > 10485.7600000f ? 0.0f : _write_data_rate; } uint32_t |