diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2017-04-03 23:36:12 +0200 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2017-09-18 11:40:53 -0400 |
commit | 35c7274cc96a04f166df78249e66ae4a32a53a66 (patch) | |
tree | 99794daed4a289bf9164d0864d46f4773397fbaa /libs | |
parent | d16ae875be9d113c3cb0ec9e8311f3bb5dab9bfa (diff) |
remove Diskstream from Track and derivatives; get ardour to actually startup
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/auditioner.h | 5 | ||||
-rw-r--r-- | libs/ardour/ardour/disk_io.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/disk_writer.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_track.h | 9 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 6 | ||||
-rw-r--r-- | libs/ardour/ardour/track.h | 14 | ||||
-rw-r--r-- | libs/ardour/audio_track.cc | 2 | ||||
-rw-r--r-- | libs/ardour/auditioner.cc | 6 | ||||
-rw-r--r-- | libs/ardour/disk_io.cc | 43 | ||||
-rw-r--r-- | libs/ardour/disk_reader.cc | 33 | ||||
-rw-r--r-- | libs/ardour/disk_writer.cc | 19 | ||||
-rw-r--r-- | libs/ardour/midi_track.cc | 28 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 60 | ||||
-rw-r--r-- | libs/ardour/track.cc | 125 |
14 files changed, 135 insertions, 219 deletions
diff --git a/libs/ardour/ardour/auditioner.h b/libs/ardour/ardour/auditioner.h index 1dbe0cd81e..fc52c7e6f0 100644 --- a/libs/ardour/ardour/auditioner.h +++ b/libs/ardour/ardour/auditioner.h @@ -96,9 +96,6 @@ class LIBARDOUR_API Auditioner : public Track int export_stuff (BufferSet&, framepos_t, framecnt_t, boost::shared_ptr<Processor>, bool, bool, bool) { return -1; } - boost::shared_ptr<Diskstream> diskstream_factory (XMLNode const &) - { return boost::shared_ptr<Diskstream> (); } - private: boost::shared_ptr<AudioRegion> the_region; boost::shared_ptr<MidiRegion> midi_region; @@ -115,8 +112,6 @@ class LIBARDOUR_API Auditioner : public Track bool _synth_changed; bool _queue_panic; - boost::shared_ptr<Diskstream> _diskstream_audio; - boost::shared_ptr<Diskstream> _diskstream_midi; boost::shared_ptr<Processor> asynth; void drop_ports (); diff --git a/libs/ardour/ardour/disk_io.h b/libs/ardour/ardour/disk_io.h index c10dad54a1..54d4254a69 100644 --- a/libs/ardour/ardour/disk_io.h +++ b/libs/ardour/ardour/disk_io.h @@ -113,6 +113,8 @@ class LIBARDOUR_API DiskIOProcessor : public Processor PBD::Signal1<void,DataType> PlaylistChanged; + virtual void adjust_buffering() = 0; + protected: friend class Auditioner; virtual int seek (framepos_t which_sample, bool complete_refill = false) = 0; diff --git a/libs/ardour/ardour/disk_writer.h b/libs/ardour/ardour/disk_writer.h index d0f3672cbd..4a5612fec9 100644 --- a/libs/ardour/ardour/disk_writer.h +++ b/libs/ardour/ardour/disk_writer.h @@ -131,6 +131,8 @@ class LIBARDOUR_API DiskWriter : public DiskIOProcessor void transport_looped (framepos_t transport_frame); void transport_stopped_wallclock (struct tm&, time_t, bool abort); + void adjust_buffering (); + protected: friend class Track; int do_flush (RunContext context, bool force = false); diff --git a/libs/ardour/ardour/midi_track.h b/libs/ardour/ardour/midi_track.h index ea6e4e3636..0aff566b1c 100644 --- a/libs/ardour/ardour/midi_track.h +++ b/libs/ardour/ardour/midi_track.h @@ -48,9 +48,6 @@ public: void realtime_locate (); void non_realtime_locate (framepos_t); - boost::shared_ptr<Diskstream> create_diskstream (); - void set_diskstream (boost::shared_ptr<Diskstream>); - bool can_be_record_enabled (); bool can_be_record_safe (); @@ -150,20 +147,14 @@ private: MidiChannelFilter _playback_filter; MidiChannelFilter _capture_filter; - virtual boost::shared_ptr<Diskstream> diskstream_factory (XMLNode const &); - void write_out_of_band_data (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, framecnt_t nframes); void set_state_part_two (); void set_state_part_three (); - int no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, bool state_changing); void push_midi_input_to_step_edit_ringbuffer (framecnt_t nframes); - void diskstream_data_recorded (boost::weak_ptr<MidiSource>); - PBD::ScopedConnection _diskstream_data_recorded_connection; - void track_input_active (IOChange, void*); void map_input_active (bool); diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 43f0c95d98..4c848ec366 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -115,7 +115,6 @@ class Butler; class Click; class ControllableDescriptor; class CoreSelection; -class Diskstream; class ExportHandler; class ExportStatus; class Graph; @@ -283,8 +282,6 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop void refresh_disk_space (); - int load_diskstreams_2X (XMLNode const &, int); - int load_routes (const XMLNode&, int); boost::shared_ptr<RouteList> get_routes() const { return routes.reader (); @@ -2036,9 +2033,6 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop void rt_set_controls (boost::shared_ptr<ControlList>, double val, PBD::Controllable::GroupControlDisposition group_override); void rt_clear_all_solo_state (boost::shared_ptr<RouteList>, bool yn, PBD::Controllable::GroupControlDisposition group_override); - /** temporary list of Diskstreams used only during load of 2.X sessions */ - std::list<boost::shared_ptr<Diskstream> > _diskstreams_2X; - void set_session_range_location (framepos_t, framepos_t); void setup_midi_machine_control (); diff --git a/libs/ardour/ardour/track.h b/libs/ardour/ardour/track.h index 33c967f088..91e02b921e 100644 --- a/libs/ardour/ardour/track.h +++ b/libs/ardour/ardour/track.h @@ -26,7 +26,6 @@ #include "ardour/interthread_info.h" #include "ardour/recordable.h" #include "ardour/route.h" -#include "ardour/public_diskstream.h" namespace ARDOUR { @@ -35,10 +34,10 @@ class Playlist; class RouteGroup; class Source; class Region; -class Diskstream; class DiskReader; class DiskWriter; class IO; +class Location; class MonitorControl; class RecordEnableControl; class RecordSafeControl; @@ -50,7 +49,7 @@ class RecordSafeControl; * to be played from disk, and modifies that object during recording and * editing. */ -class LIBARDOUR_API Track : public Route, public Recordable, public PublicDiskstream +class LIBARDOUR_API Track : public Route, public Recordable { public: Track (Session&, std::string name, PresentationInfo::Flag f = PresentationInfo::Flag (0), TrackMode m = Normal, DataType default_type = DataType::AUDIO); @@ -136,11 +135,8 @@ class LIBARDOUR_API Track : public Route, public Recordable, public PublicDiskst bool can_be_record_enabled (); bool can_be_record_safe (); - bool using_diskstream_id (PBD::ID) const; - void set_block_size (pframes_t); - /* PublicDiskstream interface */ boost::shared_ptr<Playlist> playlist (); void request_input_monitoring (bool); void ensure_input_monitoring (bool); @@ -163,7 +159,7 @@ class LIBARDOUR_API Track : public Route, public Recordable, public PublicDiskst void non_realtime_set_speed (); int overwrite_existing_buffers (); framecnt_t get_captured_frames (uint32_t n = 0) const; - int set_loop (Location *); + int set_loop (ARDOUR::Location *); void transport_looped (framepos_t); bool realtime_set_speed (double, bool); void transport_stopped_wallclock (struct tm &, time_t, bool); @@ -181,7 +177,7 @@ class LIBARDOUR_API Track : public Route, public Recordable, public PublicDiskst void set_align_choice (AlignChoice, bool force=false); void playlist_modified (); int use_playlist (DataType, boost::shared_ptr<Playlist>); - int find_and_use_playlist (DataType, std::string const & name); + int find_and_use_playlist (DataType, PBD::ID const &); int use_copy_playlist (); int use_new_playlist (); void adjust_playback_buffering (); @@ -195,8 +191,6 @@ class LIBARDOUR_API Track : public Route, public Recordable, public PublicDiskst protected: XMLNode& state (bool full); - boost::shared_ptr<Diskstream> _diskstream; - boost::shared_ptr<DiskReader> _disk_reader; boost::shared_ptr<DiskWriter> _disk_writer; boost::shared_ptr<Playlist> _playlists[DataType::num_types]; diff --git a/libs/ardour/audio_track.cc b/libs/ardour/audio_track.cc index 4076ed5056..56d82c3a19 100644 --- a/libs/ardour/audio_track.cc +++ b/libs/ardour/audio_track.cc @@ -254,7 +254,7 @@ AudioTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_fram fill_buffers_with_input (bufs, _input, nframes); - if (_meter_point == MeterInput && ((_monitoring_control->monitoring_choice() & MonitorInput) || _diskstream->record_enabled())) { + if (_meter_point == MeterInput && ((_monitoring_control->monitoring_choice() & MonitorInput) || _disk_writer->record_enabled())) { _meter->run (bufs, start_frame, end_frame, 1.0 /*speed()*/, nframes, true); } diff --git a/libs/ardour/auditioner.cc b/libs/ardour/auditioner.cc index 4426464adc..98d4f6c92a 100644 --- a/libs/ardour/auditioner.cc +++ b/libs/ardour/auditioner.cc @@ -510,7 +510,11 @@ Auditioner::input_streams () const depends solely on the region we are auditioning. */ - return _disk_reader->input_streams (); + if (_disk_reader) { + return _disk_reader->input_streams (); + } + + return ChanCount (DataType::AUDIO, 1); } MonitorState diff --git a/libs/ardour/disk_io.cc b/libs/ardour/disk_io.cc index 89aba80322..b7622bc9d4 100644 --- a/libs/ardour/disk_io.cc +++ b/libs/ardour/disk_io.cc @@ -17,11 +17,13 @@ */ +#include "pbd/debug.h" #include "pbd/error.h" #include "pbd/i18n.h" #include "ardour/audioplaylist.h" #include "ardour/butler.h" +#include "ardour/debug.h" #include "ardour/disk_io.h" #include "ardour/disk_reader.h" #include "ardour/disk_writer.h" @@ -62,7 +64,7 @@ DiskIOProcessor::DiskIOProcessor (Session& s, string const & str, Flag f) , speed_buffer_size (0) , _need_butler (false) , channels (new ChannelList) - , _midi_buf (0) + , _midi_buf (new MidiRingBuffer<framepos_t> (s.butler()->midi_diskstream_buffer_size())) , _frames_written_to_ringbuffer (0) , _frames_read_from_ringbuffer (0) { @@ -148,7 +150,7 @@ DiskIOProcessor::can_support_io_configuration (const ChanCount& in, ChanCount& o bool DiskIOProcessor::configure_io (ChanCount in, ChanCount out) { - Glib::Threads::Mutex::Lock lm (state_lock); + DEBUG_TRACE (DEBUG::DiskIO, string_compose ("Configuring %1 for in:%2 out:%3\n", name(), in, out)); RCUWriter<ChannelList> writer (channels); boost::shared_ptr<ChannelList> c = writer.get_copy(); @@ -213,9 +215,7 @@ DiskIOProcessor::non_realtime_locate (framepos_t location) void DiskIOProcessor::non_realtime_set_speed () { - if (_buffer_reallocation_required) - { - Glib::Threads::Mutex::Lock lm (state_lock); + if (_buffer_reallocation_required) { _buffer_reallocation_required = false; } @@ -368,27 +368,27 @@ DiskIOProcessor::use_playlist (DataType dt, boost::shared_ptr<Playlist> playlist return 0; } - { - Glib::Threads::Mutex::Lock lm (state_lock); + DEBUG_TRACE (DEBUG::DiskIO, string_compose ("%1: set to use playlist %2 (%3)\n", name(), playlist->name(), dt.to_string())); - if (playlist == _playlists[dt]) { - return 0; - } + if (playlist == _playlists[dt]) { + return 0; + } - playlist_connections.drop_connections (); + playlist_connections.drop_connections (); - if (_playlists[dt]) { - _playlists[dt]->release(); - } + if (_playlists[dt]) { + _playlists[dt]->release(); + } - _playlists[dt] = playlist; - playlist->use(); + _playlists[dt] = playlist; + playlist->use(); - playlist->ContentsChanged.connect_same_thread (playlist_connections, boost::bind (&DiskIOProcessor::playlist_modified, this)); - playlist->LayeringChanged.connect_same_thread (playlist_connections, boost::bind (&DiskIOProcessor::playlist_modified, this)); - playlist->DropReferences.connect_same_thread (playlist_connections, boost::bind (&DiskIOProcessor::playlist_deleted, this, boost::weak_ptr<Playlist>(playlist))); - playlist->RangesMoved.connect_same_thread (playlist_connections, boost::bind (&DiskIOProcessor::playlist_ranges_moved, this, _1, _2)); - } + playlist->ContentsChanged.connect_same_thread (playlist_connections, boost::bind (&DiskIOProcessor::playlist_modified, this)); + playlist->LayeringChanged.connect_same_thread (playlist_connections, boost::bind (&DiskIOProcessor::playlist_modified, this)); + playlist->DropReferences.connect_same_thread (playlist_connections, boost::bind (&DiskIOProcessor::playlist_deleted, this, boost::weak_ptr<Playlist>(playlist))); + playlist->RangesMoved.connect_same_thread (playlist_connections, boost::bind (&DiskIOProcessor::playlist_ranges_moved, this, _1, _2)); + + DEBUG_TRACE (DEBUG::DiskIO, string_compose ("%1 now use playlist %1 (%2)\n", name(), playlist->name(), playlist->id())); PlaylistChanged (dt); /* EMIT SIGNAL */ _session.set_dirty (); @@ -452,4 +452,3 @@ DiskIOProcessor::get_location_times(const Location* location, *length = *end - *start; } } - diff --git a/libs/ardour/disk_reader.cc b/libs/ardour/disk_reader.cc index 7cdbaf1a0f..cf3b29c306 100644 --- a/libs/ardour/disk_reader.cc +++ b/libs/ardour/disk_reader.cc @@ -59,7 +59,6 @@ DiskReader::DiskReader (Session& s, string const & str, DiskIOProcessor::Flag f) DiskReader::~DiskReader () { DEBUG_TRACE (DEBUG::Destruction, string_compose ("DiskReader %1 deleted\n", _name)); - Glib::Threads::Mutex::Lock lm (state_lock); for (uint32_t n = 0; n < DataType::num_types; ++n) { if (_playlists[n]) { @@ -241,13 +240,6 @@ DiskReader::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, boost::shared_ptr<ChannelList> c = channels.reader(); ChannelList::iterator chan; framecnt_t playback_distance = 0; - - Glib::Threads::Mutex::Lock sm (state_lock, Glib::Threads::TRY_LOCK); - - if (!sm.locked()) { - return; - } - const bool need_disk_signal = result_required || _monitoring_choice == MonitorDisk || _monitoring_choice == MonitorCue; if (fabsf (_actual_speed) != 1.0f) { @@ -586,8 +578,6 @@ DiskReader::seek (framepos_t frame, bool complete_refill) ChannelList::iterator chan; boost::shared_ptr<ChannelList> c = channels.reader(); - Glib::Threads::Mutex::Lock lm (state_lock); - for (n = 0, chan = c->begin(); chan != c->end(); ++chan, ++n) { (*chan)->buf->reset (); } @@ -1409,20 +1399,23 @@ DiskReader::refill_midi () return 0; } - uint32_t frames_read = g_atomic_int_get (&_frames_read_from_ringbuffer); - uint32_t frames_written = g_atomic_int_get (&_frames_written_to_ringbuffer); + if (_playlists[DataType::MIDI]) { - if ((frames_read < frames_written) && (frames_written - frames_read) >= midi_readahead) { - return 0; - } + const uint32_t frames_read = g_atomic_int_get (&_frames_read_from_ringbuffer); + const uint32_t frames_written = g_atomic_int_get (&_frames_written_to_ringbuffer); + + if ((frames_read < frames_written) && (frames_written - frames_read) >= midi_readahead) { + return 0; + } - framecnt_t to_read = midi_readahead - ((framecnt_t)frames_written - (framecnt_t)frames_read); + framecnt_t to_read = midi_readahead - ((framecnt_t)frames_written - (framecnt_t)frames_read); - to_read = min (to_read, (framecnt_t) (max_framepos - file_frame)); - to_read = min (to_read, (framecnt_t) write_space); + to_read = min (to_read, (framecnt_t) (max_framepos - file_frame)); + to_read = min (to_read, (framecnt_t) write_space); - if (midi_read (file_frame, to_read, reversed)) { - ret = -1; + if (midi_read (file_frame, to_read, reversed)) { + ret = -1; + } } return ret; diff --git a/libs/ardour/disk_writer.cc b/libs/ardour/disk_writer.cc index 32d22fb1ae..be6763e088 100644 --- a/libs/ardour/disk_writer.cc +++ b/libs/ardour/disk_writer.cc @@ -25,6 +25,7 @@ #include "ardour/audio_buffer.h" #include "ardour/audioplaylist.h" #include "ardour/audioregion.h" +#include "ardour/butler.h" #include "ardour/debug.h" #include "ardour/disk_writer.h" #include "ardour/midi_playlist.h" @@ -497,12 +498,6 @@ DiskWriter::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, nominally_recording = (can_record && re); - Glib::Threads::Mutex::Lock sm (state_lock, Glib::Threads::TRY_LOCK); - - if (!sm.locked()) { - return; - } - // Safeguard against situations where process() goes haywire when autopunching // and last_recordable_frame < first_recordable_frame @@ -883,8 +878,6 @@ DiskWriter::seek (framepos_t frame, bool complete_refill) ChannelList::iterator chan; boost::shared_ptr<ChannelList> c = channels.reader(); - Glib::Threads::Mutex::Lock lm (state_lock); - for (n = 0, chan = c->begin(); chan != c->end(); ++chan, ++n) { (*chan)->buf->reset (); } @@ -1697,3 +1690,13 @@ DiskWriter::use_destructive_playlist () /* the source list will never be reset for a destructive track */ } + +void +DiskWriter::adjust_buffering () +{ + boost::shared_ptr<ChannelList> c = channels.reader(); + + for (ChannelList::iterator chan = c->begin(); chan != c->end(); ++chan) { + (*chan)->resize (_session.butler()->audio_diskstream_capture_buffer_size()); + } +} diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc index 6cbf700f03..be85bc1d49 100644 --- a/libs/ardour/midi_track.cc +++ b/libs/ardour/midi_track.cc @@ -42,7 +42,6 @@ #include "ardour/disk_writer.h" #include "ardour/event_type_map.h" #include "ardour/meter.h" -#include "ardour/midi_diskstream.h" #include "ardour/midi_playlist.h" #include "ardour/midi_port.h" #include "ardour/midi_region.h" @@ -102,17 +101,6 @@ MidiTrack::init () return 0; } -boost::shared_ptr<Diskstream> -MidiTrack::create_diskstream () -{ - MidiDiskstream::Flag dflags = MidiDiskstream::Flag (MidiDiskstream::Recordable); - - assert(_mode != Destructive); - - return boost::shared_ptr<Diskstream> (new MidiDiskstream (_session, name(), dflags)); -} - - bool MidiTrack::can_be_record_safe () { @@ -348,7 +336,7 @@ MidiTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame if (!_active) { silence (nframes); - if (_meter_point == MeterInput && ((_monitoring_control->monitoring_choice() & MonitorInput) || _diskstream->record_enabled())) { + if (_meter_point == MeterInput && ((_monitoring_control->monitoring_choice() & MonitorInput) || _disk_writer->record_enabled())) { _meter->reset(); } return 0; @@ -364,7 +352,7 @@ MidiTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame /* filter captured data before meter sees it */ _capture_filter.filter (bufs); - if (_meter_point == MeterInput && ((_monitoring_control->monitoring_choice() & MonitorInput) || _diskstream->record_enabled())) { + if (_meter_point == MeterInput && ((_monitoring_control->monitoring_choice() & MonitorInput) || _disk_writer->record_enabled())) { _meter->run (bufs, start_frame, end_frame, 1.0 /*speed()*/, nframes, true); } @@ -769,12 +757,6 @@ MidiTrack::midi_playlist () return boost::dynamic_pointer_cast<MidiPlaylist> (_playlists[DataType::MIDI]); } -void -MidiTrack::diskstream_data_recorded (boost::weak_ptr<MidiSource> src) -{ - DataRecorded (src); /* EMIT SIGNAL */ -} - bool MidiTrack::input_active () const { @@ -816,12 +798,6 @@ MidiTrack::track_input_active (IOChange change, void* /* src */) } } -boost::shared_ptr<Diskstream> -MidiTrack::diskstream_factory (XMLNode const & node) -{ - return boost::shared_ptr<Diskstream> (new MidiDiskstream (_session, node)); -} - boost::shared_ptr<MidiBuffer> MidiTrack::get_gui_feed_buffer () const { diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index c818943e1d..1f6645bae8 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -1610,15 +1610,6 @@ Session::set_state (const XMLNode& node, int version) } } - if (version < 3000) { - if ((child = find_named_node (node, X_("DiskStreams"))) == 0) { - error << _("Session: XML state has no diskstreams section") << endmsg; - goto out; - } else if (load_diskstreams_2X (*child, version)) { - goto out; - } - } - if ((child = find_named_node (node, VCAManager::xml_node_name)) != 0) { _vca_manager->set_state (*child, version); } @@ -1634,9 +1625,6 @@ Session::set_state (const XMLNode& node, int version) Slavable::Assign (_vca_manager); /* EMIT SIGNAL */ - /* our diskstreams list is no longer needed as they are now all owned by their Route */ - _diskstreams_2X.clear (); - if (version >= 3000) { if ((child = find_named_node (node, "RouteGroups")) == 0) { @@ -1757,14 +1745,18 @@ Session::XMLRouteFactory (const XMLNode& node, int version) return ret; } - XMLNode* ds_child = find_named_node (node, X_("Diskstream")); + XMLNode* pl_child = find_named_node (node, X_("audio-playlist")); + + if (!pl_child) { + pl_child = find_named_node (node, X_("midi-playlist")); + } DataType type = DataType::AUDIO; node.get_property("default-type", type); assert (type != DataType::NIL); - if (ds_child) { + if (pl_child) { boost::shared_ptr<Track> track; @@ -1819,15 +1811,10 @@ Session::XMLRouteFactory_2X (const XMLNode& node, int version) if (ds_prop) { - list<boost::shared_ptr<Diskstream> >::iterator i = _diskstreams_2X.begin (); - while (i != _diskstreams_2X.end() && (*i)->id() != ds_prop->value()) { - ++i; - } + // XXX DISK .... how to load 2.x diskstreams ? - if (i == _diskstreams_2X.end()) { - error << _("Could not find diskstream for route") << endmsg; - return boost::shared_ptr<Route> (); - } + error << _("Could not find diskstream for route") << endmsg; + return boost::shared_ptr<Route> (); boost::shared_ptr<Track> track; @@ -4180,35 +4167,6 @@ Session::set_history_depth (uint32_t d) _history.set_depth (d); } -int -Session::load_diskstreams_2X (XMLNode const & node, int) -{ - XMLNodeList clist; - XMLNodeConstIterator citer; - - clist = node.children(); - - for (citer = clist.begin(); citer != clist.end(); ++citer) { - - try { - /* diskstreams added automatically by DiskstreamCreated handler */ - if ((*citer)->name() == "AudioDiskstream" || (*citer)->name() == "DiskStream") { - boost::shared_ptr<AudioDiskstream> dsp (new AudioDiskstream (*this, **citer)); - _diskstreams_2X.push_back (dsp); - } else { - error << _("Session: unknown diskstream type in XML") << endmsg; - } - } - - catch (failed_constructor& err) { - error << _("Session: could not load diskstream via XML state") << endmsg; - return -1; - } - } - - return 0; -} - /** Connect things to the MMC object */ void Session::setup_midi_machine_control () diff --git a/libs/ardour/track.cc b/libs/ardour/track.cc index 5cc87f8ecd..571da3f1f9 100644 --- a/libs/ardour/track.cc +++ b/libs/ardour/track.cc @@ -54,6 +54,19 @@ Track::Track (Session& sess, string name, PresentationInfo::Flag flag, TrackMode { _freeze_record.state = NoFreeze; _declickable = true; +} + +Track::~Track () +{ + DEBUG_TRACE (DEBUG::Destruction, string_compose ("track %1 destructor\n", _name)); +} + +int +Track::init () +{ + if (Route::init ()) { + return -1; + } DiskIOProcessor::Flag dflags = DiskIOProcessor::Recordable; @@ -63,29 +76,20 @@ Track::Track (Session& sess, string name, PresentationInfo::Flag flag, TrackMode dflags = DiskIOProcessor::Flag(dflags | DiskIOProcessor::NonLayered); } - _disk_reader.reset (new DiskReader (sess, name, dflags)); + _disk_reader.reset (new DiskReader (_session, name(), dflags)); _disk_reader->set_block_size (_session.get_block_size ()); _disk_reader->set_route (shared_from_this()); _disk_reader->do_refill_with_alloc (); - _disk_writer.reset (new DiskWriter (sess, name, dflags)); + _disk_writer.reset (new DiskWriter (_session, name(), dflags)); _disk_writer->set_block_size (_session.get_block_size ()); _disk_writer->set_route (shared_from_this()); -} - -Track::~Track () -{ - DEBUG_TRACE (DEBUG::Destruction, string_compose ("track %1 destructor\n", _name)); -} + use_new_playlist (); -int -Track::init () -{ - if (Route::init ()) { - return -1; - } + add_processor (_disk_writer, PreFader); + add_processor (_disk_reader, PreFader); boost::shared_ptr<Route> rp (boost::dynamic_pointer_cast<Route> (shared_from_this())); boost::shared_ptr<Track> rt = boost::dynamic_pointer_cast<Track> (rp); @@ -119,12 +123,19 @@ Track::state (bool full) { XMLNode& root (Route::state (full)); + if (_playlists[DataType::AUDIO]) { + root.add_property (X_("audio-playlist"), _playlists[DataType::AUDIO]->id().to_s()); + } + + if (_playlists[DataType::MIDI]) { + root.add_property (X_("midi-playlist"), _playlists[DataType::MIDI]->id().to_s()); + } + root.add_child_nocopy (_monitoring_control->get_state ()); root.add_child_nocopy (_record_safe_control->get_state ()); root.add_child_nocopy (_record_enable_control->get_state ()); root.set_property (X_("saved-meter-point"), _saved_meter_point); - root.add_child_nocopy (_diskstream->get_state ()); return root; } @@ -137,6 +148,7 @@ Track::set_state (const XMLNode& node, int version) } XMLNode* child; + XMLProperty const * prop; if (version >= 3000 && version < 4000) { if ((child = find_named_node (node, X_("Diskstream"))) != 0) { @@ -144,9 +156,13 @@ Track::set_state (const XMLNode& node, int version) } } - /* set rec-enable control *AFTER* setting up diskstream, because it may - want to operate on the diskstream as it sets its own state - */ + if ((prop = node.property (X_("audio-playlist")))) { + find_and_use_playlist (DataType::AUDIO, PBD::ID (prop->value())); + } + + if ((prop = node.property (X_("midi-playlist")))) { + find_and_use_playlist (DataType::MIDI, PBD::ID (prop->value())); + } XMLNodeList nlist = node.children(); for (XMLNodeConstIterator niter = nlist.begin(); niter != nlist.end(); ++niter) { @@ -168,15 +184,6 @@ Track::set_state (const XMLNode& node, int version) } } - /* convert old 3001 state */ - MonitorChoice monitoring; - if (node.get_property (X_("monitoring"), monitoring)) { - XMLNode mon_node ("backwardscompat"); - mon_node.set_property (X_("monitoring"), monitoring); - mon_node.set_property (X_("value"), (int) monitoring); - _monitoring_control->set_state (mon_node, version); - } - if (!node.get_property (X_("saved-meter-point"), _saved_meter_point)) { _saved_meter_point = _meter_point; } @@ -227,16 +234,16 @@ Track::prep_record_enabled (bool yn) } /* keep track of the meter point as it was before we rec-enabled */ - if (!_diskstream->record_enabled()) { + if (!_disk_writer->record_enabled()) { _saved_meter_point = _meter_point; } bool will_follow; if (yn) { - will_follow = _diskstream->prep_record_enable (); + will_follow = _disk_writer->prep_record_enable (); } else { - will_follow = _diskstream->prep_record_disable (); + will_follow = _disk_writer->prep_record_disable (); } if (will_follow) { @@ -255,25 +262,25 @@ Track::prep_record_enabled (bool yn) void Track::record_enable_changed (bool, Controllable::GroupControlDisposition) { - _diskstream->set_record_enabled (_record_enable_control->get_value()); + _disk_writer->set_record_enabled (_record_enable_control->get_value()); } void Track::record_safe_changed (bool, Controllable::GroupControlDisposition) { - _diskstream->set_record_safe (_record_safe_control->get_value()); + _disk_writer->set_record_safe (_record_safe_control->get_value()); } bool Track::can_be_record_safe () { - return !_record_enable_control->get_value() && _diskstream && _session.writable() && (_freeze_record.state != Frozen); + return !_record_enable_control->get_value() && _disk_writer && _session.writable() && (_freeze_record.state != Frozen); } bool Track::can_be_record_enabled () { - return !_record_safe_control->get_value() && _diskstream && !_diskstream->record_safe() && _session.writable() && (_freeze_record.state != Frozen); + return !_record_safe_control->get_value() && _disk_writer && !_disk_writer->record_safe() && _session.writable() && (_freeze_record.state != Frozen); } void @@ -333,10 +340,10 @@ Track::set_name (const string& str) } _diskstream_name = diskstream_name; - _diskstream->set_write_source_name (diskstream_name); + _disk_writer->set_write_source_name (diskstream_name); boost::shared_ptr<Track> me = boost::dynamic_pointer_cast<Track> (shared_from_this ()); - if (_diskstream->playlist()->all_regions_empty () && _session.playlists->playlists_for_track (me).size() == 1) { + if (_playlists[data_type()]->all_regions_empty () && _session.playlists->playlists_for_track (me).size() == 1) { /* Only rename the diskstream (and therefore the playlist) if a) the playlist has never had a region added to it and b) there is only one playlist for this track. @@ -348,7 +355,8 @@ Track::set_name (const string& str) If (b) is not followed, we rename the current playlist and not the other ones, which is a bit confusing (see mantis #4977). */ - _diskstream->set_name (str); + _disk_reader->set_name (str); + _disk_writer->set_name (str); } /* save state so that the statefile fully reflects any filename changes */ @@ -364,7 +372,7 @@ void Track::set_latency_compensation (framecnt_t longest_session_latency) { Route::set_latency_compensation (longest_session_latency); - _diskstream->set_roll_delay (_roll_delay); + _disk_reader->set_roll_delay (_roll_delay); } int @@ -389,7 +397,7 @@ Track::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, if (!_active) { silence (nframes); - if (_meter_point == MeterInput && ((_monitoring_control->monitoring_choice() & MonitorInput) || _diskstream->record_enabled())) { + if (_meter_point == MeterInput && ((_monitoring_control->monitoring_choice() & MonitorInput) || _disk_writer->record_enabled())) { _meter->reset(); } return 0; @@ -397,8 +405,9 @@ Track::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, if (session_state_changing) { if (_session.transport_speed() != 0.0f) { - /* we're rolling but some state is changing (e.g. our diskstream contents) - so we cannot use them. Be silent till this is over. Don't declick. + /* we're rolling but some state is changing (e.g. our + disk reader contents) so we cannot use them. Be + silent till this is over. Don't declick. XXX note the absurdity of ::no_roll() being called when we ARE rolling! */ @@ -537,7 +546,8 @@ Track::silent_roll (pframes_t nframes, framepos_t /*start_frame*/, framepos_t /* boost::shared_ptr<Playlist> Track::playlist () { - return _diskstream->playlist (); + cerr << name() << " lookup " << data_type().to_string() << " pl's\n"; + return _playlists[data_type()]; } void @@ -729,7 +739,7 @@ Track::set_slaved (bool s) ChanCount Track::n_channels () { - return _diskstream->n_channels (); + return _disk_reader->output_streams(); // XXX DISK } framepos_t @@ -769,16 +779,16 @@ Track::playlist_modified () } int -Track::find_and_use_playlist (DataType dt, const string& name) +Track::find_and_use_playlist (DataType dt, PBD::ID const & id) { boost::shared_ptr<Playlist> playlist; - if ((playlist = _session.playlists->by_name (name)) == 0) { - playlist = PlaylistFactory::create (dt, _session, name); + if ((playlist = _session.playlists->by_id (id)) == 0) { + return -1; } if (!playlist) { - error << string_compose(_("DiskIOProcessor: \"%1\" isn't an playlist"), name) << endmsg; + error << string_compose(_("DiskIOProcessor: \"%1\" isn't an playlist"), id.to_s()) << endmsg; return -1; } @@ -847,41 +857,36 @@ Track::use_new_playlist () void Track::set_align_style (AlignStyle s, bool force) { - _diskstream->set_align_style (s, force); + // XXX DISK } void Track::set_align_choice (AlignChoice s, bool force) { - _diskstream->set_align_choice (s, force); -} - -bool -Track::using_diskstream_id (PBD::ID id) const -{ - return (id == _diskstream->id ()); + // XXX DISK } void Track::set_block_size (pframes_t n) { Route::set_block_size (n); - _diskstream->set_block_size (n); + _disk_reader->set_block_size (n); + _disk_writer->set_block_size (n); } void Track::adjust_playback_buffering () { - if (_diskstream) { - _diskstream->adjust_playback_buffering (); + if (_disk_reader) { + _disk_reader->adjust_buffering (); } } void Track::adjust_capture_buffering () { - if (_diskstream) { - _diskstream->adjust_capture_buffering (); + if (_disk_writer) { + _disk_writer->adjust_buffering (); } } |