Improve import status messages slightly.
[ardour.git] / libs / ardour / audio_track.cc
index 878ad1118fdfc6127decdb0bccb6204a536dae61..8e68eb014077c22e9045144c5a27962dfbc228fa 100644 (file)
@@ -36,6 +36,7 @@
 #include "ardour/buffer_set.h"
 #include "ardour/io_processor.h"
 #include "ardour/panner.h"
+#include "ardour/meter.h"
 #include "ardour/playlist_factory.h"
 #include "ardour/plugin_insert.h"
 #include "ardour/processor.h"
@@ -139,14 +140,8 @@ AudioTrack::deprecated_use_diskstream_connections ()
 
        diskstream->deprecated_io_node = 0;
 
-       set_input_minimum (ChanCount::ZERO);
-       set_input_maximum (ChanCount::INFINITE);
-       set_output_minimum (ChanCount::ZERO);
-       set_output_maximum (ChanCount::INFINITE);
-       
        if ((prop = node.property ("gain")) != 0) {
-               set_gain (atof (prop->value().c_str()), this);
-               _gain = _gain_control->user_float();
+               _amp->set_gain (atof (prop->value().c_str()), this);
        }
 
        if ((prop = node.property ("input-connection")) != 0) {
@@ -165,10 +160,10 @@ AudioTrack::deprecated_use_diskstream_connections ()
                        }
                }
 
