remove Auditioner::prepare_playlist() - not used
[ardour.git] / libs / ardour / auditioner.cc
index 85fa4cce31b832084a241aa24c810f8a30db406e..b10ac2ca44d7124dcd31eea8ab5287bd4babc8a8 100644 (file)
@@ -22,7 +22,6 @@
 #include "pbd/error.h"
 
 #include "ardour/amp.h"
-#include "ardour/audio_diskstream.h"
 #include "ardour/audio_port.h"
 #include "ardour/audioengine.h"
 #include "ardour/audioplaylist.h"
@@ -30,7 +29,8 @@
 #include "ardour/auditioner.h"
 #include "ardour/data_type.h"
 #include "ardour/delivery.h"
-#include "ardour/midi_diskstream.h"
+#include "ardour/disk_reader.h"
+#include "ardour/midi_playlist.h"
 #include "ardour/midi_region.h"
 #include "ardour/plugin.h"
 #include "ardour/plugin_insert.h"
@@ -215,37 +215,8 @@ Auditioner::data_type () const {
        }
 }
 
-boost::shared_ptr<Diskstream>
-Auditioner::create_diskstream () {
-
-       {
-               AudioDiskstream::Flag dflags = AudioDiskstream::Flag (0);
-               dflags = AudioDiskstream::Flag (dflags | AudioDiskstream::Hidden);
-               _diskstream_audio = boost::shared_ptr<AudioDiskstream> (new AudioDiskstream (_session, name(), dflags));
-       }
-
-       {
-               MidiDiskstream::Flag dflags = MidiDiskstream::Flag (0);
-               dflags = MidiDiskstream::Flag (dflags | MidiDiskstream::Hidden);
-               _diskstream_midi = boost::shared_ptr<Diskstream> (new MidiDiskstream (_session, name(), dflags));
-               _diskstream_midi->do_refill_with_alloc ();
-               _diskstream_midi->playlist()->set_orig_track_id (id());
-       }
-
-       return _diskstream_audio;
-}
-
-int
-Auditioner::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, int declick, bool& need_butler) {
-       if (_midi_audition) {
-               return roll_midi(nframes, start_frame, end_frame, declick, need_butler);
-       } else {
-               return roll_audio(nframes, start_frame, end_frame, declick, need_butler);
-       }
-}
-
 int
-Auditioner::roll_midi (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, int declick, bool& need_butler)
+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()) {
@@ -254,17 +225,13 @@ Auditioner::roll_midi (pframes_t nframes, framepos_t start_frame, framepos_t end
 
        assert(_active);
 
-       framecnt_t playback_distance = nframes;
-       boost::shared_ptr<MidiDiskstream> diskstream = midi_diskstream();
        BufferSet& bufs = _session.get_route_buffers (n_process_buffers());
-       MidiBuffer& mbuf (bufs.get_midi (0));
-       _silent = false;
 
-       ChanCount cnt (DataType::MIDI, 1);
-       cnt.set (DataType::AUDIO, bufs.count().n_audio());
-       bufs.set_count (cnt);
+       _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 };
@@ -274,20 +241,9 @@ Auditioner::roll_midi (pframes_t nframes, framepos_t start_frame, framepos_t end
                        buf[1] = MIDI_CTL_RESET_CONTROLLERS;
                        mbuf.push_back(0, 3, buf);
                }
-               process_output_buffers (bufs, start_frame, start_frame+1, 1, false, false);
-
-               for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
-                       boost::shared_ptr<Delivery> d = boost::dynamic_pointer_cast<Delivery> (*i);
-                       if (d) {
-                               d->flush_buffers (nframes);
-                       }
-               }
        }
 
-       diskstream->get_playback (mbuf, nframes);
-
-       process_output_buffers (bufs, start_frame, end_frame, nframes,
-                               declick, (!diskstream->record_enabled() && !_session.transport_stopped()));
+       process_output_buffers (bufs, start_frame, end_frame, nframes, declick, !_session.transport_stopped());
 
        for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
                boost::shared_ptr<Delivery> d = boost::dynamic_pointer_cast<Delivery> (*i);
@@ -296,73 +252,9 @@ Auditioner::roll_midi (pframes_t nframes, framepos_t start_frame, framepos_t end
                }
        }
 
-       need_butler = diskstream->commit (playback_distance);
-       return 0;
-}
-
-
-int
-Auditioner::roll_audio (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(n_outputs().n_total() > 0);
-       assert(_active);
-
-       int dret;
-       framecnt_t playback_distance;
-       framepos_t transport_frame = _session.transport_frame();
-       boost::shared_ptr<AudioDiskstream> diskstream = audio_diskstream();
-       BufferSet& bufs = _session.get_route_buffers (n_process_buffers ());
-
-       _silent = false;
-       _amp->apply_gain_automation(false);
-
-       if ((dret = diskstream->process (bufs, transport_frame, nframes, playback_distance, (monitoring_state() == MonitoringDisk))) != 0) {
-               need_butler = diskstream->commit (playback_distance);
-               silence (nframes);
-               return dret;
-       }
-
-       process_output_buffers (bufs, start_frame, end_frame, nframes, declick, (!diskstream->record_enabled() && _session.transport_rolling()));
-       need_butler = diskstream->commit (playback_distance);
        return 0;
 }
 
