diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2009-01-30 09:01:02 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2009-01-30 09:01:02 +0000 |
commit | 15554385d6227e46457b0ab8fa36179ce237b0fe (patch) | |
tree | ea509c35848d9bc812620587bdf98dbebd9797c4 /libs/ardour/internal_send.cc | |
parent | 70b939da4f9d4097160e32f2373a7a5ff8f4957f (diff) |
add forgotten files
git-svn-id: svn://localhost/ardour2/branches/3.0@4465 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/internal_send.cc')
-rw-r--r-- | libs/ardour/internal_send.cc | 212 |
1 files changed, 212 insertions, 0 deletions
diff --git a/libs/ardour/internal_send.cc b/libs/ardour/internal_send.cc new file mode 100644 index 0000000000..60c0cde6af --- /dev/null +++ b/libs/ardour/internal_send.cc @@ -0,0 +1,212 @@ +/* + Copyright (C) 2009 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include <algorithm> + +#include <pbd/xml++.h> + +#include <ardour/internal_send.h> +#include <ardour/session.h> +#include <ardour/port.h> +#include <ardour/audio_port.h> +#include <ardour/buffer_set.h> +#include <ardour/meter.h> +#include <ardour/panner.h> + +#include "i18n.h" + +using namespace ARDOUR; +using namespace PBD; + +InternalSend::InternalSend (Session& s, Placement p, boost::shared_ptr<IO> dst) + : IOProcessor (s, string_compose (_(">%1"), dst->name()), p, + -1, -1, -1, -1, + DataType::AUDIO, false) + , destination (dst) +{ + _metering = false; + + destination->input_changed.connect (mem_fun (*this, &InternalSend::destination_io_config_changed)); + + destination_io_config_changed (ConfigurationChanged, this); + + ProcessorCreated (this); /* EMIT SIGNAL */ +} + +InternalSend::~InternalSend () +{ + GoingAway (); +} + +void +InternalSend::destination_io_config_changed (IOChange c, void* src) +{ + if (!(c & ConfigurationChanged)) { + return; + } + + _io->disconnect_outputs (this); + + _io->ensure_io (ChanCount::ZERO, destination->n_inputs(), false, this); + + PortSet::const_iterator us (_io->outputs().begin()); + PortSet::const_iterator them (destination->inputs().begin ()); + + for (; us != _io->outputs().end() && them != destination->inputs().end(); ++us, ++them) { + (const_cast<Port*>(&(*us)))->connect (const_cast<Port*>(&(*them))); + } +} + +XMLNode& +InternalSend::get_state(void) +{ + fatal << X_("InternalSend::get_state() called - should never happen") << endmsg; + /*NOTREACHED*/ + return *(new XMLNode ("foo")); +} + +int +InternalSend::set_state(const XMLNode& node) +{ + fatal << X_("InternalSend::set_state() called - should never happen") << endmsg; + /*NOTREACHED*/ + return 0; +} + +void +InternalSend::run_in_place (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset) +{ + if (active()) { + + // we have to copy the input, because IO::deliver_output may alter the buffers + // in-place, which a send must never do. otherwise its gain settings will + // affect the signal seen later in the parent Route. + + // BufferSet& sendbufs = _session.get_mix_buffers(bufs.count()); + + // sendbufs.read_from (bufs, nframes); + // assert(sendbufs.count() == bufs.count()); + + _io->deliver_output (bufs, start_frame, end_frame, nframes, offset); + + if (_metering) { + if (_io->effective_gain() == 0) { + _io->peak_meter().reset(); + } else { + _io->peak_meter().run_in_place(_io->output_buffers(), start_frame, end_frame, nframes, offset); + } + } + + } else { + _io->silence (nframes, offset); + if (_metering) { + _io->peak_meter().reset(); + } + } +} + +void +InternalSend::set_metering (bool yn) +{ + _metering = yn; + + if (!_metering) { + /* XXX possible thread hazard here */ + _io->peak_meter().reset(); + } +} + +bool +InternalSend::can_support_io_configuration (const ChanCount& in, ChanCount& out_is_ignored) const +{ + /* number of outputs is fixed (though mutable by changing the I/O configuration + of the destination) + */ + + cerr << "IS: testing I/O config in=" << in.n_audio() << " out=" << out_is_ignored.n_audio() << endl; + + if (in == _io->n_outputs()) { + return 1; + } + + return -1; +} + +bool +InternalSend::configure_io (ChanCount in, ChanCount out) +{ + cerr << "Configure IS for in " << in.n_audio() << " out = " << out.n_audio() << endl; + + /* we're transparent no matter what. fight the power. */ + + if (out != in) { + return false; + } + + _io->set_output_maximum (in); + _io->set_output_minimum (in); + _io->set_input_maximum (ChanCount::ZERO); + _io->set_input_minimum (ChanCount::ZERO); + + out = _io->n_outputs(); + + Processor::configure_io(in, out); + + _io->reset_panner(); + + return true; +} + +ChanCount +InternalSend::output_streams() const +{ + // this method reflects the idea that from the perspective of the Route's ProcessorList, + // a send is just a passthrough. that doesn't match what the Send actually does with its + // data, but since what it does is invisible to the Route, it appears to be a passthrough. + + return _io->n_outputs (); +} + +ChanCount +InternalSend::input_streams() const +{ + return _configured_input; +} + + +void +InternalSend::expect_inputs (const ChanCount& expected) +{ + if (expected != expected_inputs) { + expected_inputs = expected; + _io->reset_panner (); + } +} + +void +InternalSend::activate () +{ + Processor::activate (); +} + +void +InternalSend::deactivate () +{ + Processor::deactivate (); +} |