13
0

Give Processor::run a new parameter to say whether or not the run method must leave

the passed-in buffers valid.  In the case where the main outs delivery is the last
processor in a route, this is not necessary (and wasteful).  If another processor
(e.g. a meter) follows the main outs, the passed-in (scratch) buffers must be valid
or the meter will get garbage data.

Fixes meters displaying phantom signals in some cases.


git-svn-id: svn://localhost/ardour2/branches/3.0@6180 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2009-11-25 23:29:52 +00:00
parent fe59ade874
commit 47b8fa2169
22 changed files with 42 additions and 31 deletions

View File

@ -72,7 +72,7 @@ Amp::configure_io (ChanCount in, ChanCount out)
}
void
Amp::run (BufferSet& bufs, sframes_t /*start_frame*/, sframes_t /*end_frame*/, nframes_t nframes)
Amp::run (BufferSet& bufs, sframes_t /*start_frame*/, sframes_t /*end_frame*/, nframes_t nframes, bool)
{
gain_t mute_gain;

View File

@ -44,7 +44,7 @@ public:
bool can_support_io_configuration (const ChanCount& in, ChanCount& out) const;
bool configure_io (ChanCount in, ChanCount out);
void run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes);
void run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes, bool);
bool apply_gain() const { return _apply_gain; }
void apply_gain(bool yn) { _apply_gain = yn; }

View File

@ -65,7 +65,7 @@ public:
bool can_support_io_configuration (const ChanCount& in, ChanCount& out) const;
bool configure_io (ChanCount in, ChanCount out);
void run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes);
void run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes, bool);
/* supplemental method used with MIDI */

View File

@ -40,7 +40,7 @@ class InternalReturn : public Return
XMLNode& get_state(void);
int set_state(const XMLNode&, int version);
void run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes);
void run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes, bool);
bool configure_io (ChanCount in, ChanCount out);
bool can_support_io_configuration (const ChanCount& in, ChanCount& out) const;
void set_block_size (nframes_t);

View File

@ -40,7 +40,7 @@ class InternalSend : public Send
XMLNode& get_state(void);
int set_state(const XMLNode& node, int version);
void run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes);
void run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes, bool);
bool feeds (boost::shared_ptr<Route> other) const;
bool can_support_io_configuration (const ChanCount& in, ChanCount& out) const;
bool configure_io (ChanCount in, ChanCount out);

View File

@ -61,7 +61,7 @@ public:
bool configure_io (ChanCount in, ChanCount out);
/** Compute peaks */
void run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes);
void run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes, bool);
float peak_power (uint32_t n) {
if (n < _visible_peak_power.size()) {

View File

@ -54,7 +54,7 @@ class PluginInsert : public Processor
XMLNode& get_state(void);
int set_state(const XMLNode&, int version);
void run (BufferSet& in, sframes_t start_frame, sframes_t end_frame, nframes_t nframes);
void run (BufferSet& in, sframes_t start_frame, sframes_t end_frame, nframes_t nframes, bool);
void silence (nframes_t nframes);
void activate ();

View File

@ -51,7 +51,7 @@ class PortInsert : public IOProcessor
XMLNode& get_state(void);
int set_state (const XMLNode&, int version);
void run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes);
void run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes, bool);
nframes_t signal_latency() const;

View File

@ -70,7 +70,10 @@ class Processor : public SessionObject, public AutomatableControls, public Laten
virtual void set_block_size (nframes_t /*nframes*/) {}
virtual void run (BufferSet& /*bufs*/, sframes_t /*start_frame*/, sframes_t /*end_frame*/, nframes_t /*nframes*/) {}
/** @param result_required true if, on return from this method, bufs is required to contain valid data;
* if false, the method need not bother writing to bufs if it doesn't want to.
*/
virtual void run (BufferSet& /*bufs*/, sframes_t /*start_frame*/, sframes_t /*end_frame*/, nframes_t /*nframes*/, bool /*result_required*/) {}
virtual void silence (nframes_t /*nframes*/) {}
virtual void activate () { _pending_active = true; ActiveChanged(); }

