summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2008-10-21 15:03:50 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2008-10-21 15:03:50 +0000
commit6405e51c856c9094507b7da20511b907bc41f9f7 (patch)
treedd1e2bd5587bf79cceafd2e3fec0865d0cad9b31
parent8e095d439f5b527eeadd9588b725733e64a57427 (diff)
improved (?) Session::audible_frame()
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3990 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/editor_mixer.cc1
-rw-r--r--libs/ardour/ardour/session.h3
-rw-r--r--libs/ardour/session.cc67
-rw-r--r--libs/ardour/session_state.cc3
-rw-r--r--libs/ardour/session_transport.cc5
5 files changed, 35 insertions, 44 deletions
diff --git a/gtk2_ardour/editor_mixer.cc b/gtk2_ardour/editor_mixer.cc
index 58a2d55a0c..d58a202e1a 100644
--- a/gtk2_ardour/editor_mixer.cc
+++ b/gtk2_ardour/editor_mixer.cc
@@ -176,7 +176,6 @@ Editor::set_selected_mixer_strip (TimeAxisView& view)
}
double current = 0.0;
-bool currentInitialized = 0;
void
Editor::update_current_screen ()
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 35b8c5489d..c967310dc7 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -1755,8 +1755,7 @@ class Session : public PBD::StatefulDestructible
/* used in ::audible_frame() */
- mutable float af_last_transport_speed;
- mutable nframes64_t af_last_frame;
+ mutable bool have_looped;
};
} // namespace ARDOUR
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 0a58a7da25..a6a322739e 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -1377,6 +1377,10 @@ Session::audible_frame () const
nframes_t ret;
nframes_t offset;
nframes_t tf;
+
+ if (_transport_speed == 0.0f) {
+ return last_stop_frame;
+ }
/* the first of these two possible settings for "offset"
mean that the audible frame is stationary until
@@ -1407,56 +1411,43 @@ Session::audible_frame () const
tf = _transport_frame;
}
- if (_transport_speed == 0) {
- ret = tf;
- goto block_retrograde;
- }
-
- if (tf < offset) {
- ret = 0;
- goto block_retrograde;
- }
-
ret = tf;
if (!non_realtime_work_pending()) {
/* MOVING */
- /* take latency into account */
-
- if (_transport_speed > 0.0) {
- /* forwards */
- ret -= offset;
- } else {
- /* backwards */
- ret += offset;
- }
+ /* check to see if we have passed the first guaranteed
+ audible frame past our last stopping position. if not,
+ the return that last stopping point because in terms
+ of audible frames, we have not moved yet.
+ */
- }
+ if (_transport_speed > 0.0f) {
- /* do not allow retrograde motion near startup or a direction change
- caused by latency correction. we detect this by the asking if the present
- and previously-noted transport speed (and thus direction) are the same.
- */
+ if (!play_loop || !have_looped) {
+ if (tf < last_stop_frame + offset) {
+ return last_stop_frame;
+
+ }
+ }
+
- block_retrograde:
- if ((af_last_transport_speed >= 0.0) == (_transport_speed >= 0.0)) {
+ /* forwards */
+ ret -= offset;
- if (_transport_speed > 0.0) {
- if (ret < af_last_frame) {
- ret = af_last_frame;
- }
+ } else if (_transport_speed < 0.0f) {
- } else if (_transport_speed < 0.0) {
- if (ret > af_last_frame) {
- ret = af_last_frame;
+ /* XXX wot? no backward looping? */
+
+ if (tf > last_stop_frame - offset) {
+ return last_stop_frame;
+ } else {
+ /* backwards */
+ ret += offset;
}
- }
- }
-
- af_last_frame = ret;
- af_last_transport_speed = _transport_speed;
+ }
+ }
return ret;
}
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index 469914c971..3b68f8fb44 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -148,6 +148,7 @@ Session::first_stage_init (string fullpath, string snapshot_name)
g_atomic_int_set (&_record_status, Disabled);
loop_changing = false;
play_loop = false;
+ have_looped = false;
_last_roll_location = 0;
_last_record_location = 0;
pending_locate_frame = 0;
@@ -228,8 +229,6 @@ Session::first_stage_init (string fullpath, string snapshot_name)
_smpte_offset = 0;
_smpte_offset_negative = true;
last_smpte_valid = false;
- af_last_transport_speed = 0.0;
- af_last_frame = 0.0;
sync_time_vars ();
diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc
index 1baf6cae29..83bac047ac 100644
--- a/libs/ardour/session_transport.cc
+++ b/libs/ardour/session_transport.cc
@@ -437,6 +437,8 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished)
_requested_return_frame = -1;
}
+ have_looped = false;
+
send_full_time_code ();
deliver_mmc (MIDI::MachineControl::cmdStop, 0);
deliver_mmc (MIDI::MachineControl::cmdLocate, _transport_frame);
@@ -766,7 +768,7 @@ Session::locate (nframes_t target_frame, bool with_roll, bool with_flush, bool w
}
}
}
-
+ have_looped = true;
TransportLooped(); // EMIT SIGNAL
}
}
@@ -926,6 +928,7 @@ void
Session::start_transport ()
{
_last_roll_location = _transport_frame;
+ have_looped = false;
/* if record status is Enabled, move it to Recording. if its
already Recording, move it to Disabled.