diff options
-rw-r--r-- | libs/ardour/ardour/configuration_vars.h | 3 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_diskstream.h | 3 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 6 | ||||
-rw-r--r-- | libs/ardour/audio_diskstream.cc | 14 | ||||
-rw-r--r-- | libs/ardour/io.cc | 1 | ||||
-rw-r--r-- | libs/ardour/midi_diskstream.cc | 78 | ||||
-rw-r--r-- | libs/ardour/midi_model.cc | 13 | ||||
-rw-r--r-- | libs/ardour/session_butler.cc | 13 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 3 |
9 files changed, 42 insertions, 92 deletions
diff --git a/libs/ardour/ardour/configuration_vars.h b/libs/ardour/ardour/configuration_vars.h index 95313b5b9b..4e2a14c07b 100644 --- a/libs/ardour/ardour/configuration_vars.h +++ b/libs/ardour/ardour/configuration_vars.h @@ -49,7 +49,8 @@ CONFIG_VARIABLE (RemoteModel, remote_model, "remote-model", MixerOrdered) /* disk operations */ CONFIG_VARIABLE (uint32_t, minimum_disk_io_bytes, "minimum-disk-io-bytes", 1024 * 256) -CONFIG_VARIABLE (float, track_buffer_seconds, "track-buffer-seconds", 5.0) +CONFIG_VARIABLE (float, audio_track_buffer_seconds, "track-buffer-seconds", 5.0) +CONFIG_VARIABLE (float, midi_track_buffer_seconds, "midi-track-buffer-seconds", 1.0) CONFIG_VARIABLE (uint32_t, disk_choice_space_threshold, "disk-choice-space-threshold", 57600000) CONFIG_VARIABLE (SampleFormat, native_file_data_format, "native-file-data-format", ARDOUR::FormatFloat) CONFIG_VARIABLE (HeaderFormat, native_file_header_format, "native-file-header-format", ARDOUR::WAVE) diff --git a/libs/ardour/ardour/midi_diskstream.h b/libs/ardour/ardour/midi_diskstream.h index 3e8e9c4156..28e80816a8 100644 --- a/libs/ardour/ardour/midi_diskstream.h +++ b/libs/ardour/ardour/midi_diskstream.h @@ -171,13 +171,10 @@ class MidiDiskstream : public Diskstream void engage_record_enable (); void disengage_record_enable (); - /* FIXME: too much code duplication in this class because of lack of ChannelInfo */ - MidiRingBuffer* _playback_buf; MidiRingBuffer* _capture_buf; MidiPort* _source_port; boost::shared_ptr<SMFSource> _write_source; - RingBufferNPT<CaptureTransition>* _capture_transition_buf; nframes_t _last_flush_frame; NoteMode _note_mode; }; diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 325b164c8d..b718d751b4 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -296,7 +296,8 @@ class Session : public PBD::StatefulDestructible bool have_captured() const { return _have_captured; } void refill_all_diskstream_buffers (); - uint32_t diskstream_buffer_size() const { return dstream_buffer_size; } + uint32_t audio_diskstream_buffer_size() const { return audio_dstream_buffer_size; } + uint32_t midi_diskstream_buffer_size() const { return midi_dstream_buffer_size; } uint32_t get_next_diskstream_id() const { return n_diskstreams(); } uint32_t n_diskstreams() const; @@ -1420,7 +1421,8 @@ class Session : public PBD::StatefulDestructible SerializedRCUManager<DiskstreamList> diskstreams; - uint32_t dstream_buffer_size; + uint32_t audio_dstream_buffer_size; + uint32_t midi_dstream_buffer_size; int load_diskstreams (const XMLNode&); /* routes stuff */ diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index 59e6007a6d..091e1df30f 100644 --- a/libs/ardour/audio_diskstream.cc +++ b/libs/ardour/audio_diskstream.cc @@ -861,18 +861,18 @@ AudioDiskstream::commit (nframes_t nframes) } if (_slaved) { - /*if (_io && _io->active()) {*/ + if (_io && _io->active()) { need_butler = c->front()->playback_buf->write_space() >= c->front()->playback_buf->bufsize() / 2; - /*} else { + } else { need_butler = false; - }*/ + } } else { - /*if (_io && _io->active()) {*/ + if (_io && _io->active()) { need_butler = c->front()->playback_buf->write_space() >= disk_io_chunk_frames || c->front()->capture_buf->read_space() >= disk_io_chunk_frames; - /*} else { + } else { need_butler = c->front()->capture_buf->read_space() >= disk_io_chunk_frames; - }*/ + } } if (commit_should_unlock) { @@ -2202,7 +2202,7 @@ int AudioDiskstream::add_channel_to (boost::shared_ptr<ChannelList> c, uint32_t how_many) { while (how_many--) { - c->push_back (new ChannelInfo(_session.diskstream_buffer_size(), speed_buffer_size, wrap_buffer_size)); + c->push_back (new ChannelInfo(_session.audio_diskstream_buffer_size(), speed_buffer_size, wrap_buffer_size)); } _n_channels.set(DataType::AUDIO, c->size()); diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index 71c051733e..5d4b41cf32 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -163,6 +163,7 @@ IO::IO (Session& s, const string& name, IO::IO (Session& s, const XMLNode& node, DataType dt) : Automatable (s, "unnamed io"), _output_buffers (new BufferSet()), + _active(true), _default_type (dt) { _meter = new PeakMeter (_session); diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc index b36e8da293..84fe21ce35 100644 --- a/libs/ardour/midi_diskstream.cc +++ b/libs/ardour/midi_diskstream.cc @@ -61,12 +61,7 @@ MidiDiskstream::MidiDiskstream (Session &sess, const string &name, Diskstream::F : Diskstream(sess, name, flag) , _playback_buf(0) , _capture_buf(0) - //, _current_playback_buffer(0) - //, _current_capture_buffer(0) - //, _playback_wrap_buffer(0) - //, _capture_wrap_buffer(0) , _source_port(0) - , _capture_transition_buf(0) , _last_flush_frame(0) , _note_mode(Sustained) { @@ -86,12 +81,7 @@ MidiDiskstream::MidiDiskstream (Session& sess, const XMLNode& node) : Diskstream(sess, node) , _playback_buf(0) , _capture_buf(0) - //, _current_playback_buffer(0) - //, _current_capture_buffer(0) - //, _playback_wrap_buffer(0) - //, _capture_wrap_buffer(0) , _source_port(0) - , _capture_transition_buf(0) , _last_flush_frame(0) , _note_mode(Sustained) { @@ -123,9 +113,8 @@ MidiDiskstream::init (Diskstream::Flag f) set_block_size (_session.get_block_size()); allocate_temporary_buffers (); - _playback_buf = new MidiRingBuffer (_session.diskstream_buffer_size()); - _capture_buf = new MidiRingBuffer (_session.diskstream_buffer_size()); - _capture_transition_buf = new RingBufferNPT<CaptureTransition> (128); + _playback_buf = new MidiRingBuffer (_session.midi_diskstream_buffer_size()); + _capture_buf = new MidiRingBuffer (_session.midi_diskstream_buffer_size()); _n_channels = ChanCount(DataType::MIDI, 1); @@ -141,10 +130,9 @@ MidiDiskstream::~MidiDiskstream () void MidiDiskstream::non_realtime_locate (nframes_t position) { - //cerr << "MDS: non_realtime_locate: " << position << endl; assert(_write_source); _write_source->set_timeline_position (position); - seek(position, true); // correct? + seek(position, false); } @@ -304,7 +292,6 @@ MidiDiskstream::set_destructive (bool yn) void MidiDiskstream::set_note_mode (NoteMode m) { - cout << "MDS: SET NOTE MODE: " << m << endl; _note_mode = m; midi_playlist()->set_note_mode(m); if (_write_source && _write_source->model()) @@ -403,21 +390,6 @@ MidiDiskstream::check_record_status (nframes_t transport_frame, nframes_t nframe } - if (_flags & Recordable) { - RingBufferNPT<CaptureTransition>::rw_vector transvec; - _capture_transition_buf->get_write_vector(&transvec); - - if (transvec.len[0] > 0) { - transvec.buf[0]->type = CaptureStart; - transvec.buf[0]->capture_val = capture_start_frame; - _capture_transition_buf->increment_write_ptr(1); - } else { - // bad! - fatal << X_("programming error: capture_transition_buf is full on rec start! inconceivable!") - << endmsg; - } - } - } else if (!record_enabled() || !can_record) { /* stop recording */ @@ -468,7 +440,7 @@ MidiDiskstream::process (nframes_t transport_frame, nframes_t nframes, nframes_t return 0; } - /* This lock is held until the end of AudioDiskstream::commit, so these two functions + /* This lock is held until the end of ::commit, so these two functions must always be called as a pair. The only exception is if this function returns a non-zero value, in which case, ::commit should not be called. */ @@ -642,12 +614,18 @@ MidiDiskstream::commit (nframes_t nframes) adjust_capture_position = 0; } + /* what audio does: + * can't do this with midi: write space is in bytes, chunk_frames is in frames if (_slaved) { need_butler = _playback_buf->write_space() >= _playback_buf->capacity() / 2; } else { need_butler = _playback_buf->write_space() >= disk_io_chunk_frames || _capture_buf->read_space() >= disk_io_chunk_frames; - } + }*/ + + /* we'll just keep the playback buffer full for now. + * this should be decreased to reduce edit latency */ + need_butler = _playback_buf->write_space() >= _playback_buf->capacity() / 2; if (commit_should_unlock) { state_lock.unlock(); @@ -664,9 +642,8 @@ MidiDiskstream::set_pending_overwrite (bool yn) /* called from audio thread, so we can use the read ptr and playback sample as we wish */ pending_overwrite = yn; - + overwrite_frame = playback_sample; - //overwrite_offset = channels.front().playback_buf->get_read_ptr(); } int @@ -682,8 +659,6 @@ MidiDiskstream::seek (nframes_t frame, bool complete_refill) Glib::Mutex::Lock lm (state_lock); int ret = -1; - //cerr << "MDS: seek: " << frame << endl; - _playback_buf->reset(); _capture_buf->reset(); @@ -826,35 +801,6 @@ MidiDiskstream::do_refill () return 0; } - /* if there are 2+ chunks of disk i/o possible for - this track, let the caller know so that it can arrange - for us to be called again, ASAP. - */ - - if (write_space >= (_slaved?3:2) * disk_io_chunk_frames) { - ret = 1; - } - - /* if we're running close to normal speed and there isn't enough - space to do disk_io_chunk_frames of I/O, then don't bother. - - at higher speeds, just do it because the sync between butler - and audio thread may not be good enough. - */ - - if ((write_space < disk_io_chunk_frames) && fabs (_actual_speed) < 2.0f) { - return 0; - } - - /* when slaved, don't try to get too close to the read pointer. this - leaves space for the buffer reversal to have something useful to - work with. - */ - - if (_slaved && write_space < (_playback_buf->capacity() / 2)) { - return 0; - } - if (reversed) { return 0; } diff --git a/libs/ardour/midi_model.cc b/libs/ardour/midi_model.cc index 863747c19f..d01bf4276b 100644 --- a/libs/ardour/midi_model.cc +++ b/libs/ardour/midi_model.cc @@ -193,14 +193,11 @@ const MidiModel::const_iterator& MidiModel::const_iterator::operator++() double x = 0.0, y = 0.0; const bool ret = _control_iter->automation_list->rt_safe_earliest_event_unlocked( _control_iter->x, DBL_MAX, x, y, false); - //cerr << "control_iter x:" << _control_iter->x << " y:" << _control_iter->y << endl; if (ret) { - //cerr << "Incremented " << _control_iter->automation_list->parameter().id() << " to " << x << endl; _control_iter->x = x; _control_iter->y = y; } else { - cerr << "Hit end of " << _control_iter->automation_list->parameter().id() << endl; _control_iter->automation_list.reset(); _control_iter->x = DBL_MAX; } @@ -340,11 +337,11 @@ size_t MidiModel::read(MidiRingBuffer& dst, nframes_t start, nframes_t nframes, _read_iter->size(), _read_iter->buffer()); - //cerr << this << " MidiModel::read event @ " << _read_iter->time() - //<< " type: " << hex << int(_read_iter->type()) << dec - //<< " note: " << int(_read_iter->note()) - //<< " velocity: " << int(_read_iter->velocity()) - //<< endl; + /*cerr << this << " MidiModel::read event @ " << _read_iter->time() + << " type: " << hex << int(_read_iter->type()) << dec + << " note: " << int(_read_iter->note()) + << " velocity: " << int(_read_iter->velocity()) + << endl;*/ ++_read_iter; ++read_events; diff --git a/libs/ardour/session_butler.cc b/libs/ardour/session_butler.cc index 2ac06e57dd..ec5de23caf 100644 --- a/libs/ardour/session_butler.cc +++ b/libs/ardour/session_butler.cc @@ -69,10 +69,15 @@ int Session::start_butler_thread () { /* size is in Samples, not bytes */ - - dstream_buffer_size = (uint32_t) floor (Config->get_track_buffer_seconds() * (float) frame_rate()); - - Crossfade::set_buffer_size (dstream_buffer_size); + audio_dstream_buffer_size = (uint32_t) floor (Config->get_audio_track_buffer_seconds() * (float) frame_rate()); + + /* size is in bytes + * XXX: Jack needs to tell us the MIDI buffer size + * (i.e. how many MIDI bytes we might see in a cycle) + */ + midi_dstream_buffer_size = (uint32_t) floor (Config->get_midi_track_buffer_seconds() * (float)frame_rate()); + + Crossfade::set_buffer_size (audio_dstream_buffer_size); butler_should_run = false; diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 0d0499b5a1..c228f3c47b 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -168,7 +168,8 @@ Session::first_stage_init (string fullpath, string snapshot_name) pending_locate_frame = 0; pending_locate_roll = false; pending_locate_flush = false; - dstream_buffer_size = 0; + audio_dstream_buffer_size = 0; + midi_dstream_buffer_size = 0; state_tree = 0; state_was_pending = false; set_next_event (); |