-               connect_input_ports_to_bundle (c, this);
+               _input->connect_ports_to_bundle (c, this);
 
        } else if ((prop = node.property ("inputs")) != 0) {
-               if (set_inputs (prop->value())) {
+               if (_input->set_ports (prop->value())) {
                        error << string_compose(_("improper input channel list in XML node (%1)"), prop->value()) << endmsg;
                        return -1;
                }
@@ -178,17 +173,17 @@ AudioTrack::deprecated_use_diskstream_connections ()
 }
 
 int
-AudioTrack::set_diskstream (boost::shared_ptr<AudioDiskstream> ds, void *src)
+AudioTrack::set_diskstream (boost::shared_ptr<AudioDiskstream> ds, void * /*src*/)
 {
        _diskstream = ds;
-       _diskstream->set_io (*this);
+       _diskstream->set_route (*this);
        _diskstream->set_destructive (_mode == Destructive);
        _diskstream->set_non_layered (_mode == NonLayered);
 
        if (audio_diskstream()->deprecated_io_node) {
 
-               if (!connecting_legal) {
-                       ConnectingLegal.connect (mem_fun (*this, &AudioTrack::deprecated_use_diskstream_connections));
+               if (!IO::connecting_legal) {
+                       IO::ConnectingLegal.connect (mem_fun (*this, &AudioTrack::deprecated_use_diskstream_connections));
                } else {
                        deprecated_use_diskstream_connections ();
                }
@@ -198,7 +193,7 @@ AudioTrack::set_diskstream (boost::shared_ptr<AudioDiskstream> ds, void *src)
        _diskstream->monitor_input (false);
 
        ic_connection.disconnect();
-       ic_connection = input_changed.connect (mem_fun (*_diskstream, &Diskstream::handle_input_change));
+       ic_connection = _input->changed.connect (mem_fun (*_diskstream, &Diskstream::handle_input_change));
 
        DiskstreamChanged (); /* EMIT SIGNAL */
 
@@ -484,8 +479,6 @@ AudioTrack::roll (nframes_t nframes, sframes_t start_frame, sframes_t end_frame,
 
        transport_frame = _session.transport_frame();
 
-       prepare_inputs (nframes);
-
        if ((nframes = check_initial_delay (nframes, transport_frame)) == 0) {
 
                /* need to do this so that the diskstream sets its
@@ -506,7 +499,7 @@ AudioTrack::roll (nframes_t nframes, sframes_t start_frame, sframes_t end_frame,
        /* special condition applies */
        
        if (_meter_point == MeterInput) {
-               just_meter_input (start_frame, end_frame, nframes);
+               _input->process_input (_meter, start_frame, end_frame, nframes);
        }
 
        if (diskstream->record_enabled() && !can_record && !_session.config.get_auto_input()) {
@@ -590,7 +583,7 @@ AudioTrack::roll (nframes_t nframes, sframes_t start_frame, sframes_t end_frame,
                        limit = blimit;
 
                } else {
-                       for (i = 0, n = 1; i < blimit; ++i, ++n) {
+                       for (i = 0, n = 1; i < limit; ++i, ++n) {
                                memcpy (bufs.get_audio (i).data(), b, sizeof (Sample) * nframes); 
                                if (n < diskstream->n_channels().n_audio()) {
                                        tmpb = diskstream->playback_buffer(n);
@@ -599,11 +592,19 @@ AudioTrack::roll (nframes_t nframes, sframes_t start_frame, sframes_t end_frame,
                                        }
                                }
                        }
+
+                       /* try to leave any MIDI buffers alone */
+                       
+                       ChanCount chn;
+                       chn.set_audio (limit);
+                       chn.set_midi (_input->n_ports().n_midi());
+                       bufs.set_count (chn);
                }
 
                /* don't waste time with automation if we're recording or we've just stopped (yes it can happen) */
 
                if (!diskstream->record_enabled() && _session.transport_rolling()) {
+#ifdef XXX_MOVE_THIS_TO_AMP
                        Glib::Mutex::Lock am (data().control_lock(), Glib::TRY_LOCK);
                        
                        if (am.locked() && gain_control()->automation_playback()) {
@@ -611,6 +612,7 @@ AudioTrack::roll (nframes_t nframes, sframes_t start_frame, sframes_t end_frame,
                                                gain_control()->list()->curve().rt_safe_get_vector (
                                                        start_frame, end_frame, _session.gain_automation_buffer(), nframes));
                        }
+#endif
                }
 
                process_output_buffers (bufs, start_frame, end_frame, nframes, (!_session.get_record_enabled() || !Config->get_do_not_record_plugins()), declick);
@@ -672,7 +674,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_in_place (buffers, start, start+nframes, nframes);
+                       processor->run (buffers, start, start+nframes, nframes);
                }
        }
        
@@ -764,9 +766,9 @@ AudioTrack::freeze (InterThreadInfo& itt)
 
        new_playlist = PlaylistFactory::create (DataType::AUDIO, _session, new_playlist_name, false);
 
-       _freeze_record.gain = _gain;
-       _freeze_record.gain_automation_state = _gain_control->automation_state();
-       _freeze_record.pan_automation_state = _panner->automation_state();
+       _freeze_record.gain = _amp->gain();
+       _freeze_record.gain_automation_state = _amp->gain_control()->automation_state();
+       /* XXX need main outs automation state _freeze_record.pan_automation_state = _mainpanner->automation_state(); */
 
        region_name = new_playlist_name;
 
@@ -789,8 +791,8 @@ AudioTrack::freeze (InterThreadInfo& itt)
        /* reset stuff that has already been accounted for in the freeze process */
        
        set_gain (1.0, this);
-       _gain_control->set_automation_state (Off);
-       _panner->set_automation_state (Off);
+       _amp->gain_control()->set_automation_state (Off);
+       /* XXX need to use _main_outs _panner->set_automation_state (Off); */
 
        _freeze_record.state = Frozen;
        FreezeChange(); /* EMIT SIGNAL */
@@ -816,8 +818,8 @@ AudioTrack::unfreeze ()
                
                _freeze_record.playlist.reset ();
                set_gain (_freeze_record.gain, this);
-               _gain_control->set_automation_state (_freeze_record.gain_automation_state);
-               _panner->set_automation_state (_freeze_record.pan_automation_state);
+               _amp->gain_control()->set_automation_state (_freeze_record.gain_automation_state);
+               /* XXX need to use _main_outs _panner->set_automation_state (_freeze_record.pan_automation_state); */
        }
 
        _freeze_record.state = UnFrozen;