-void
-Auditioner::set_diskstream (boost::shared_ptr<Diskstream> ds)
-{
-       Track::set_diskstream (ds);
-
-       _diskstream->set_track (this);
-       _diskstream->set_record_enabled (false);
-       _diskstream->request_input_monitoring (false);
-
-       DiskstreamChanged (); /* EMIT SIGNAL */
-}
-
-AudioPlaylist&
-Auditioner::prepare_playlist ()
-{
-       // used by CrossfadeEditor::audition()
-
-       _midi_audition = false;
-       set_diskstream(_diskstream_audio);
-       if (_synth_added) {
-               remove_processor(asynth);
-               _synth_added = false;
-       }
-
-       // FIXME auditioner is still audio-only
-       boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist>(_diskstream->playlist());
-       assert(apl);
-
-       apl->clear ();
-       return *apl;
-}
-
 void
 Auditioner::audition_region (boost::shared_ptr<Region> region)
 {
@@ -378,7 +270,7 @@ Auditioner::audition_region (boost::shared_ptr<Region> region)
        if (boost::dynamic_pointer_cast<AudioRegion>(region) != 0) {
 
                _midi_audition = false;
-               set_diskstream(_diskstream_audio);
+
                if (_synth_added) {
                        remove_processor(asynth);
                        _synth_added = false;
@@ -390,14 +282,8 @@ Auditioner::audition_region (boost::shared_ptr<Region> region)
                the_region = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (region));
                the_region->set_position (0);
 
-               _diskstream->playlist()->drop_regions ();
-               _diskstream->playlist()->add_region (the_region, 0, 1);
-
-               if (_diskstream->n_channels().n_audio() < the_region->n_channels()) {
-                       audio_diskstream()->add_channel (the_region->n_channels() - _diskstream->n_channels().n_audio());
-               } else if (_diskstream->n_channels().n_audio() > the_region->n_channels()) {
-                       audio_diskstream()->remove_channel (_diskstream->n_channels().n_audio() - the_region->n_channels());
-               }
+               _disk_reader->audio_playlist()->drop_regions ();
+               _disk_reader->audio_playlist()->add_region (the_region, 0, 1);
 
                ProcessorStreams ps;
                {
@@ -405,14 +291,14 @@ Auditioner::audition_region (boost::shared_ptr<Region> region)
 
                        if (configure_processors (&ps)) {
                                error << string_compose (_("Cannot setup auditioner processing flow for %1 channels"),
-                                                        _diskstream->n_channels()) << endmsg;
+                                                        region->n_channels()) << endmsg;
                                return;
                        }
                }
 
        } else if (boost::dynamic_pointer_cast<MidiRegion>(region)) {
                _midi_audition = true;
-               set_diskstream(_diskstream_midi);
+
                the_region.reset();
                _import_position = region->position();
 
@@ -420,9 +306,9 @@ Auditioner::audition_region (boost::shared_ptr<Region> region)
                midi_region = (boost::dynamic_pointer_cast<MidiRegion> (RegionFactory::create (region)));
                midi_region->set_position (_import_position);
 
-               _diskstream->playlist()->drop_regions ();
-               _diskstream->playlist()->add_region (midi_region, _import_position, 1);
-               midi_diskstream()->reset_tracker();
+               _disk_reader->midi_playlist()->drop_regions ();
+               _disk_reader->midi_playlist()->add_region (midi_region, _import_position, 1);
+               _disk_reader->reset_tracker();
 
                ProcessorStreams ps;
 
@@ -435,7 +321,6 @@ Auditioner::audition_region (boost::shared_ptr<Region> region)
                        lookup_synth();
                }
 
-
                if (!_synth_added && asynth) {
                        int rv = add_processor (asynth, PreFader, &ps, true);
                        if (rv) {
@@ -452,7 +337,7 @@ Auditioner::audition_region (boost::shared_ptr<Region> region)
 
                        if (configure_processors (&ps)) {
                                error << string_compose (_("Cannot setup auditioner processing flow for %1 channels"),
-                                                        _diskstream->n_channels()) << endmsg;
+                                                        region->n_channels()) << endmsg;
                                return;
                        }
                }
@@ -485,7 +370,7 @@ Auditioner::audition_region (boost::shared_ptr<Region> region)
                offset = 0;
        }
 
-       _diskstream->seek (offset, true);
+       _disk_reader->seek (offset, true);
        current_frame = offset;
 
        g_atomic_int_set (&_auditioning, 1);
@@ -515,9 +400,7 @@ Auditioner::play_audition (framecnt_t nframes)
                _seek_complete = false;
                _seeking = false;
                _seek_frame = -1;
-               if (_midi_audition && midi_diskstream()) {
-                       midi_diskstream()->reset_tracker();
-               }
+               _disk_reader->reset_tracker();
        }
 
        if(!_seeking) {
@@ -604,18 +487,14 @@ ChanCount
 Auditioner::input_streams () const
 {
        /* auditioner never has any inputs - its channel configuration
-                depends solely on the region we are auditioning.
-                */
+          depends solely on the region we are auditioning.
+       */
 
-       if (!_midi_audition && audio_diskstream()) {
-               return audio_diskstream()->n_channels();
-       }
-       if (_midi_audition && midi_diskstream()) {
-               ChanCount cnt (DataType::MIDI, 1);
-               return cnt;
+       if (_disk_reader) {
+               return _disk_reader->input_streams ();
        }
 
-       return ChanCount ();
+       return ChanCount (DataType::AUDIO, 1);
 }
 
 MonitorState
@@ -624,14 +503,3 @@ Auditioner::monitoring_state () const
        return MonitoringDisk;
 }
 
-boost::shared_ptr<AudioDiskstream>
-Auditioner::audio_diskstream() const
-{
-       return boost::dynamic_pointer_cast<AudioDiskstream> (_diskstream);
-}
-
-boost::shared_ptr<MidiDiskstream>
-Auditioner::midi_diskstream() const
-{
-       return boost::dynamic_pointer_cast<MidiDiskstream> (_diskstream);
-}