+ via_monitor = false;
+
+ if (left.empty() || left == "default") {
+ if (_session.monitor_out() && _session.monitor_out()->input()->audio (0)) {
+ left = _session.monitor_out()->input()->audio (0)->name();
+ } else {
+ if (outputs.size() > 0) {
+ left = outputs[0];
+ }
+ }
+ }
+
+ if (right.empty() || right == "default") {
+ if (_session.monitor_out() && _session.monitor_out()->input()->audio (1)) {
+ right = _session.monitor_out()->input()->audio (1)->name();
+ } else {
+ if (outputs.size() > 1) {
+ right = outputs[1];
+ }
+ }
+ }
+
+ _output->disconnect (this);
+
+ if (left.empty() && right.empty()) {
+ if (_output->n_ports().n_audio() == 0) {
+ /* ports not set up, so must be during startup */
+ warning << _("no outputs available for auditioner - manual connection required") << endmsg;
+ }
+ } else {
+
+ if (_output->n_ports().n_audio() == 0) {
+
+ /* create (and connect) new ports */
+
+ _main_outs->defer_pan_reset ();
+
+ if (left.length()) {
+ _output->add_port (left, this, DataType::AUDIO);
+ }
+
+ if (right.length()) {
+ _output->add_port (right, this, DataType::AUDIO);
+ }
+
+ _main_outs->allow_pan_reset ();
+ _main_outs->reset_panner ();
+
+ } else {
+
+ /* reconnect existing ports */
+
+ boost::shared_ptr<Port> oleft (_output->nth (0));
+ boost::shared_ptr<Port> oright (_output->nth (1));
+ if (oleft) {
+ oleft->connect (left);
+ }
+ if (oright) {
+ oright->connect (right);
+ }
+ }
+
+ }
+
+ if (_session.monitor_out () && _output->connected_to (_session.monitor_out ()->input())) {
+ via_monitor = true;
+ }
+
+ return 0;
+}
+
+
+DataType
+Auditioner::data_type () const {
+ if (_midi_audition) {
+ return DataType::MIDI;
+ } else {
+ return DataType::AUDIO;
+ }
+}
+
+int
+Auditioner::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, int declick, bool& need_butler)
+{
+ Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
+ if (!lm.locked()) {
+ return 0;
+ }
+
+ assert(_active);
+
+ BufferSet& bufs = _session.get_route_buffers (n_process_buffers());
+
+ _silent = false;
+ _amp->apply_gain_automation(false);
+
+ if (_queue_panic) {
+ MidiBuffer& mbuf (bufs.get_midi (0));
+ _queue_panic = false;
+ for (uint8_t chn = 0; chn < 0xf; ++chn) {
+ uint8_t buf[3] = { ((uint8_t) (MIDI_CMD_CONTROL | chn)), ((uint8_t) MIDI_CTL_SUSTAIN), 0 };
+ mbuf.push_back(0, 3, buf);
+ buf[1] = MIDI_CTL_ALL_NOTES_OFF;
+ mbuf.push_back(0, 3, buf);
+ buf[1] = MIDI_CTL_RESET_CONTROLLERS;
+ mbuf.push_back(0, 3, buf);
+ }
+ }