X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fmidi_region.cc;h=7511aadce86b6631665c7a20ca2404eec664ee14;hb=e12e8716ba10ba337e298739cf59b401df805ae1;hp=abaf6d348455e96cf0593129f9741bad8a22641a;hpb=a4d8cc2e048b823fa33ac1976373cc46e6a6cb85;p=ardour.git diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index abaf6d3484..7511aadce8 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -109,9 +109,11 @@ MidiRegion::MidiRegion (boost::shared_ptr other, frameoffset_t { if (offset != 0) { _start_beats = (_session.tempo_map().exact_qn_at_frame (other->_position + offset, sub_num) - other->_quarter_note) + other->_start_beats; + update_length_beats (sub_num); + /* we've potentially shifted _start_beats, now reset _start frames to match */ + _start = _session.tempo_map().frames_between_quarter_notes (_quarter_note - _start_beats, _quarter_note); } - update_length_beats (sub_num); register_properties (); assert(_name.val().find("/") == string::npos); @@ -178,10 +180,18 @@ MidiRegion::clone (boost::shared_ptr newsrc) const Evoral::Beats const bend = bfc.from (_start + _length); { + boost::shared_ptr ms = midi_source(0); + Source::Lock lm (ms->mutex()); + + if (!ms->model()) { + ms->load_model (lm); + } + /* Lock our source since we'll be reading from it. write_to() will - take a lock on newsrc. */ - Source::Lock lm (midi_source(0)->mutex()); - if (midi_source(0)->write_to (lm, newsrc, bbegin, bend)) { + take a lock on newsrc. + */ + + if (ms->write_to (lm, newsrc, bbegin, bend)) { return boost::shared_ptr (); } }