*/
+#include <boost/smart_ptr/scoped_ptr.hpp>
+
#include "pbd/enumwriter.h"
#include "pbd/memento_command.h"
}
XMLNode&
-DiskReader::state (bool full)
+DiskReader::state ()
{
- XMLNode& node (DiskIOProcessor::state (full));
+ XMLNode& node (DiskIOProcessor::state ());
node.set_property(X_("type"), X_("diskreader"));
return node;
}
void
DiskReader::realtime_handle_transport_stopped ()
{
- realtime_speed_change ();
}
void
}
}
- if (speed == 0.0) {
- /* Nothing to do here.
- *
- * Do not clear input buffers here when (ms == MonitoringDisk)
- * we need to allow out-of-band data to pass thru from the input.
- * (e.g. MIDI immediate events)
+ if ((speed == 0.0) && (ms == MonitoringDisk)) {
+ /* no channels, or stopped. Don't accidentally pass any data
+ * from disk into our outputs (e.g. via interpolation)
*/
return;
}
+ BufferSet& scratch_bufs (_session.get_scratch_buffers (bufs.count()));
+ const bool still_locating = _session.global_locate_pending();
+
+ if (c->empty()) {
+ /* do nothing with audio */
+ goto midi;
+ }
+
if (speed != 1.0f && speed != -1.0f) {
interpolation.set_speed (speed);
- midi_interpolation.set_speed (speed);
- disk_samples_to_consume = midi_interpolation.distance (nframes);
+ disk_samples_to_consume = interpolation.distance (nframes);
if (speed < 0.0) {
disk_samples_to_consume = -disk_samples_to_consume;
}
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 || _no_disk_output) {
disk_signal = output.data ();
}
- if (start_sample < playback_sample) {
- cerr << owner()->name() << " SS = " << start_sample << " PS = " << playback_sample << endl;
- abort ();
+ if (speed > 0) {
+ if (start_sample < playback_sample) {
+ cerr << owner()->name() << " SS = " << start_sample << " PS = " << playback_sample << endl;
+ abort ();
+ }
+ } else if (speed < 0) {
+ if (playback_sample < start_sample) {
+ cerr << owner()->name() << " SS = " << start_sample << " PS = " << playback_sample << " REVERSE" << endl;
+ abort ();
+ }
}
- if (start_sample != playback_sample) {
+ if ((speed > 0) && (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)) {
if (disk_samples_to_consume <= (samplecnt_t) chaninfo->rw_vector.len[0]) {
if (fabsf (speed) != 1.0f) {
- (void) interpolation.interpolate (
- n, disk_samples_to_consume,
- chaninfo->rw_vector.buf[0],
- disk_signal);
+ samplecnt_t ocnt = nframes;
+ samplecnt_t icnt = chaninfo->rw_vector.len[0];
+ (void) interpolation.interpolate (n, icnt, chaninfo->rw_vector.buf[0], ocnt, disk_signal);
} else if (speed != 0.0) {
memcpy (disk_signal, chaninfo->rw_vector.buf[0], sizeof (Sample) * disk_samples_to_consume);
}
if (disk_samples_to_consume <= total) {
- /* We have enough samples, but not in one lump.
- */
-
if (fabsf (speed) != 1.0f) {
- interpolation.interpolate (n, chaninfo->rw_vector.len[0],
- chaninfo->rw_vector.buf[0],
- disk_signal);
- disk_signal += chaninfo->rw_vector.len[0];
- interpolation.interpolate (n, disk_samples_to_consume - chaninfo->rw_vector.len[0],
- chaninfo->rw_vector.buf[1],
- disk_signal);
+ samplecnt_t ocnt = nframes;
+ interpolation.interpolate (n, chaninfo->rw_vector.len[0], chaninfo->rw_vector.buf[0], ocnt, disk_signal);
+
+ if (ocnt < nframes) {
+ disk_signal += ocnt;
+ ocnt = nframes - ocnt;
+ interpolation.interpolate (n, chaninfo->rw_vector.len[1], chaninfo->rw_vector.buf[1], ocnt, disk_signal);
+ }
+
} else if (speed != 0.0) {
+
memcpy (disk_signal,
chaninfo->rw_vector.buf[0],
chaninfo->rw_vector.len[0] * sizeof (Sample));
chaninfo->buf->increment_read_ptr (disk_samples_to_consume);
- monitor_mix:
-
if (ms & MonitoringInput) {
/* mix the disk signal into the input signal (already in bufs) */
mix_buffers_no_gain (output.data(), disk_signal, disk_samples_to_consume);
/* assume all are the same size */
samplecnt_t size = c->front()->buf->bufsize();
- std::auto_ptr<Sample> mixdown_buffer (new Sample[size]);
- std::auto_ptr<float> gain_buffer (new float[size]);
+ boost::scoped_ptr<Sample> mixdown_buffer (new Sample[size]);
+ boost::scoped_ptr<float> gain_buffer (new float[size]);
/* reduce size so that we can fill the buffer correctly (ringbuffers
can only handle size-1, otherwise they appear to be empty)
*/
{
- std::auto_ptr<Sample> mix_buf (new Sample[2*1048576]);
- std::auto_ptr<float> gain_buf (new float[2*1048576]);
+ boost::scoped_ptr<Sample> mix_buf (new Sample[2*1048576]);
+ boost::scoped_ptr<float> gain_buf (new float[2*1048576]);
int ret = refill_audio (mix_buf.get(), gain_buf.get(), (partial_fill ? _chunk_samples : 0));