mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-23 15:16:25 +01:00
mike taht's patch to remove all use of gettimeofday() in favor of ARDOUR::get_microseconds() which now uses JACK's usec clock
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3355 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
e313838485
commit
5ea9dee73b
10 changed files with 47 additions and 56 deletions
|
|
@ -63,6 +63,8 @@
|
||||||
#include <ardour/port.h>
|
#include <ardour/port.h>
|
||||||
#include <ardour/audio_track.h>
|
#include <ardour/audio_track.h>
|
||||||
|
|
||||||
|
typedef uint64_t microseconds_t;
|
||||||
|
|
||||||
#include "actions.h"
|
#include "actions.h"
|
||||||
#include "ardour_ui.h"
|
#include "ardour_ui.h"
|
||||||
#include "public_editor.h"
|
#include "public_editor.h"
|
||||||
|
|
@ -195,8 +197,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[])
|
||||||
last_speed_displayed = -1.0f;
|
last_speed_displayed = -1.0f;
|
||||||
ignore_dual_punch = false;
|
ignore_dual_punch = false;
|
||||||
|
|
||||||
last_configure_time.tv_sec = 0;
|
last_configure_time= 0;
|
||||||
last_configure_time.tv_usec = 0;
|
|
||||||
|
|
||||||
shuttle_grabbed = false;
|
shuttle_grabbed = false;
|
||||||
shuttle_fract = 0.0;
|
shuttle_fract = 0.0;
|
||||||
|
|
@ -205,8 +206,9 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[])
|
||||||
shuttle_style_menu = 0;
|
shuttle_style_menu = 0;
|
||||||
shuttle_unit_menu = 0;
|
shuttle_unit_menu = 0;
|
||||||
|
|
||||||
gettimeofday (&last_peak_grab, 0);
|
// We do not have jack linked in yet so;
|
||||||
gettimeofday (&last_shuttle_request, 0);
|
|
||||||
|
last_shuttle_request = last_peak_grab = 0; // get_microseconds();
|
||||||
|
|
||||||
ARDOUR::Diskstream::DiskOverrun.connect (mem_fun(*this, &ARDOUR_UI::disk_overrun_handler));
|
ARDOUR::Diskstream::DiskOverrun.connect (mem_fun(*this, &ARDOUR_UI::disk_overrun_handler));
|
||||||
ARDOUR::Diskstream::DiskUnderrun.connect (mem_fun(*this, &ARDOUR_UI::disk_underrun_handler));
|
ARDOUR::Diskstream::DiskUnderrun.connect (mem_fun(*this, &ARDOUR_UI::disk_underrun_handler));
|
||||||
|
|
@ -398,21 +400,15 @@ ARDOUR_UI::pop_back_splash ()
|
||||||
gint
|
gint
|
||||||
ARDOUR_UI::configure_timeout ()
|
ARDOUR_UI::configure_timeout ()
|
||||||
{
|
{
|
||||||
struct timeval now;
|
if (last_configure_time == 0) {
|
||||||
struct timeval diff;
|
|
||||||
|
|
||||||
if (last_configure_time.tv_sec == 0 && last_configure_time.tv_usec == 0) {
|
|
||||||
/* no configure events yet */
|
/* no configure events yet */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gettimeofday (&now, 0);
|
|
||||||
timersub (&now, &last_configure_time, &diff);
|
|
||||||
|
|
||||||
/* force a gap of 0.5 seconds since the last configure event
|
/* 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;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
have_configure_timeout = false;
|
have_configure_timeout = false;
|
||||||
|
|
@ -425,7 +421,7 @@ gboolean
|
||||||
ARDOUR_UI::configure_handler (GdkEventConfigure* conf)
|
ARDOUR_UI::configure_handler (GdkEventConfigure* conf)
|
||||||
{
|
{
|
||||||
if (have_configure_timeout) {
|
if (have_configure_timeout) {
|
||||||
gettimeofday (&last_configure_time, 0);
|
last_configure_time = get_microseconds();
|
||||||
} else {
|
} else {
|
||||||
Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::configure_timeout), 100);
|
Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::configure_timeout), 100);
|
||||||
have_configure_timeout = true;
|
have_configure_timeout = true;
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@
|
||||||
#include <gtkmm2ext/bindable_button.h>
|
#include <gtkmm2ext/bindable_button.h>
|
||||||
#include <ardour/ardour.h>
|
#include <ardour/ardour.h>
|
||||||
#include <ardour/session.h>
|
#include <ardour/session.h>
|
||||||
|
#include <ardour/types.h>
|
||||||
|
|
||||||
#include "audio_clock.h"
|
#include "audio_clock.h"
|
||||||
#include "ardour_dialog.h"
|
#include "ardour_dialog.h"
|
||||||
|
|
@ -643,11 +644,11 @@ class ARDOUR_UI : public Gtkmm2ext::UI
|
||||||
void flush_trash ();
|
void flush_trash ();
|
||||||
|
|
||||||
bool have_configure_timeout;
|
bool have_configure_timeout;
|
||||||
struct timeval last_configure_time;
|
ARDOUR::microseconds_t last_configure_time;
|
||||||
gint configure_timeout ();
|
gint configure_timeout ();
|
||||||
|
|
||||||
struct timeval last_peak_grab;
|
ARDOUR::microseconds_t last_peak_grab;
|
||||||
struct timeval last_shuttle_request;
|
ARDOUR::microseconds_t last_shuttle_request;
|
||||||
|
|
||||||
bool have_disk_speed_dialog_displayed;
|
bool have_disk_speed_dialog_displayed;
|
||||||
void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
|
void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
|
||||||
|
|
|
||||||
|
|
@ -755,17 +755,13 @@ ARDOUR_UI::set_shuttle_fract (double f)
|
||||||
void
|
void
|
||||||
ARDOUR_UI::use_shuttle_fract (bool force)
|
ARDOUR_UI::use_shuttle_fract (bool force)
|
||||||
{
|
{
|
||||||
struct timeval now;
|
microseconds_t now = get_microseconds();
|
||||||
struct timeval diff;
|
|
||||||
|
|
||||||
/* do not attempt to submit a motion-driven transport speed request
|
/* do not attempt to submit a motion-driven transport speed request
|
||||||
more than once per process cycle.
|
more than once per process cycle.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
gettimeofday (&now, 0);
|
if (!force && (last_shuttle_request - now) < engine->usecs_per_cycle()) {
|
||||||
timersub (&now, &last_shuttle_request, &diff);
|
|
||||||
|
|
||||||
if (!force && (diff.tv_usec + (diff.tv_sec * 1000000)) < engine->usecs_per_cycle()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2062,7 +2062,7 @@ public:
|
||||||
/* tracking step changes of track height */
|
/* tracking step changes of track height */
|
||||||
|
|
||||||
TimeAxisView* current_stepping_trackview;
|
TimeAxisView* current_stepping_trackview;
|
||||||
struct timeval last_track_height_step_timestamp;
|
ARDOUR::microseconds_t last_track_height_step_timestamp;
|
||||||
gint track_height_step_timeout();
|
gint track_height_step_timeout();
|
||||||
sigc::connection step_timeout;
|
sigc::connection step_timeout;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ Editor::track_canvas_scroll (GdkEventScroll* ev)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gettimeofday (&last_track_height_step_timestamp, 0);
|
last_track_height_step_timestamp = get_microseconds();
|
||||||
current_stepping_trackview->step_height (true);
|
current_stepping_trackview->step_height (true);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -125,7 +125,7 @@ Editor::track_canvas_scroll (GdkEventScroll* ev)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gettimeofday (&last_track_height_step_timestamp, 0);
|
last_track_height_step_timestamp = get_microseconds();
|
||||||
current_stepping_trackview->step_height (false);
|
current_stepping_trackview->step_height (false);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -5392,13 +5392,7 @@ Editor::mouse_brush_insert_region (RegionView* rv, nframes_t pos)
|
||||||
gint
|
gint
|
||||||
Editor::track_height_step_timeout ()
|
Editor::track_height_step_timeout ()
|
||||||
{
|
{
|
||||||
struct timeval now;
|
if (get_microseconds() - last_track_height_step_timestamp < 250000) {
|
||||||
struct timeval delta;
|
|
||||||
|
|
||||||
gettimeofday (&now, 0);
|
|
||||||
timersub (&now, &last_track_height_step_timestamp, &delta);
|
|
||||||
|
|
||||||
if (delta.tv_sec * 1000000 + delta.tv_usec > 250000) { /* milliseconds */
|
|
||||||
current_stepping_trackview = 0;
|
current_stepping_trackview = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@
|
||||||
#include <ardour/configuration.h>
|
#include <ardour/configuration.h>
|
||||||
#include <ardour/types.h>
|
#include <ardour/types.h>
|
||||||
|
|
||||||
|
// #include <jack/jack.h> need this to inline jack_get_microseconds
|
||||||
|
|
||||||
namespace MIDI {
|
namespace MIDI {
|
||||||
class MachineControl;
|
class MachineControl;
|
||||||
class Port;
|
class Port;
|
||||||
|
|
@ -63,7 +65,12 @@ namespace ARDOUR {
|
||||||
const layer_t max_layer = UCHAR_MAX;
|
const layer_t max_layer = UCHAR_MAX;
|
||||||
|
|
||||||
microseconds_t get_microseconds ();
|
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 ();
|
Change new_change ();
|
||||||
|
|
||||||
extern Change StartChanged;
|
extern Change StartChanged;
|
||||||
|
|
|
||||||
|
|
@ -889,7 +889,7 @@ class Session : public PBD::StatefulDestructible
|
||||||
void reset_playback_load_min ();
|
void reset_playback_load_min ();
|
||||||
void reset_capture_load_min ();
|
void reset_capture_load_min ();
|
||||||
|
|
||||||
float read_data_rate () const;
|
float read_data_rate () const; // in usec
|
||||||
float write_data_rate () const;
|
float write_data_rate () const;
|
||||||
|
|
||||||
/* ranges */
|
/* ranges */
|
||||||
|
|
|
||||||
|
|
@ -383,11 +383,7 @@ ARDOUR::cleanup ()
|
||||||
microseconds_t
|
microseconds_t
|
||||||
ARDOUR::get_microseconds ()
|
ARDOUR::get_microseconds ()
|
||||||
{
|
{
|
||||||
/* XXX need JACK to export its functionality */
|
return (microseconds_t) jack_get_time ();
|
||||||
|
|
||||||
struct timeval now;
|
|
||||||
gettimeofday (&now, 0);
|
|
||||||
return now.tv_sec * 1000000ULL + now.tv_usec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ARDOUR::Change
|
ARDOUR::Change
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,8 @@ Session::butler_thread_work ()
|
||||||
uint32_t err = 0;
|
uint32_t err = 0;
|
||||||
int32_t bytes;
|
int32_t bytes;
|
||||||
bool compute_io;
|
bool compute_io;
|
||||||
struct timeval begin, end;
|
microseconds_t begin, end;
|
||||||
|
|
||||||
struct pollfd pfd[1];
|
struct pollfd pfd[1];
|
||||||
bool disk_work_outstanding = false;
|
bool disk_work_outstanding = false;
|
||||||
DiskstreamList::iterator i;
|
DiskstreamList::iterator i;
|
||||||
|
|
@ -243,7 +244,7 @@ Session::butler_thread_work ()
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
compute_io = true;
|
compute_io = true;
|
||||||
|
|
||||||
gettimeofday (&begin, 0);
|
begin = get_microseconds();
|
||||||
|
|
||||||
boost::shared_ptr<DiskstreamList> dsl = diskstreams.reader ();
|
boost::shared_ptr<DiskstreamList> dsl = diskstreams.reader ();
|
||||||
|
|
||||||
|
|
@ -290,17 +291,16 @@ Session::butler_thread_work ()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compute_io) {
|
if (compute_io) {
|
||||||
gettimeofday (&end, 0);
|
end = get_microseconds();
|
||||||
|
if(end-begin > 0) {
|
||||||
double b = begin.tv_sec + (begin.tv_usec/1000000.0);
|
_read_data_rate = (float) bytes / (float) (end - begin);
|
||||||
double e = end.tv_sec + (end.tv_usec / 1000000.0);
|
} else { _read_data_rate = 0; // infinity better
|
||||||
|
}
|
||||||
_read_data_rate = bytes / (e - b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
compute_io = true;
|
compute_io = true;
|
||||||
gettimeofday (&begin, 0);
|
begin = get_microseconds();
|
||||||
|
|
||||||
for (i = dsl->begin(); !transport_work_requested() && butler_should_run && i != dsl->end(); ++i) {
|
for (i = dsl->begin(); !transport_work_requested() && butler_should_run && i != dsl->end(); ++i) {
|
||||||
// cerr << "write behind for " << (*i)->name () << endl;
|
// cerr << "write behind for " << (*i)->name () << endl;
|
||||||
|
|
@ -344,12 +344,13 @@ Session::butler_thread_work ()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compute_io) {
|
if (compute_io) {
|
||||||
gettimeofday (&end, 0);
|
// there are no apparent users for this calculation?
|
||||||
|
end = get_microseconds();
|
||||||
double b = begin.tv_sec + (begin.tv_usec/1000000.0);
|
if(end-begin > 0) {
|
||||||
double e = end.tv_sec + (end.tv_usec / 1000000.0);
|
_write_data_rate = (float) bytes / (float) (end - begin);
|
||||||
|
} else {
|
||||||
_write_data_rate = bytes / (e - b);
|
_write_data_rate = 0; // Well, infinity would be better
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!disk_work_outstanding) {
|
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
|
/* disk i/o in excess of 10000MB/sec indicate the buffer cache
|
||||||
in action. ignore it.
|
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
|
float
|
||||||
|
|
@ -425,7 +426,7 @@ Session::write_data_rate () const
|
||||||
/* disk i/o in excess of 10000MB/sec indicate the buffer cache
|
/* disk i/o in excess of 10000MB/sec indicate the buffer cache
|
||||||
in action. ignore it.
|
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
|
uint32_t
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue