remove all code related to "silent roll" concept. some debug output added
This commit is contained in:
parent
24df2b5594
commit
e9dd575ca5
|
@ -100,6 +100,7 @@ class LIBARDOUR_API DiskReader : public DiskIOProcessor
|
|||
static void set_midi_readahead_frames (framecnt_t frames_ahead) { midi_readahead = frames_ahead; }
|
||||
|
||||
static void set_no_disk_output (bool yn);
|
||||
static bool no_disk_output() { return _no_disk_output; }
|
||||
|
||||
protected:
|
||||
friend class Track;
|
||||
|
@ -128,7 +129,7 @@ class LIBARDOUR_API DiskReader : public DiskIOProcessor
|
|||
|
||||
static framecnt_t _chunk_frames;
|
||||
static framecnt_t midi_readahead;
|
||||
static bool no_disk_output;
|
||||
static bool _no_disk_output;
|
||||
|
||||
/* The MIDI stuff */
|
||||
|
||||
|
|
|
@ -65,9 +65,6 @@ public:
|
|||
|
||||
void helper_thread();
|
||||
|
||||
int silent_process_routes (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
|
||||
bool& need_butler);
|
||||
|
||||
int process_routes (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, int declick,
|
||||
bool& need_butler);
|
||||
|
||||
|
@ -130,7 +127,6 @@ private:
|
|||
bool _process_non_rt_pending;
|
||||
int _process_declick;
|
||||
|
||||
bool _process_silent;
|
||||
bool _process_noroll;
|
||||
int _process_retval;
|
||||
bool _process_need_butler;
|
||||
|
|
|
@ -1325,7 +1325,6 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
|
|||
bool follow_slave (pframes_t);
|
||||
void calculate_moving_average_of_slave_delta (int dir, framecnt_t this_delta);
|
||||
void track_slave_state (float slave_speed, framepos_t slave_transport_frame, framecnt_t this_delta);
|
||||
void follow_slave_silently (pframes_t nframes, float slave_speed);
|
||||
|
||||
void switch_to_sync_source (SyncSource); /* !RT context */
|
||||
void drop_sync_source (); /* !RT context */
|
||||
|
|
|
@ -72,9 +72,6 @@ class LIBARDOUR_API Track : public Route, public Recordable
|
|||
virtual int no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
|
||||
bool state_changing);
|
||||
|
||||
int silent_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
|
||||
bool& need_butler);
|
||||
|
||||
virtual int roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
|
||||
int declick, bool& need_butler) = 0;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ PBD::Signal0<void> DiskReader::Underrun;
|
|||
Sample* DiskReader::_mixdown_buffer = 0;
|
||||
gain_t* DiskReader::_gain_buffer = 0;
|
||||
framecnt_t DiskReader::midi_readahead = 4096;
|
||||
bool DiskReader::no_disk_output = false;
|
||||
bool DiskReader::_no_disk_output = false;
|
||||
|
||||
DiskReader::DiskReader (Session& s, string const & str, DiskIOProcessor::Flag f)
|
||||
: DiskIOProcessor (s, str, f)
|
||||
|
@ -243,7 +243,7 @@ DiskReader::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame,
|
|||
uint32_t n;
|
||||
boost::shared_ptr<ChannelList> c = channels.reader();
|
||||
ChannelList::iterator chan;
|
||||
frameoffset_t playback_distance;
|
||||
frameoffset_t disk_samples_to_consume;
|
||||
MonitorState ms = _route->monitoring_state ();
|
||||
|
||||
if (_active) {
|
||||
|
@ -270,31 +270,33 @@ DiskReader::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame,
|
|||
if (speed != 1.0f && speed != -1.0f) {
|
||||
interpolation.set_speed (speed);
|
||||
midi_interpolation.set_speed (speed);
|
||||
playback_distance = midi_interpolation.distance (nframes);
|
||||
disk_samples_to_consume = midi_interpolation.distance (nframes);
|
||||
if (speed < 0.0) {
|
||||
playback_distance = -playback_distance;
|
||||
disk_samples_to_consume = -disk_samples_to_consume;
|
||||
}
|
||||
} else {
|
||||
playback_distance = nframes;
|
||||
disk_samples_to_consume = nframes;
|
||||
}
|
||||
|
||||
BufferSet& scratch_bufs (_session.get_scratch_buffers (bufs.count()));
|
||||
const bool still_locating = _session.global_locate_pending();
|
||||
|
||||
if (!result_required || ((ms & MonitoringDisk) == 0) || still_locating) {
|
||||
cerr << name() << " use disk output ? " << !_no_disk_output << endl;
|
||||
|
||||
if (!result_required || ((ms & MonitoringDisk) == 0) || still_locating || _no_disk_output) {
|
||||
|
||||
/* no need for actual disk data, just advance read pointer and return */
|
||||
|
||||
if (!still_locating) {
|
||||
if (!still_locating || _no_disk_output) {
|
||||
for (ChannelList::iterator chan = c->begin(); chan != c->end(); ++chan) {
|
||||
(*chan)->buf->increment_read_ptr (playback_distance);
|
||||
(*chan)->buf->increment_read_ptr (disk_samples_to_consume);
|
||||
}
|
||||
}
|
||||
|
||||
/* if monitoring disk but locating put silence in the buffers */
|
||||
|
||||
if (still_locating && (ms == MonitoringDisk)) {
|
||||
bufs.silence (playback_distance, 0);
|
||||
if (_no_disk_output || (still_locating && (ms == MonitoringDisk))) {
|
||||
bufs.silence (nframes, 0);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -327,7 +329,7 @@ DiskReader::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame,
|
|||
|
||||
chaninfo->buf->get_read_vector (&(*chan)->rw_vector);
|
||||
|
||||
if (playback_distance <= (framecnt_t) chaninfo->rw_vector.len[0]) {
|
||||
if (disk_samples_to_consume <= (framecnt_t) chaninfo->rw_vector.len[0]) {
|
||||
|
||||
if (fabsf (speed) != 1.0f) {
|
||||
(void) interpolation.interpolate (
|
||||
|
@ -335,14 +337,14 @@ DiskReader::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame,
|
|||
chaninfo->rw_vector.buf[0],
|
||||
disk_signal);
|
||||
} else if (speed != 0.0) {
|
||||
memcpy (disk_signal, chaninfo->rw_vector.buf[0], sizeof (Sample) * playback_distance);
|
||||
memcpy (disk_signal, chaninfo->rw_vector.buf[0], sizeof (Sample) * disk_samples_to_consume);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
const framecnt_t total = chaninfo->rw_vector.len[0] + chaninfo->rw_vector.len[1];
|
||||
|
||||
if (playback_distance <= total) {
|
||||
if (disk_samples_to_consume <= total) {
|
||||
|
||||
/* We have enough samples, but not in one lump.
|
||||
*/
|
||||
|
@ -352,7 +354,7 @@ DiskReader::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame,
|
|||
chaninfo->rw_vector.buf[0],
|
||||
disk_signal);
|
||||
disk_signal += chaninfo->rw_vector.len[0];
|
||||
interpolation.interpolate (n, playback_distance - chaninfo->rw_vector.len[0],
|
||||
interpolation.interpolate (n, disk_samples_to_consume - chaninfo->rw_vector.len[0],
|
||||
chaninfo->rw_vector.buf[1],
|
||||
disk_signal);
|
||||
} else if (speed != 0.0) {
|
||||
|
@ -361,12 +363,12 @@ DiskReader::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame,
|
|||
chaninfo->rw_vector.len[0] * sizeof (Sample));
|
||||
memcpy (disk_signal + chaninfo->rw_vector.len[0],
|
||||
chaninfo->rw_vector.buf[1],
|
||||
(playback_distance - chaninfo->rw_vector.len[0]) * sizeof (Sample));
|
||||
(disk_samples_to_consume - chaninfo->rw_vector.len[0]) * sizeof (Sample));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
cerr << _name << " Need " << playback_distance << " total = " << total << endl;
|
||||
cerr << _name << " Need " << disk_samples_to_consume << " total = " << total << endl;
|
||||
cerr << "underrun for " << _name << endl;
|
||||
DEBUG_TRACE (DEBUG::Butler, string_compose ("%1 underrun in %2, total space = %3\n",
|
||||
DEBUG_THREAD_SELF, name(), total));
|
||||
|
@ -380,11 +382,11 @@ DiskReader::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame,
|
|||
apply_gain_to_buffer (disk_signal, nframes, scaling);
|
||||
}
|
||||
|
||||
chaninfo->buf->increment_read_ptr (playback_distance);
|
||||
chaninfo->buf->increment_read_ptr (disk_samples_to_consume);
|
||||
|
||||
if (!no_disk_output && (speed != 0.0) && (ms & MonitoringInput)) {
|
||||
if ((speed != 0.0) && (ms & MonitoringInput)) {
|
||||
/* mix the disk signal into the input signal (already in bufs) */
|
||||
mix_buffers_no_gain (output.data(), disk_signal, speed == 0.0 ? nframes : playback_distance);
|
||||
mix_buffers_no_gain (output.data(), disk_signal, speed == 0.0 ? nframes : disk_samples_to_consume);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -392,8 +394,16 @@ DiskReader::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame,
|
|||
/* MIDI data handling */
|
||||
|
||||
if (!_session.declick_out_pending()) {
|
||||
MidiBuffer* dst;
|
||||
|
||||
if (_no_disk_output) {
|
||||
dst = &scratch_bufs.get_midi(0);
|
||||
} else {
|
||||
dst = &bufs.get_midi (0);
|
||||
}
|
||||
|
||||
if (ms & MonitoringDisk && !still_locating) {
|
||||
get_midi_playback (bufs.get_midi (0), playback_distance, ms, scratch_bufs, speed, playback_distance);
|
||||
get_midi_playback (*dst, disk_samples_to_consume, ms, scratch_bufs, speed, disk_samples_to_consume);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -402,9 +412,9 @@ DiskReader::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame,
|
|||
bool butler_required = false;
|
||||
|
||||
if (speed < 0.0) {
|
||||
playback_sample -= playback_distance;
|
||||
playback_sample -= disk_samples_to_consume;
|
||||
} else {
|
||||
playback_sample += playback_distance;
|
||||
playback_sample += disk_samples_to_consume;
|
||||
}
|
||||
|
||||
if (_playlists[DataType::AUDIO]) {
|
||||
|
@ -434,7 +444,7 @@ DiskReader::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame,
|
|||
/*
|
||||
cerr << name() << " MDS written: " << frames_written << " - read: " << frames_read <<
|
||||
" = " << frames_written - frames_read
|
||||
<< " + " << playback_distance << " < " << midi_readahead << " = " << need_butler << ")" << endl;
|
||||
<< " + " << disk_samples_to_consume << " < " << midi_readahead << " = " << need_butler << ")" << endl;
|
||||
*/
|
||||
|
||||
/* frames_read will generally be less than frames_written, but
|
||||
|
@ -466,7 +476,7 @@ DiskReader::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame,
|
|||
* and can stall
|
||||
*/
|
||||
if (frames_read <= frames_written) {
|
||||
if ((frames_written - frames_read) + playback_distance < midi_readahead) {
|
||||
if ((frames_written - frames_read) + disk_samples_to_consume < midi_readahead) {
|
||||
butler_required = true;
|
||||
}
|
||||
} else {
|
||||
|
@ -1218,7 +1228,7 @@ DiskReader::resolve_tracker (Evoral::EventSink<framepos_t>& buffer, framepos_t t
|
|||
* so that an event at playback_sample has time = 0
|
||||
*/
|
||||
void
|
||||
DiskReader::get_midi_playback (MidiBuffer& dst, framecnt_t nframes, MonitorState ms, BufferSet& scratch_bufs, double speed, framecnt_t playback_distance)
|
||||
DiskReader::get_midi_playback (MidiBuffer& dst, framecnt_t nframes, MonitorState ms, BufferSet& scratch_bufs, double speed, framecnt_t disk_samples_to_consume)
|
||||
{
|
||||
MidiBuffer* target;
|
||||
|
||||
|
@ -1318,7 +1328,7 @@ DiskReader::get_midi_playback (MidiBuffer& dst, framecnt_t nframes, MonitorState
|
|||
if (speed != 0.0 && fabsf (speed) != 1.0f) {
|
||||
for (MidiBuffer::iterator i = target->begin(); i != target->end(); ++i) {
|
||||
MidiBuffer::TimeType *tme = i.timeptr();
|
||||
*tme = (*tme) * nframes / playback_distance;
|
||||
*tme = (*tme) * nframes / disk_samples_to_consume;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1486,6 +1496,5 @@ DiskReader::set_no_disk_output (bool yn)
|
|||
don't want any actual disk output yet because we are still not
|
||||
synced.
|
||||
*/
|
||||
no_disk_output = yn;
|
||||
_no_disk_output = yn;
|
||||
}
|
||||
|
||||
|
|
|
@ -512,32 +512,6 @@ Graph::dump (int chain)
|
|||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
Graph::silent_process_routes (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, bool& need_butler)
|
||||
{
|
||||
if (!_threads_active) return 0;
|
||||
|
||||
_process_nframes = nframes;
|
||||
_process_start_frame = start_frame;
|
||||
_process_end_frame = end_frame;
|
||||
|
||||
_process_silent = true;
|
||||
_process_noroll = false;
|
||||
_process_retval = 0;
|
||||
_process_need_butler = false;
|
||||
|
||||
if (!_graph_empty) {
|
||||
DEBUG_TRACE(DEBUG::ProcessThreads, "wake graph for silent process\n");
|
||||
_callback_start_sem.signal ();
|
||||
_callback_done_sem.wait ();
|
||||
DEBUG_TRACE (DEBUG::ProcessThreads, "graph execution complete\n");
|
||||
}
|
||||
|
||||
need_butler = _process_need_butler;
|
||||
|
||||
return _process_retval;
|
||||
}
|
||||
|
||||
int
|
||||
Graph::process_routes (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, int declick, bool& need_butler)
|
||||
{
|
||||
|
@ -550,7 +524,6 @@ Graph::process_routes (pframes_t nframes, framepos_t start_frame, framepos_t end
|
|||
_process_end_frame = end_frame;
|
||||
_process_declick = declick;
|
||||
|
||||
_process_silent = false;
|
||||
_process_noroll = false;
|
||||
_process_retval = 0;
|
||||
_process_need_butler = false;
|
||||
|
@ -579,7 +552,6 @@ Graph::routes_no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end
|
|||
_process_declick = declick;
|
||||
_process_non_rt_pending = non_rt_pending;
|
||||
|
||||
_process_silent = false;
|
||||
_process_noroll = true;
|
||||
_process_retval = 0;
|
||||
_process_need_butler = false;
|
||||
|
@ -601,9 +573,7 @@ Graph::process_one_route (Route* route)
|
|||
|
||||
DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 runs route %2\n", pthread_name(), route->name()));
|
||||
|
||||
if (_process_silent) {
|
||||
retval = route->silent_roll (_process_nframes, _process_start_frame, _process_end_frame, need_butler);
|
||||
} else if (_process_noroll) {
|
||||
if (_process_noroll) {
|
||||
route->set_pending_declick (_process_declick);
|
||||
retval = route->no_roll (_process_nframes, _process_start_frame, _process_end_frame, _process_non_rt_pending);
|
||||
} else {
|
||||
|
|
|
@ -230,18 +230,6 @@ Session::process_routes (pframes_t nframes, bool& need_butler)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/** @param need_butler to be set to true by this method if it needs the butler,
|
||||
* otherwise it must be left alone.
|
||||
*/
|
||||
int
|
||||
Session::silent_process_routes (pframes_t nframes, bool& need_butler)
|
||||
{
|
||||
DiskReader::set_no_disk_output (true);
|
||||
int ret = process_routes (nframes, need_butler);
|
||||
DiskReader::set_no_disk_output (false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
Session::get_track_statistics ()
|
||||
{
|
||||
|
@ -620,9 +608,9 @@ Session::follow_slave (pframes_t nframes)
|
|||
_slave_state, slave_transport_frame, slave_speed, this_delta, average_slave_delta));
|
||||
|
||||
|
||||
if (_slave_state == Running && !_slave->is_always_synced() &&
|
||||
!(Config->get_timecode_source_is_synced() && (dynamic_cast<TimecodeSlave*>(_slave)) != 0)
|
||||
) {
|
||||
if (_slave_state == Running && !_slave->is_always_synced() && !(Config->get_timecode_source_is_synced() && (dynamic_cast<TimecodeSlave*>(_slave)) != 0)) {
|
||||
|
||||
/* may need to varispeed to sync with slave */
|
||||
|
||||
if (_transport_speed != 0.0f) {
|
||||
|
||||
|
@ -663,24 +651,36 @@ Session::follow_slave (pframes_t nframes)
|
|||
slave_speed));
|
||||
}
|
||||
|
||||
#if 1
|
||||
if (!actively_recording() && (framecnt_t) abs(average_slave_delta) > _slave->resolution()) {
|
||||
cerr << "average slave delta greater than slave resolution (" << _slave->resolution() << "), going to silent motion\n";
|
||||
goto silent_motion;
|
||||
DEBUG_TRACE (DEBUG::Slave, string_compose ("average slave delta %1 greater than slave resolution %2 => silent motion\n", abs(average_slave_delta), _slave->resolution()));
|
||||
/* run routes as normal, but no disk output */
|
||||
cerr << "sync too far apart " << average_slave_delta << ", NO disk audio for now\n";
|
||||
DiskReader::set_no_disk_output (true);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!have_first_delta_accumulator) {
|
||||
DEBUG_TRACE (DEBUG::Slave, "waiting for first slave delta accumulator to be ready\n");
|
||||
/* run routes as normal, but no disk output */
|
||||
cerr << "can't measure sync yet, NO disk audio for now\n";
|
||||
DiskReader::set_no_disk_output (true);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (_slave_state == Running && 0 == (post_transport_work () & ~PostTransportSpeed)) {
|
||||
/* speed is set, we're locked, and good to go */
|
||||
return true;
|
||||
if (!have_first_delta_accumulator) {
|
||||
DiskReader::set_no_disk_output (true);
|
||||
} else {
|
||||
DiskReader::set_no_disk_output (false);
|
||||
}
|
||||
|
||||
silent_motion:
|
||||
DEBUG_TRACE (DEBUG::Slave, "silent motion\n")
|
||||
follow_slave_silently (nframes, slave_speed);
|
||||
if ((_slave_state == Running) && (0 == (post_transport_work () & ~PostTransportSpeed))) {
|
||||
/* speed is set, we're locked, and good to go */
|
||||
cerr << "slave is locked, play disk audio ? " << !DiskReader::no_disk_output() << " delta = " << average_slave_delta << endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
noroll:
|
||||
/* don't move at all */
|
||||
|
@ -825,45 +825,6 @@ Session::track_slave_state (float slave_speed, framepos_t slave_transport_frame,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
Session::follow_slave_silently (pframes_t nframes, float slave_speed)
|
||||
{
|
||||
if (slave_speed && _transport_speed) {
|
||||
|
||||
/* something isn't right, but we should move with the master
|
||||
for now.
|
||||
*/
|
||||
|
||||
bool need_butler = false;
|
||||
|
||||
silent_process_routes (nframes, need_butler);
|
||||
|
||||
get_track_statistics ();
|
||||
|
||||
if (need_butler) {
|
||||
DEBUG_TRACE (DEBUG::Butler, "f-slave-silently: session needs butler, call it\n");
|
||||
_butler->summon ();
|
||||
}
|
||||
|
||||
int32_t frames_moved;
|
||||
|
||||
if (locate_pending()) {
|
||||
frames_moved = 0;
|
||||
} else {
|
||||
frames_moved = (int32_t) floor (_transport_speed * nframes);
|
||||
}
|
||||
|
||||
if (frames_moved < 0) {
|
||||
decrement_transport_position (-frames_moved);
|
||||
} else if (frames_moved) {
|
||||
increment_transport_position (frames_moved);
|
||||
}
|
||||
|
||||
framepos_t const stop_limit = compute_stop_limit ();
|
||||
maybe_stop (stop_limit);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Session::process_without_events (pframes_t nframes)
|
||||
{
|
||||
|
|
|
@ -556,39 +556,6 @@ Track::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
Track::silent_roll (pframes_t nframes, framepos_t /*start_frame*/, framepos_t /*end_frame*/, bool& need_butler)
|
||||
{
|
||||
Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
|
||||
if (!lm.locked()) {
|
||||
// XXX DISK reader needs to seek ahead the correct distance ?? OR DOES IT ?
|
||||
//framecnt_t playback_distance = _disk_reader->calculate_playback_distance(nframes);
|
||||
//if (can_internal_playback_seek(playback_distance)) {
|
||||
// internal_playback_seek(playback_distance);
|
||||
//}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (n_outputs().n_total() == 0 && _processors.empty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_active) {
|
||||
silence (nframes);
|
||||
return 0;
|
||||
}
|
||||
|
||||
_silent = true;
|
||||
_amp->apply_gain_automation(false);
|
||||
|
||||
silence (nframes);
|
||||
flush_processor_buffers_locked (nframes);
|
||||
|
||||
//BufferSet& bufs (_session.get_route_buffers (n_process_buffers(), true));
|
||||
// XXXX DISKWRITER/READER ADVANCE, SET need_butler
|
||||
return 0;
|
||||
}
|
||||
|
||||
boost::shared_ptr<Playlist>
|
||||
Track::playlist ()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user