/*
- Copyright (C) 2006 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.
-*/
+ * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
+ * Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
+ * Copyright (C) 2007-2019 Paul Davis <paul@linuxaudiosystems.com>
+ * Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
+ * Copyright (C) 2014-2018 Ben Loftis <ben@harrisonconsoles.com>
+ * Copyright (C) 2016 Julien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
+ *
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
#include "pbd/error.h"
#include "ardour/amp.h"
, _alignment_choice (Automatic)
{
_freeze_record.state = NoFreeze;
- _declickable = true;
-
}
Track::~Track ()
if (_mode == Destructive && !Profile->get_trx()) {
dflags = DiskIOProcessor::Flag (dflags | DiskIOProcessor::Destructive);
- } else if (_mode == NonLayered){
- dflags = DiskIOProcessor::Flag(dflags | DiskIOProcessor::NonLayered);
}
_disk_reader.reset (new DiskReader (_session, name(), dflags));
_disk_reader->set_block_size (_session.get_block_size ());
_disk_reader->set_route (boost::dynamic_pointer_cast<Route> (shared_from_this()));
+ _disk_reader->set_owner (this);
_disk_writer.reset (new DiskWriter (_session, name(), dflags));
_disk_writer->set_block_size (_session.get_block_size ());
_disk_writer->set_route (boost::dynamic_pointer_cast<Route> (shared_from_this()));
+ _disk_writer->set_owner (this);
set_align_choice_from_io ();
- use_new_playlist (data_type());
+ if (!name().empty()) {
+ /* an empty name means that we are being constructed via
+ serialized state (XML). Don't create a playlist, because one
+ will be created or discovered during ::set_state().
+ */
+ use_new_playlist (data_type());
+ }
boost::shared_ptr<Route> rp (boost::dynamic_pointer_cast<Route> (shared_from_this()));
boost::shared_ptr<Track> rt = boost::dynamic_pointer_cast<Track> (rp);
}
XMLNode&
-Track::get_state ()
-{
- return state (true);
-}
-
-XMLNode&
-Track::state (bool full)
+Track::state (bool save_template)
{
- XMLNode& root (Route::state (full));
+ XMLNode& root (Route::state (save_template));
if (_playlists[DataType::AUDIO]) {
root.set_property (X_("audio-playlist"), _playlists[DataType::AUDIO]->id().to_s());
if (version >= 3000 && version < 6000) {
if (XMLNode* ds_node = find_named_node (node, "Diskstream")) {
std::string name;
- if (ds_node->get_property ("name", name)) {
+ if (ds_node->get_property ("playlist", name)) {
ds_node->set_property ("active", true);
set_align_choice (ac, true);
}
- if (boost::shared_ptr<AudioPlaylist> pl = boost::dynamic_pointer_cast<AudioPlaylist> (_session.playlists->by_name (name))) {
+ if (boost::shared_ptr<AudioPlaylist> pl = boost::dynamic_pointer_cast<AudioPlaylist> (_session.playlists()->by_name (name))) {
use_playlist (DataType::AUDIO, pl);
}
- if (boost::shared_ptr<MidiPlaylist> pl = boost::dynamic_pointer_cast<MidiPlaylist> (_session.playlists->by_name (name))) {
+ if (boost::shared_ptr<MidiPlaylist> pl = boost::dynamic_pointer_cast<MidiPlaylist> (_session.playlists()->by_name (name))) {
use_playlist (DataType::MIDI, pl);
}
}
return 0;
}
-XMLNode&
-Track::get_template ()
-{
- return state (false);
-}
-
Track::FreezeRecord::~FreezeRecord ()
{
for (vector<FreezeRecordProcessorInfo*>::iterator i = processor_info.begin(); i != processor_info.end(); ++i) {
return _freeze_record.state;
}
+bool
+Track::declick_in_progress () const
+{
+ return _disk_reader->declick_in_progress ();
+}
+
bool
Track::can_record()
{
boost::shared_ptr<Track> me = boost::dynamic_pointer_cast<Track> (shared_from_this ());
- if (_playlists[data_type()]->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.
}
void
-Track::set_pending_overwrite (bool o)
+Track::set_pending_overwrite ()
{
- _disk_reader->set_pending_overwrite (o);
+ _disk_reader->set_pending_overwrite ();
}
int
return _disk_writer->seek (p, complete_refill);
}
-int
+bool
Track::can_internal_playback_seek (samplecnt_t p)
{
return _disk_reader->can_internal_playback_seek (p);
}
-int
+void
Track::internal_playback_seek (samplecnt_t p)
{
return _disk_reader->internal_playback_seek (p);
Track::non_realtime_locate (samplepos_t p)
{
Route::non_realtime_locate (p);
-
- if (!is_private_route()) {
- /* don't waste i/o cycles and butler calls
- for private tracks (e.g.auditioner)
- */
- _disk_reader->non_realtime_locate (p);
- _disk_writer->non_realtime_locate (p);
- }
}
-void
-Track::non_realtime_speed_change ()
-{
- _disk_reader->non_realtime_speed_change ();
-}
-
-int
+bool
Track::overwrite_existing_buffers ()
{
return _disk_reader->overwrite_existing_buffers ();
return _disk_writer->get_captured_samples (n);
}
-int
-Track::set_loop (Location* l)
-{
- if (_disk_reader->set_loop (l)) {
- return -1;
- }
- return _disk_writer->set_loop (l);
-}
-
void
Track::transport_looped (samplepos_t p)
{
return _disk_writer->transport_looped (p);
}
-bool
-Track::realtime_speed_change ()
-{
- if (_disk_reader->realtime_speed_change ()) {
- return -1;
- }
- return _disk_writer->realtime_speed_change ();
-}
-
-void
-Track::realtime_handle_transport_stopped ()
-{
- Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
-
- if (!lm.locked ()) {
- return;
- }
-
- for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
- (*i)->realtime_handle_transport_stopped ();
- }
-}
-
void
Track::transport_stopped_wallclock (struct tm & n, time_t t, bool g)
{
{
boost::shared_ptr<Playlist> playlist;
- if ((playlist = _session.playlists->by_id (id)) == 0) {
+ if ((playlist = _session.playlists()->by_id (id)) == 0) {
return -1;
}
return use_playlist (dt, playlist);
}
+void
+update_region_visibility(boost::shared_ptr<Region> r)
+{
+ Region::RegionPropertyChanged(r, Properties::hidden);
+}
+
+
int
Track::use_playlist (DataType dt, boost::shared_ptr<Playlist> p)
{
}
}
+ boost::shared_ptr<Playlist> old = _playlists[dt];
+
if (ret == 0) {
_playlists[dt] = p;
}
+
+ //allow all regions of prior and new playlists to update their visibility?
+ if (old) old->foreach_region(update_region_visibility);
+ if (p) p->foreach_region(update_region_visibility);
_session.set_dirty ();
PlaylistChanged (); /* EMIT SIGNAL */
connections.clear ();
}
+
+ /* Special case bounding the Metronome.
+ * Click-out is aligned to output and hence
+ * equivalent to a physical round-trip alike
+ * ExistingMaterial.
+ */
+ if (!have_physical && _session.click_io ()) {
+ if (_session.click_io ()->connected_to (_input)) {
+ have_physical = true;
+ }
+ }
}
+
#ifdef MIXBUS
// compensate for latency when bouncing from master or mixbus.
// we need to use "ExistingMaterial" to pick up the master bus' latency
}
}
-
-void
-Track::maybe_declick (BufferSet& bufs, samplecnt_t nframes, int declick)
-{
- /* never declick if there is an internal generator - we just want it to
- keep generating sound without interruption.
-
- ditto if we are monitoring inputs.
- */
-
- if (_have_internal_generator || (_monitoring_control->monitoring_choice() == MonitorInput)) {
- return;
- }
-
- if (!declick) {
- declick = _pending_declick;
- }
-
- if (declick != 0) {
- Amp::declick (bufs, nframes, declick);
- }
-}
-
void
Track::monitoring_changed (bool, Controllable::GroupControlDisposition)
{
continue; /* XXX is this OK? */
}
- // cerr << "add new region, buffer position = " << buffer_position << " @ " << (*ci)->start << endl;
+ cerr << "add new region, len = " << (*ci)->samples << " @ " << (*ci)->start << endl;
- pl->add_region (midi_region, (*ci)->start + preroll_off, _disk_writer->non_layered());
+ pl->add_region (midi_region, (*ci)->start + preroll_off, 1, _session.config.get_layered_record_mode ());
}
pl->thaw ();
continue; /* XXX is this OK? */
}
- pl->add_region (region, (*ci)->start + preroll_off, 1, _disk_writer->non_layered());
+ pl->add_region (region, (*ci)->start + preroll_off, 1, _session.config.get_layered_record_mode());
pl->set_layer (region, DBL_MAX);
buffer_position += (*ci)->samples;