fix types for MIDI source API, and remove unusued loop length member

This commit is contained in:
Paul Davis 2021-01-22 13:41:15 -07:00
parent 4e761807bf
commit 12855c1a83
3 changed files with 25 additions and 20 deletions

View File

@ -148,12 +148,10 @@ class LIBARDOUR_API MidiSource : virtual public Source
*
* @param position The timeline position the source now starts at.
* @param capture_length The current length of the capture, which may not
* be zero if record is armed while rolling.
* @param loop_length The loop length if looping, otherwise zero.
* be zero if record is armed while rolling. In samples because we
* record using timestamps derived from the audio engine.
*/
void mark_write_starting_now (samplecnt_t position,
samplecnt_t capture_length,
samplecnt_t loop_length);
void mark_write_starting_now (timepos_t const & position, samplecnt_t capture_length);
/* like ::mark_streaming_write_completed() but with more arguments to
* allow control over MIDI-specific behaviour. Expected to be used only
@ -233,10 +231,7 @@ class LIBARDOUR_API MidiSource : virtual public Source
bool _writing;
/** The total duration of the current capture. */
samplepos_t _capture_length;
/** Length of transport loop during current capture, or zero. */
samplepos_t _capture_loop_length;
samplecnt_t _capture_length;
/** Map of interpolation styles to use for Parameters; if they are not in this map,
* the correct interpolation style can be obtained from EventTypeMap::interpolation_of ()

View File

@ -395,8 +395,16 @@ void
DiskWriter::non_realtime_locate (samplepos_t position)
{
if (_midi_write_source) {
#warning NUTEMPO maybe fixme perhaps take sources time domain into account here e.g. beats
_midi_write_source->set_natural_position (timepos_t (position));
timepos_t pos;
if (time_domain() == Temporal::AudioTime) {
pos = timepos_t (position);
} else {
const timepos_t b (position);
pos = timepos_t (b.beats());
}
_midi_write_source->set_natural_position (pos);
}
DiskIOProcessor::non_realtime_locate (position);
@ -524,7 +532,14 @@ DiskWriter::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
if (_midi_write_source) {
assert (_capture_start_sample);
_midi_write_source->mark_write_starting_now (_capture_start_sample, _capture_captured, loop_length.samples());
timepos_t start (_capture_start_sample);
if (time_domain() != Temporal::AudioTime) {
start = timepos_t (start.beats());
}
_midi_write_source->mark_write_starting_now (start, _capture_captured);
}
g_atomic_int_set (&_samples_pending_write, 0);

View File

@ -67,7 +67,6 @@ MidiSource::MidiSource (Session& s, string name, Source::Flag flags)
: Source(s, DataType::MIDI, name, flags)
, _writing(false)
, _capture_length(0)
, _capture_loop_length(0)
{
}
@ -75,7 +74,6 @@ MidiSource::MidiSource (Session& s, const XMLNode& node)
: Source(s, node)
, _writing(false)
, _capture_length(0)
, _capture_loop_length(0)
{
if (set_state (node, Stateful::loading_state_version)) {
throw failed_constructor();
@ -324,9 +322,7 @@ MidiSource::mark_streaming_midi_write_started (const Lock& lock, NoteMode mode)
}
void
MidiSource::mark_write_starting_now (samplecnt_t position,
samplecnt_t capture_length,
samplecnt_t loop_length)
MidiSource::mark_write_starting_now (timepos_t const & position, samplecnt_t capture_length)
{
/* I'm not sure if this is the best way to approach this, but
_capture_length needs to be set up with the transport sample
@ -339,10 +335,9 @@ MidiSource::mark_write_starting_now (samplecnt_t position,
because it is not RT-safe.
*/
#warning NUTEMPO QUESTION should the time domain here reflect some setting for this source?
set_natural_position (timepos_t (position));
set_natural_position (position);
_capture_length = capture_length;
_capture_loop_length = loop_length;
/* currently prefer to compute length in beats, since that matches 6.x
* and earlier behavior