: Processor (s, str)
, _flags (f)
, i_am_the_modifier (false)
- , _buffer_reallocation_required (false)
, _seek_required (false)
, _slaved (false)
- , loop_location (0)
, in_set_state (false)
, playback_sample (0)
- , wrap_buffer_size (0)
- , speed_buffer_size (0)
, _need_butler (false)
, channels (new ChannelList)
, _midi_buf (new MidiRingBuffer<samplepos_t> (s.butler()->midi_diskstream_buffer_size()))
, _samples_written_to_ringbuffer (0)
, _samples_read_from_ringbuffer (0)
{
- midi_interpolation.add_channel_to (0,0);
set_display_to_user (false);
}
+DiskIOProcessor::~DiskIOProcessor ()
+{
+ {
+ RCUWriter<ChannelList> writer (channels);
+ boost::shared_ptr<ChannelList> c = writer.get_copy();
+
+ for (ChannelList::iterator chan = c->begin(); chan != c->end(); ++chan) {
+ delete *chan;
+ }
+
+ c->clear();
+ }
+
+ channels.flush ();
+}
+
+
void
DiskIOProcessor::init ()
{
if (in.n_midi() > 0 && !_midi_buf) {
const size_t size = _session.butler()->midi_diskstream_buffer_size();
_midi_buf = new MidiRingBuffer<samplepos_t>(size);
- midi_interpolation.add_channel_to (0,0);
changed = true;
}
return 0;
}
-int
-DiskIOProcessor::set_loop (Location *location)
-{
- if (location) {
- if (location->start() >= location->end()) {
- error << string_compose(_("Location \"%1\" not valid for track loop (start >= end)"), location->name()) << endl;
- return -1;
- }
- }
-
- loop_location = location;
-
- LoopSet (location); /* EMIT SIGNAL */
- return 0;
-}
-
void
DiskIOProcessor::non_realtime_locate (samplepos_t location)
{
void
DiskIOProcessor::non_realtime_speed_change ()
{
- if (_buffer_reallocation_required) {
- _buffer_reallocation_required = false;
- }
-
if (_seek_required) {
seek (_session.transport_sample(), true);
_seek_required = false;
bool
DiskIOProcessor::realtime_speed_change ()
{
- const samplecnt_t required_wrap_size = (samplecnt_t) ceil (_session.get_block_size() * fabs (_session.transport_speed())) + 2;
- bool _buffer_reallocation_required;
-
- if (required_wrap_size > wrap_buffer_size) {
- _buffer_reallocation_required = true;
- } else {
- _buffer_reallocation_required = false;
- }
-
- return _buffer_reallocation_required;
+ return true;
}
int
return 0;
}
-int
-DiskIOProcessor::add_channel_to (boost::shared_ptr<ChannelList> c, uint32_t how_many)
-{
- while (how_many--) {
- c->push_back (new ChannelInfo (_session.butler()->audio_diskstream_playback_buffer_size()));
- interpolation.add_channel_to (_session.butler()->audio_diskstream_playback_buffer_size(), speed_buffer_size);
- DEBUG_TRACE (DEBUG::DiskIO, string_compose ("%1: new channel, write space = %2 read = %3\n",
- name(),
- c->back()->buf->write_space(),
- c->back()->buf->read_space()));
- }
-
- return 0;
-}
-
int
DiskIOProcessor::add_channel (uint32_t how_many)
{
while (how_many-- && !c->empty()) {
delete c->back();
c->pop_back();
- interpolation.remove_channel_from ();
}
return 0;
}
DiskIOProcessor::ChannelInfo::ChannelInfo (samplecnt_t bufsize)
+ : rbuf (0)
+ , wbuf (0)
+ , capture_transition_buf (0)
+ , curr_capture_cnt (0)
{
- buf = new RingBufferNPT<Sample> (bufsize);
-
- /* touch the ringbuffer buffer, which will cause
- them to be mapped into locked physical RAM if
- we're running with mlockall(). this doesn't do
- much if we're not.
- */
-
- memset (buf->buffer(), 0, sizeof (Sample) * buf->bufsize());
- capture_transition_buf = new RingBufferNPT<CaptureTransition> (256);
-}
-
-void
-DiskIOProcessor::ChannelInfo::resize (samplecnt_t bufsize)
-{
- delete buf;
- buf = new RingBufferNPT<Sample> (bufsize);
- memset (buf->buffer(), 0, sizeof (Sample) * buf->bufsize());
}
DiskIOProcessor::ChannelInfo::~ChannelInfo ()
{
- delete buf;
- buf = 0;
-
+ delete rbuf;
+ delete wbuf;
delete capture_transition_buf;
+ rbuf = 0;
+ wbuf = 0;
capture_transition_buf = 0;
}