Flush audio-buffers for internal connections

Forward data for ports that are both internally and
externally connected.

e.g. click-io may be connected to a track as well as physical
outputs. Since the port is externally connected, data is written
to an internal buffer _data[], and only at cycle-end resampled
to engine-buffers.

However a track's recording the metronome is not externally
connected. Hence data is directly read from the engine-buffers.
Summing also happens at engine level, so data has to
be written back for downstream ports to read them in the same cycle.
This commit is contained in:
Robin Gareus 2023-03-07 15:36:14 +01:00
parent 77bb262c26
commit 62fc1d3c2e
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 24 additions and 0 deletions

View File

@ -42,6 +42,8 @@ public:
void cycle_end (pframes_t);
void cycle_split ();
void flush_buffers (pframes_t nframes);
/* reset SRC, clear out any state */
void reinit (bool with_ratio);

View File

@ -127,6 +127,22 @@ AudioPort::cycle_split ()
{
}
void
AudioPort::flush_buffers (pframes_t nframes)
{
if (!sends_output() || !_port_handle || !in_cycle ()) {
return;
}
if (!externally_connected () || !internally_connected ()) {
return;
}
/* port is both internally and externnally connected, make
* data available to internal connections which directly use
* port_engine.get_buffer () without resampling.
*/
copy_vector ((float*)port_engine.get_buffer (_port_handle, nframes), &_data[_global_port_buffer_offset], nframes);
}
void
AudioPort::reinit (bool with_ratio)
{

View File

@ -1700,6 +1700,12 @@ IO::copy_to_outputs (BufferSet& bufs, DataType type, pframes_t nframes, samplecn
port_buffer.read_from (*prev, nframes, offset);
++o;
}
/* when port is both externally and internally connected,
* make data directly available to downstream internal ports */
for (auto const& p : _ports) {
p->flush_buffers (nframes);
}
}
boost::shared_ptr<Port>