summaryrefslogtreecommitdiff
path: root/libs/ardour/session_process.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-04-14 19:23:58 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-04-14 19:23:58 +0000
commitd68045d6c5933580dace6b63311040f4b1716f72 (patch)
treee5c4a81f190559ab1b1f1bf39f6d0c274c178a8d /libs/ardour/session_process.cc
parent4558ae1e6e9e91450a45c44d010a9a6f03c6de38 (diff)
EXPERIMENTAL! NEEDS TESTING! remove "offset" from almost everything in the process callback tree
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4979 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/session_process.cc')
-rw-r--r--libs/ardour/session_process.cc80
1 files changed, 44 insertions, 36 deletions
diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc
index 31cf3a930d..8d831ee40d 100644
--- a/libs/ardour/session_process.cc
+++ b/libs/ardour/session_process.cc
@@ -76,7 +76,15 @@ Session::prepare_diskstreams ()
}
int
-Session::no_roll (nframes_t nframes, nframes_t offset)
+Session::fail_roll (nframes_t nframes)
+{
+ Port::set_port_offset (0);
+ return no_roll (nframes);
+
+}
+
+int
+Session::no_roll (nframes_t nframes)
{
nframes_t end_frame = _transport_frame + nframes;
int ret = 0;
@@ -84,7 +92,7 @@ Session::no_roll (nframes_t nframes, nframes_t offset)
boost::shared_ptr<RouteList> r = routes.reader ();
if (_click_io) {
- _click_io->silence (nframes, offset);
+ _click_io->silence (nframes);
}
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
@@ -95,7 +103,7 @@ Session::no_roll (nframes_t nframes, nframes_t offset)
(*i)->set_pending_declick (declick);
- if ((*i)->no_roll (nframes, _transport_frame, end_frame, offset, non_realtime_work_pending(),
+ if ((*i)->no_roll (nframes, _transport_frame, end_frame, non_realtime_work_pending(),
actively_recording(), declick)) {
error << string_compose(_("Session: error in no roll for %1"), (*i)->name()) << endmsg;
ret = -1;
@@ -107,7 +115,7 @@ Session::no_roll (nframes_t nframes, nframes_t offset)
}
int
-Session::process_routes (nframes_t nframes, nframes_t offset)
+Session::process_routes (nframes_t nframes)
{
bool record_active;
int declick = get_transport_declick_required();
@@ -131,7 +139,7 @@ Session::process_routes (nframes_t nframes, nframes_t offset)
(*i)->set_pending_declick (declick);
- if ((ret = (*i)->roll (nframes, _transport_frame, _transport_frame + nframes, offset, declick, record_active, rec_monitors)) < 0) {
+ if ((ret = (*i)->roll (nframes, _transport_frame, _transport_frame + nframes, declick, record_active, rec_monitors)) < 0) {
/* we have to do this here. Route::roll() for an AudioTrack will have called AudioDiskstream::process(),
and the DS will expect AudioDiskstream::commit() to be called. but we're aborting from that
@@ -152,7 +160,7 @@ Session::process_routes (nframes_t nframes, nframes_t offset)
}
int
-Session::silent_process_routes (nframes_t nframes, nframes_t offset)
+Session::silent_process_routes (nframes_t nframes)
{
bool record_active = actively_recording();
int declick = get_transport_declick_required();
@@ -172,7 +180,7 @@ Session::silent_process_routes (nframes_t nframes, nframes_t offset)
continue;
}
- if ((ret = (*i)->silent_roll (nframes, _transport_frame, _transport_frame + nframes, offset, record_active, rec_monitors)) < 0) {
+ if ((ret = (*i)->silent_roll (nframes, _transport_frame, _transport_frame + nframes, record_active, rec_monitors)) < 0) {
/* we have to do this here. Route::roll() for an AudioTrack will have called AudioDiskstream::process(),
and the DS will expect AudioDiskstream::commit() to be called. but we're aborting from that
@@ -212,7 +220,7 @@ Session::commit_diskstreams (nframes_t nframes, bool &needs_butler)
also runs commit() for every diskstream.
*/
- if ((dret = (*i)->process (_transport_frame, nframes, 0, actively_recording(), get_rec_monitors_input())) == 0) {
+ if ((dret = (*i)->process (_transport_frame, nframes, actively_recording(), get_rec_monitors_input())) == 0) {
if ((*i)->commit (nframes)) {
needs_butler = true;
}
@@ -246,7 +254,7 @@ Session::process_with_events (nframes_t nframes)
Event* ev;
nframes_t this_nframes;
nframes_t end_frame;
- nframes_t offset;
+
bool session_needs_butler = false;
nframes_t stop_limit;
long frames_moved;
@@ -254,7 +262,7 @@ Session::process_with_events (nframes_t nframes)
/* make sure the auditioner is silent */
if (auditioner) {
- auditioner->silence (nframes, 0);
+ auditioner->silence (nframes);
}
/* handle any pending events */
@@ -296,13 +304,13 @@ Session::process_with_events (nframes_t nframes)
}
if (!_exporting && _slave) {
- if (!follow_slave (nframes, 0)) {
+ if (!follow_slave (nframes)) {
return;
}
}
if (_transport_speed == 0) {
- no_roll (nframes, 0);
+ no_roll (nframes);
return;
}
@@ -318,7 +326,7 @@ Session::process_with_events (nframes_t nframes)
}
if (maybe_stop (stop_limit)) {
- no_roll (nframes, 0);
+ no_roll (nframes);
return;
}
@@ -326,7 +334,6 @@ Session::process_with_events (nframes_t nframes)
the_next_one = next_event;
++the_next_one;
- offset = 0;
while (nframes) {
@@ -342,20 +349,19 @@ Session::process_with_events (nframes_t nframes)
if (this_nframes) {
- click (_transport_frame, nframes, offset);
+ click (_transport_frame, nframes);
/* now process frames between now and the first event in this block */
prepare_diskstreams ();
- if (process_routes (this_nframes, offset)) {
- no_roll (nframes, 0);
+ if (process_routes (this_nframes)) {
+ fail_roll (nframes);
return;
}
commit_diskstreams (this_nframes, session_needs_butler);
-
+
nframes -= this_nframes;
- offset += this_nframes;
if (frames_moved < 0) {
decrement_transport_position (-frames_moved);
@@ -367,6 +373,10 @@ Session::process_with_events (nframes_t nframes)
check_declick_out ();
}
+ /* reset port offsets so that Port::get_buffer() will fetch the correct data */
+
+ Port::increment_port_offset (this_nframes);
+
/* now handle this event and all others scheduled for the same time */
while (this_event && this_event->action_frame == _transport_frame) {
@@ -383,13 +393,12 @@ Session::process_with_events (nframes_t nframes)
/* if an event left our state changing, do the right thing */
if (nframes && non_realtime_work_pending()) {
- no_roll (nframes, offset);
+ no_roll (nframes);
break;
}
/* this is necessary to handle the case of seamless looping */
end_frame = _transport_frame + (nframes_t) floor (nframes * _transport_speed);
-
}
set_next_event ();
@@ -430,7 +439,7 @@ Session::transport_locked () const
}
bool
-Session::follow_slave (nframes_t nframes, nframes_t offset)
+Session::follow_slave (nframes_t nframes)
{
float slave_speed;
nframes_t slave_transport_frame;
@@ -680,7 +689,7 @@ Session::follow_slave (nframes_t nframes, nframes_t offset)
bool need_butler;
prepare_diskstreams ();
- silent_process_routes (nframes, offset);
+ silent_process_routes (nframes);
commit_diskstreams (nframes, need_butler);
if (need_butler) {
@@ -712,7 +721,7 @@ Session::follow_slave (nframes_t nframes, nframes_t offset)
noroll:
/* don't move at all */
- no_roll (nframes, 0);
+ no_roll (nframes);
return false;
}
@@ -722,7 +731,6 @@ Session::process_without_events (nframes_t nframes)
bool session_needs_butler = false;
nframes_t stop_limit;
long frames_moved;
- nframes_t offset = 0;
if (!process_can_proceed()) {
_silent = true;
@@ -730,13 +738,13 @@ Session::process_without_events (nframes_t nframes)
}
if (!_exporting && _slave) {
- if (!follow_slave (nframes, 0)) {
+ if (!follow_slave (nframes)) {
return;
}
}
if (_transport_speed == 0) {
- no_roll (nframes, 0);
+ fail_roll (nframes);
return;
}
@@ -751,22 +759,22 @@ Session::process_without_events (nframes_t nframes)
}
if (maybe_stop (stop_limit)) {
- no_roll (nframes, 0);
+ fail_roll (nframes);
return;
}
- if (maybe_sync_start (nframes, offset)) {
+ if (maybe_sync_start (nframes)) {
return;
}
- click (_transport_frame, nframes, offset);
+ click (_transport_frame, nframes);
prepare_diskstreams ();
frames_moved = (long) floor (_transport_speed * nframes);
- if (process_routes (nframes, offset)) {
- no_roll (nframes, offset);
+ if (process_routes (nframes)) {
+ fail_roll (nframes);
return;
}
@@ -800,7 +808,7 @@ Session::process_audition (nframes_t nframes)
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
if (!(*i)->hidden()) {
- (*i)->silence (nframes, 0);
+ (*i)->silence (nframes);
}
}
@@ -833,7 +841,7 @@ Session::process_audition (nframes_t nframes)
}
bool
-Session::maybe_sync_start (nframes_t& nframes, nframes_t& offset)
+Session::maybe_sync_start (nframes_t& nframes)
{
nframes_t sync_offset;
@@ -848,9 +856,9 @@ Session::maybe_sync_start (nframes_t& nframes, nframes_t& offset)
is left to do.
*/
- no_roll (sync_offset, 0);
+ no_roll (sync_offset);
nframes -= sync_offset;
- offset += sync_offset;
+ Port::increment_port_offset (sync_offset);
waiting_for_sync_offset = false;
if (nframes == 0) {