X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fdisk_reader.cc;h=624a9ac17d7fb0cff581c60427cd51bb3f58548e;hb=5ada17eba0195d90f0685776251b384efdf5168e;hp=254b81e1683c4add32fbe2463bfc8a8338b1403a;hpb=e44ae422ebb5c1b18cc03cb2254e3cf3308565e0;p=ardour.git diff --git a/libs/ardour/disk_reader.cc b/libs/ardour/disk_reader.cc index 254b81e168..624a9ac17d 100644 --- a/libs/ardour/disk_reader.cc +++ b/libs/ardour/disk_reader.cc @@ -18,7 +18,6 @@ */ #include "pbd/enumwriter.h" -#include "pbd/i18n.h" #include "pbd/memento_command.h" #include "ardour/audioengine.h" @@ -36,6 +35,8 @@ #include "ardour/session.h" #include "ardour/session_playlists.h" +#include "pbd/i18n.h" + using namespace ARDOUR; using namespace PBD; using namespace std; @@ -50,9 +51,9 @@ bool DiskReader::_no_disk_output = false; DiskReader::DiskReader (Session& s, string const & str, DiskIOProcessor::Flag f) : DiskIOProcessor (s, str, f) , overwrite_sample (0) - , overwrite_offset (0) - , _pending_overwrite (false) - , overwrite_queued (false) + , overwrite_offset (0) + , _pending_overwrite (false) + , overwrite_queued (false) , _gui_feed_buffer (AudioEngine::instance()->raw_buffer_size (DataType::MIDI)) { file_sample[DataType::AUDIO] = 0; @@ -252,11 +253,17 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp } } - if (speed == 0.0 && (ms == MonitoringDisk)) { - /* stopped. Don't accidentally pass any data from disk - * into our outputs (e.g. via interpolation) - */ - bufs.silence (nframes, 0); + if (speed == 0.0) { + /* stopped. Don't accidentally pass any data from disk + * into our outputs (e.g. via interpolation) + * nor jump ahead playback_sample when not rolling + */ + if (ms == MonitoringDisk) { + /* when monitoring disk, clear input data so far, + * everything before the disk processor is not relevant. + */ + bufs.silence (nframes, 0); + } return; } @@ -318,13 +325,29 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp disk_signal = output.data (); } + if (start_sample < playback_sample) { + cerr << owner()->name() << " SS = " << start_sample << " PS = " << playback_sample << endl; + abort (); + } + + if (start_sample != playback_sample) { + cerr << owner()->name() << " playback not aligned, jump ahead " << (start_sample - playback_sample) << endl; + + if (can_internal_playback_seek (start_sample - playback_sample)) { + internal_playback_seek (start_sample - playback_sample); + } else { + cerr << owner()->name() << " playback not possible: ss = " << start_sample << " ps = " << playback_sample << endl; + goto midi; + } + } + chaninfo->buf->get_read_vector (&(*chan)->rw_vector); if (disk_samples_to_consume <= (samplecnt_t) chaninfo->rw_vector.len[0]) { if (fabsf (speed) != 1.0f) { (void) interpolation.interpolate ( - n, nframes, + n, disk_samples_to_consume, chaninfo->rw_vector.buf[0], disk_signal); } else if (speed != 0.0) { @@ -370,20 +393,23 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp } if (scaling != 1.0f && speed != 0.0) { - apply_gain_to_buffer (disk_signal, nframes, scaling); + apply_gain_to_buffer (disk_signal, disk_samples_to_consume, scaling); } chaninfo->buf->increment_read_ptr (disk_samples_to_consume); - if ((speed != 0.0) && (ms & MonitoringInput)) { + monitor_mix: + + if (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 : disk_samples_to_consume); + mix_buffers_no_gain (output.data(), disk_signal, disk_samples_to_consume); } } } /* MIDI data handling */ + midi: if (!_session.declick_out_pending() && bufs.count().n_midi()) { MidiBuffer* dst; @@ -605,6 +631,8 @@ DiskReader::seek (samplepos_t sample, bool complete_refill) ChannelList::iterator chan; boost::shared_ptr c = channels.reader(); + //sample = std::max ((samplecnt_t)0, sample -_session.worst_output_latency ()); + for (n = 0, chan = c->begin(); chan != c->end(); ++chan, ++n) { (*chan)->buf->reset (); }