View File

@ -44,7 +44,7 @@ public:
uint32_t bit_slot() const { return _bitslot; }
void run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes);
void run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes, bool);
boost::shared_ptr<Amp> amp() const { return _amp; }
boost::shared_ptr<PeakMeter> meter() const { return _meter; }

View File

@ -57,7 +57,7 @@ class Send : public Delivery
uint32_t pans_required() const { return _configured_input.n_audio(); }
void run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes);
void run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes, bool);
bool can_support_io_configuration (const ChanCount& in, ChanCount& out) const;
bool configure_io (ChanCount in, ChanCount out);

View File

@ -675,7 +675,7 @@ AudioTrack::export_stuff (BufferSet& buffers, sframes_t start, nframes_t nframes
for (i = _processors.begin(); i != _processors.end(); ++i) {
boost::shared_ptr<Processor> processor;
if ((processor = boost::dynamic_pointer_cast<Processor>(*i)) != 0) {
processor->run (buffers, start, start+nframes, nframes);
processor->run (buffers, start, start+nframes, nframes, true);
}
}

View File

@ -275,7 +275,7 @@ Delivery::configure_io (ChanCount in, ChanCount out)
}
void
Delivery::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes)
Delivery::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes, bool result_required)
{
assert (_output);
@ -318,7 +318,9 @@ Delivery::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nfra
*/
_output->silence (nframes);
Amp::apply_simple_gain (bufs, nframes, 0.0);
if (result_required) {
Amp::apply_simple_gain (bufs, nframes, 0.0);
}
goto out;
} else if (tgain != 1.0) {
@ -333,6 +335,10 @@ Delivery::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nfra
_panner->run (bufs, output_buffers(), start_frame, end_frame, nframes);
if (result_required) {
bufs.read_from (output_buffers (), nframes);
}
} else {
// Do a 1:1 copy of data to output ports

View File

@ -44,7 +44,7 @@ InternalReturn::InternalReturn (Session& s, const XMLNode& node)
}
void
InternalReturn::run (BufferSet& bufs, sframes_t /*start_frame*/, sframes_t /*end_frame*/, nframes_t nframes)
InternalReturn::run (BufferSet& bufs, sframes_t /*start_frame*/, sframes_t /*end_frame*/, nframes_t nframes, bool)
{
if (!_active && !_pending_active) {
return;

View File

@ -71,7 +71,7 @@ InternalSend::send_to_going_away ()
}
void
InternalSend::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes)
InternalSend::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes, bool)
{
if ((!_active && !_pending_active) || !target || !_send_to) {
_meter->reset ();
@ -114,7 +114,7 @@ InternalSend::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame,
// so that we don't overwrite the main automation data for the route amp
// _amp->setup_gain_automation (start_frame, end_frame, nframes);
_amp->run (mixbufs, start_frame, end_frame, nframes);
_amp->run (mixbufs, start_frame, end_frame, nframes, true);
/* XXX NEED TO PAN */
@ -124,7 +124,7 @@ InternalSend::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame,
if (_amp->gain_control()->get_value() == 0) {
_meter->reset();
} else {
_meter->run (mixbufs, start_frame, end_frame, nframes);
_meter->run (mixbufs, start_frame, end_frame, nframes, true);
}
}

View File

@ -1484,7 +1484,7 @@ IO::process_input (boost::shared_ptr<Processor> proc, sframes_t start_frame, sfr
/* don't read the data into new buffers - just use the port buffers directly */
bufs.attach_buffers (_ports, nframes, 0);
proc->run (bufs, start_frame, end_frame, nframes);
proc->run (bufs, start_frame, end_frame, nframes, true);
}
void

View File

@ -71,7 +71,7 @@ Metering::update_meters()
* be set to 0.
*/
void
PeakMeter::run (BufferSet& bufs, sframes_t /*start_frame*/, sframes_t /*end_frame*/, nframes_t nframes)
PeakMeter::run (BufferSet& bufs, sframes_t /*start_frame*/, sframes_t /*end_frame*/, nframes_t nframes, bool)
{
if (!_active && !_pending_active) {
return;

View File

@ -367,7 +367,7 @@ PluginInsert::silence (nframes_t nframes)
}
void
PluginInsert::run (BufferSet& bufs, sframes_t /*start_frame*/, sframes_t /*end_frame*/, nframes_t nframes)
PluginInsert::run (BufferSet& bufs, sframes_t /*start_frame*/, sframes_t /*end_frame*/, nframes_t nframes, bool)
{
if (_active || _pending_active) {

View File

@ -66,7 +66,7 @@ PortInsert::~PortInsert ()
}
void
PortInsert::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes)
PortInsert::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes, bool)
{
if (_output->n_ports().n_total() == 0) {
return;
@ -78,7 +78,7 @@ PortInsert::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nf
goto out;
}
_out->run (bufs, start_frame, end_frame, nframes);
_out->run (bufs, start_frame, end_frame, nframes, true);
_input->collect_input (bufs, nframes, ChanCount::ZERO);
out:

View File

@ -120,7 +120,7 @@ Return::set_state (const XMLNode& node, int version)
}
void
Return::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes)
Return::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes, bool)
{
if ((!_active && !_pending_active) || _input->n_ports() == ChanCount::ZERO) {
return;
@ -132,13 +132,13 @@ Return::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframe
// Can't automate gain for sends or returns yet because we need different buffers
// so that we don't overwrite the main automation data for the route amp
// _amp->setup_gain_automation (start_frame, end_frame, nframes);
_amp->run (bufs, start_frame, end_frame, nframes);
_amp->run (bufs, start_frame, end_frame, nframes, true);
if (_metering) {
if (_amp->gain_control()->get_value() == 0) {
_meter->reset();
} else {
_meter->run (bufs, start_frame, end_frame, nframes);
_meter->run (bufs, start_frame, end_frame, nframes, true);
}
}

View File

@ -423,13 +423,15 @@ Route::process_output_buffers (BufferSet& bufs,
if (rm.locked()) {
for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
if (bufs.count() != (*i)->input_streams()) {
cerr << _name << " bufs = " << bufs.count()
<< " input for " << (*i)->name() << " = " << (*i)->input_streams()
<< endl;
}
assert (bufs.count() == (*i)->input_streams());
(*i)->run (bufs, start_frame, end_frame, nframes);
(*i)->run (bufs, start_frame, end_frame, nframes, *i != _processors.back());
bufs.set_count (ChanCount::max(bufs.count(), (*i)->output_streams()));
}

View File

@ -87,7 +87,7 @@ Send::deactivate ()
}
void
Send::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes)
Send::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes, bool)
{
if (_output->n_ports() == ChanCount::ZERO) {
_meter->reset ();
@ -114,11 +114,11 @@ Send::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_
// Can't automate gain for sends or returns yet because we need different buffers
// so that we don't overwrite the main automation data for the route amp
// _amp->setup_gain_automation (start_frame, end_frame, nframes);
_amp->run (sendbufs, start_frame, end_frame, nframes);
_amp->run (sendbufs, start_frame, end_frame, nframes, true);
/* deliver to outputs */
Delivery::run (sendbufs, start_frame, end_frame, nframes);
Delivery::run (sendbufs, start_frame, end_frame, nframes, true);
/* consider metering */
@ -126,7 +126,7 @@ Send::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_
if (_amp->gain_control()->get_value() == 0) {
_meter->reset();
} else {
_meter->run (*_output_buffers, start_frame, end_frame, nframes);
_meter->run (*_output_buffers, start_frame, end_frame, nframes, true);
}
}