#include "pbd/enumwriter.h"
#include "pbd/convert.h"
+#include "ardour/midi_buffer.h"
+
#include "ardour/delivery.h"
#include "ardour/audio_buffer.h"
#include "ardour/amp.h"
/* deliver to an existing IO object */
Delivery::Delivery (Session& s, boost::shared_ptr<IO> io, boost::shared_ptr<MuteMaster> mm, const string& name, Role r)
- : IOProcessor(s, boost::shared_ptr<IO>(), (r == Listen ? boost::shared_ptr<IO>() : io), name)
+ : IOProcessor(s, boost::shared_ptr<IO>(), (role_requires_output_ports (r) ? io : boost::shared_ptr<IO>()), name)
, _role (r)
, _output_buffers (new BufferSet())
, _current_gain (1.0)
/* deliver to a new IO object */
Delivery::Delivery (Session& s, boost::shared_ptr<MuteMaster> mm, const string& name, Role r)
- : IOProcessor(s, false, (r == Listen ? false : true), name)
+ : IOProcessor(s, false, (role_requires_output_ports (r) ? true : false), name)
, _role (r)
, _output_buffers (new BufferSet())
, _current_gain (1.0)
CycleStart.connect (mem_fun (*this, &Delivery::cycle_start));
}
+std::string
+Delivery::display_name () const
+{
+ switch (_role) {
+ case Main:
+ return _("main outs");
+ break;
+ case Listen:
+ return _("listen");
+ break;
+ case Send:
+ case Insert:
+ default:
+ return name();
+ }
+}
+
void
-Delivery::cycle_start (nframes_t nframes)
+Delivery::cycle_start (nframes_t /*nframes*/)
{
_output_offset = 0;
_no_outs_cuz_we_no_monitor = false;
bool
Delivery::visible () const
{
- if (_role & Main) {
- return false;
- }
-
return true;
}
bool
Delivery::can_support_io_configuration (const ChanCount& in, ChanCount& out) const
{
- out = in;
- return true;
+ if (_role == Main) {
+
+ /* the out buffers will be set to point to the port output buffers
+ of our output object.
+ */
+
+ if (_output) {
+ if (_output->n_ports() != ChanCount::ZERO) {
+ out = _output->n_ports();
+ return true;
+ } else {
+ /* not configured yet - we will passthru */
+ out = in;
+ return true;
+ }
+ } else {
+ fatal << "programming error: this should never be reached" << endmsg;
+ /*NOTREACHED*/
+ }
+
+
+ } else if (_role == Insert) {
+
+ /* the output buffers will be filled with data from the *input* ports
+ of this Insert.
+ */
+
+ if (_input) {
+ if (_input->n_ports() != ChanCount::ZERO) {
+ out = _input->n_ports();
+ return true;
+ } else {
+ /* not configured yet - we will passthru */
+ out = in;
+ return true;
+ }
+ } else {
+ fatal << "programming error: this should never be reached" << endmsg;
+ /*NOTREACHED*/
+ }
+
+ } else {
+ fatal << "programming error: this should never be reached" << endmsg;
+ }
+
+ return false;
}
bool
Delivery::configure_io (ChanCount in, ChanCount out)
{
- if (out != in) { // always 1:1
+ /* check configuration by comparison with our I/O port configuration, if appropriate.
+ see ::can_support_io_configuration() for comments
+ */
+
+ if (_role == Main) {
+
+ if (_output) {
+ if (_output->n_ports() != out) {
+ if (_output->n_ports() != ChanCount::ZERO) {
+ fatal << _name << " programming error: configure_io with nports = " << _output->n_ports() << " called with " << in << " and " << out << " with " << _output->n_ports() << " output ports" << endmsg;
+ /*NOTREACHED*/
+ } else {
+ /* I/O not yet configured */
+ }
+ }
+ }
+
+ } else if (_role == Insert) {
+
+ if (_input) {
+ if (_input->n_ports() != in) {
+ if (_input->n_ports() != ChanCount::ZERO) {
+ fatal << _name << " programming error: configure_io called with " << in << " and " << out << " with " << _input->n_ports() << " input ports" << endmsg;
+ /*NOTREACHED*/
+ } else {
+ /* I/O not yet configured */
+ }
+ }
+ }
+ }
+
+ if (!Processor::configure_io (in, out)) {
return false;
}
reset_panner ();
-
- return Processor::configure_io (in, out);
+
+ return true;
}
void
Delivery::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes)
{
+ assert (_output);
+
+ PortSet& ports (_output->ports());
+ gain_t tgain;
+
if (_output->n_ports ().get (_output->default_type()) == 0) {
- return;
+ goto out;
+ }
+
+ if (!_active && !_pending_active) {
+ _output->silence (nframes);
+ goto out;
}
/* this setup is not just for our purposes, but for anything that comes after us in the
processing pathway that wants to use this->output_buffers() for some reason.
*/
- PortSet& ports (_output->ports());
output_buffers().attach_buffers (ports, nframes, _output_offset);
// this Delivery processor is not a derived type, and thus we assume
// the main output stage of a Route). Contrast with Send::run()
// which cannot do this.
- gain_t tgain = target_gain ();
+ tgain = target_gain ();
if (tgain != _current_gain) {
/* we were quiet last time, and we're still supposed to be quiet.
Silence the outputs, and make sure the buffers are quiet too,
*/
-
+
_output->silence (nframes);
Amp::apply_simple_gain (bufs, nframes, 0.0);
-
- return;
+ goto out;
} else if (tgain != 1.0) {
Amp::apply_simple_gain (bufs, nframes, tgain);
}
- // Attach output buffers to port buffers
-
if (_panner && _panner->npanners() && !_panner->bypassed()) {
// Use the panner to distribute audio to output port buffers
_output->copy_to_outputs (bufs, DataType::MIDI, nframes, _output_offset);
}
}
-}
+ out:
+ _active = _pending_active;
+}
XMLNode&
Delivery::state (bool full_state)
gain_t
Delivery::target_gain ()
{
+ /* if we've been requested to deactivate, our target gain is zero */
+
+ if (!_pending_active) {
+ return 0.0;
+ }
+
/* if we've been told not to output because its a monitoring situation and
we're not monitoring, then be quiet.
*/
break;
case Send:
case Insert:
- if (_placement == PreFader) {
- mp = MuteMaster::PreFader;
- } else {
- mp = MuteMaster::PostFader;
- }
+ case Aux:
+ /* XXX FIX ME this is wrong, we need per-delivery muting */
+ mp = MuteMaster::PreFader;
break;
}
}
void
-Delivery::output_changed (IOChange change, void* src)
+Delivery::output_changed (IOChange change, void* /*src*/)
{
if (change & ARDOUR::ConfigurationChanged) {
reset_panner ();