summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2019-03-19 05:14:00 +0100
committerRobin Gareus <robin@gareus.org>2019-03-19 05:14:00 +0100
commitcf11e11fc571e761382507a7d7cf574d5c3429bc (patch)
tree37fa8b0722bd9d0398956eac4e95226db2ae97d3 /libs
parentab791658936a24d2df69102d07c430b38db8ca32 (diff)
Remove global Session::playlists variable, use getter method (1/2)
Global variables that can written by anyone are to be avoided. This also simplifies exposing SessionPlaylists as Lua bindings.
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/session.h4
-rw-r--r--libs/ardour/audio_playlist_importer.cc2
-rw-r--r--libs/ardour/audio_track.cc4
-rw-r--r--libs/ardour/midi_track.cc2
-rw-r--r--libs/ardour/playlist.cc2
-rw-r--r--libs/ardour/session.cc16
-rw-r--r--libs/ardour/session_command.cc4
-rw-r--r--libs/ardour/session_state.cc28
-rw-r--r--libs/ardour/track.cc8
9 files changed, 36 insertions, 34 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index d744cd1d0e..ab7b59c5c6 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -1117,7 +1117,7 @@ public:
PostTransportAdjustCaptureBuffering = 0x2000
};
- boost::shared_ptr<SessionPlaylists> playlists;
+ boost::shared_ptr<SessionPlaylists> playlists () const { return _playlists; }
void send_mmc_locate (samplepos_t);
void queue_full_time_code () { _send_timecode_update = true; }
@@ -1227,6 +1227,8 @@ private:
static void init_name_id_counter (guint n);
static unsigned int name_id_counter ();
+ boost::shared_ptr<SessionPlaylists> _playlists;
+
/* stuff used in process() should be close together to
maximise cache hits
*/
diff --git a/libs/ardour/audio_playlist_importer.cc b/libs/ardour/audio_playlist_importer.cc
index 65f3410fcd..89e1b40852 100644
--- a/libs/ardour/audio_playlist_importer.cc
+++ b/libs/ardour/audio_playlist_importer.cc
@@ -170,7 +170,7 @@ bool
AudioPlaylistImporter::_prepare_move ()
{
// Rename
- while (session.playlists->by_name (name) || !handler.check_name (name)) {
+ while (session.playlists()->by_name (name) || !handler.check_name (name)) {
std::pair<bool, string> rename_pair = *Rename (_("A playlist with this name already exists, please rename it."), name);
if (!rename_pair.first) {
return false;
diff --git a/libs/ardour/audio_track.cc b/libs/ardour/audio_track.cc
index 477d07e83b..e9b7434c0c 100644
--- a/libs/ardour/audio_track.cc
+++ b/libs/ardour/audio_track.cc
@@ -214,7 +214,7 @@ AudioTrack::set_state_part_two ()
_freeze_record.processor_info.clear ();
if ((prop = fnode->property (X_("playlist"))) != 0) {
- boost::shared_ptr<Playlist> pl = _session.playlists->by_name (prop->value());
+ boost::shared_ptr<Playlist> pl = _session.playlists()->by_name (prop->value());
if (pl) {
_freeze_record.playlist = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
_freeze_record.playlist->use();
@@ -379,7 +379,7 @@ AudioTrack::freeze_me (InterThreadInfo& itt)
candidate = string_compose ("<F%2>%1", _freeze_record.playlist->name(), n);
- if (_session.playlists->by_name (candidate) == 0) {
+ if (_session.playlists()->by_name (candidate) == 0) {
new_playlist_name = candidate;
break;
}
diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc
index 9ef9532b63..9f7291c6e7 100644
--- a/libs/ardour/midi_track.cc
+++ b/libs/ardour/midi_track.cc
@@ -265,7 +265,7 @@ MidiTrack::set_state_part_two ()
std::string str;
if (fnode->get_property (X_("playlist"), str)) {
- boost::shared_ptr<Playlist> pl = _session.playlists->by_name (str);
+ boost::shared_ptr<Playlist> pl = _session.playlists()->by_name (str);
if (pl) {
_freeze_record.playlist = boost::dynamic_pointer_cast<MidiPlaylist> (pl);
} else {
diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc
index bf95fde434..0c1860f2cd 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -2475,7 +2475,7 @@ Playlist::bump_name (string name, Session &session)
do {
newname = bump_name_once (newname, '.');
- } while (session.playlists->by_name (newname)!=NULL);
+ } while (session.playlists()->by_name (newname)!=NULL);
return newname;
}
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index ca16628db5..dbbd3115ed 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -170,7 +170,7 @@ Session::Session (AudioEngine &eng,
const string& snapshot_name,
BusProfile* bus_profile,
string mix_template)
- : playlists (new SessionPlaylists)
+ : _playlists (new SessionPlaylists)
, _engine (eng)
, process_function (&Session::process_with_events)
, _bounce_processing_active (false)
@@ -794,7 +794,7 @@ Session::destroy ()
}
/* not strictly necessary, but doing it here allows the shared_ptr debugging to work */
- playlists.reset ();
+ _playlists.reset ();
emit_thread_terminate ();
@@ -3342,7 +3342,7 @@ Session::new_route_from_template (uint32_t how_many, PresentationInfo::order_t i
XMLNode* ds_node = find_named_node (node_copy, "Diskstream");
if (ds_node) {
const std::string playlist_name = ds_node->property (X_("playlist"))->value ();
- boost::shared_ptr<Playlist> playlist = playlists->by_name (playlist_name);
+ boost::shared_ptr<Playlist> playlist = _playlists->by_name (playlist_name);
// Use same name as Route::set_name_in_state so playlist copy
// is picked up when creating the Route in XMLRouteFactory below
playlist = PlaylistFactory::create (playlist, string_compose ("%1.1", name));
@@ -3352,7 +3352,7 @@ Session::new_route_from_template (uint32_t how_many, PresentationInfo::order_t i
XMLNode* ds_node = find_named_node (node_copy, "Diskstream");
if (ds_node) {
const std::string playlist_name = ds_node->property (X_("playlist"))->value ();
- boost::shared_ptr<Playlist> playlist = playlists->by_name (playlist_name);
+ boost::shared_ptr<Playlist> playlist = _playlists->by_name (playlist_name);
playlist->share_with ((node_copy.property (X_("id")))->value());
}
}
@@ -4714,7 +4714,7 @@ Session::destroy_sources (list<boost::shared_ptr<Source> > srcs)
tmp = r;
++tmp;
- playlists->destroy_region (*r);
+ _playlists->destroy_region (*r);
RegionFactory::map_remove (*r);
(*r)->drop_sources ();
@@ -5328,7 +5328,7 @@ Session::add_playlist (boost::shared_ptr<Playlist> playlist, bool unused)
return;
}
- playlists->add (playlist);
+ _playlists->add (playlist);
if (unused) {
playlist->release();
@@ -5350,7 +5350,7 @@ Session::remove_playlist (boost::weak_ptr<Playlist> weak_playlist)
return;
}
- playlists->remove (playlist);
+ _playlists->remove (playlist);
set_dirty();
}
@@ -5773,7 +5773,7 @@ Session::tempo_map_changed (const PropertyChange&)
{
clear_clicks ();
- playlists->update_after_tempo_map_change ();
+ _playlists->update_after_tempo_map_change ();
_locations->apply (*this, &Session::update_locations_after_tempo_map_change);
diff --git a/libs/ardour/session_command.cc b/libs/ardour/session_command.cc
index 89dabbdcbf..8318b41e52 100644
--- a/libs/ardour/session_command.cc
+++ b/libs/ardour/session_command.cc
@@ -111,7 +111,7 @@ Session::memento_command_factory(XMLNode *n)
return new MementoCommand<TempoMap>(*_tempo_map, before, after);
} else if (type_name == "ARDOUR::Playlist" || type_name == "ARDOUR::AudioPlaylist" || type_name == "ARDOUR::MidiPlaylist") {
- if (boost::shared_ptr<Playlist> pl = playlists->by_name(child->property("name")->value())) {
+ if (boost::shared_ptr<Playlist> pl = _playlists->by_name(child->property("name")->value())) {
return new MementoCommand<Playlist>(*(pl.get()), before, after);
}
@@ -165,7 +165,7 @@ Session::stateful_diff_command_factory (XMLNode* n)
}
} else if (type_name == "ARDOUR::AudioPlaylist" || type_name == "ARDOUR::MidiPlaylist") {
- boost::shared_ptr<Playlist> p = playlists->by_id (id);
+ boost::shared_ptr<Playlist> p = _playlists->by_id (id);
if (p) {
return new StatefulDiffCommand (p, *n);
} else {
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index 9773364523..8e08630471 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -1263,8 +1263,8 @@ Session::state (bool save_template, snapshot_t snapshot_type, bool only_used_ass
set<boost::shared_ptr<Source> > sources_used_by_this_snapshot;
if (only_used_assets) {
- playlists->sync_all_regions_with_regions ();
- playlists->foreach (boost::bind (merge_all_sources, _1, &sources_used_by_this_snapshot), false);
+ _playlists->sync_all_regions_with_regions ();
+ _playlists->foreach (boost::bind (merge_all_sources, _1, &sources_used_by_this_snapshot), false);
}
for (SourceMap::iterator siter = sources.begin(); siter != sources.end(); ++siter) {
@@ -1475,7 +1475,7 @@ Session::state (bool save_template, snapshot_t snapshot_type, bool only_used_ass
}
}
- playlists->add_state (node, save_template, !only_used_assets);
+ _playlists->add_state (node, save_template, !only_used_assets);
child = node->add_child ("RouteGroups");
for (list<RouteGroup *>::iterator i = _route_groups.begin(); i != _route_groups.end(); ++i) {
@@ -1663,13 +1663,13 @@ Session::set_state (const XMLNode& node, int version)
if ((child = find_named_node (node, "Playlists")) == 0) {
error << _("Session: XML state has no playlists section") << endmsg;
goto out;
- } else if (playlists->load (*this, *child)) {
+ } else if (_playlists->load (*this, *child)) {
goto out;
}
if ((child = find_named_node (node, "UnusedPlaylists")) == 0) {
// this is OK
- } else if (playlists->load_unused (*this, *child)) {
+ } else if (_playlists->load_unused (*this, *child)) {
goto out;
}
@@ -3245,7 +3245,7 @@ Session::cleanup_regions ()
for (RegionFactory::RegionMap::const_iterator i = regions.begin(); i != regions.end();) {
- uint32_t used = playlists->region_use_count (i->second);
+ uint32_t used = _playlists->region_use_count (i->second);
if (used == 0 && !i->second->automatic ()) {
boost::weak_ptr<Region> w = i->second;
@@ -3265,7 +3265,7 @@ Session::cleanup_regions ()
continue;
}
assert(boost::dynamic_pointer_cast<PlaylistSource>(i->second->source (0)) != 0);
- if (0 == playlists->region_use_count (i->second)) {
+ if (0 == _playlists->region_use_count (i->second)) {
boost::weak_ptr<Region> w = i->second;
++i;
RegionFactory::map_remove (w);
@@ -3375,14 +3375,14 @@ Session::cleanup_sources (CleanupReport& rep)
/* consider deleting all unused playlists */
- if (playlists->maybe_delete_unused (boost::bind (Session::ask_about_playlist_deletion, _1))) {
+ if (_playlists->maybe_delete_unused (boost::bind (Session::ask_about_playlist_deletion, _1))) {
ret = 0;
goto out;
}
/* sync the "all regions" property of each playlist with its current state */
- playlists->sync_all_regions_with_regions ();
+ _playlists->sync_all_regions_with_regions ();
/* find all un-used sources */
@@ -3442,7 +3442,7 @@ Session::cleanup_sources (CleanupReport& rep)
* This will include the playlists used within compound regions.
*/
- playlists->foreach (boost::bind (merge_all_sources, _1, &sources_used_by_this_snapshot));
+ _playlists->foreach (boost::bind (merge_all_sources, _1, &sources_used_by_this_snapshot));
/* add our current source list
*/
@@ -4005,9 +4005,9 @@ Session::config_changed (std::string p, bool ours)
} else if (p == "edit-mode") {
- Glib::Threads::Mutex::Lock lm (playlists->lock);
+ Glib::Threads::Mutex::Lock lm (_playlists->lock);
- for (SessionPlaylists::List::iterator i = playlists->playlists.begin(); i != playlists->playlists.end(); ++i) {
+ for (SessionPlaylists::List::iterator i = _playlists->playlists.begin(); i != _playlists->playlists.end(); ++i) {
(*i)->set_edit_mode (Config->get_edit_mode ());
}
@@ -5292,8 +5292,8 @@ Session::archive_session (const std::string& dest,
set<boost::shared_ptr<Source> > sources_used_by_this_snapshot;
if (only_used_sources) {
- playlists->sync_all_regions_with_regions ();
- playlists->foreach (boost::bind (merge_all_sources, _1, &sources_used_by_this_snapshot), false);
+ _playlists->sync_all_regions_with_regions ();
+ _playlists->foreach (boost::bind (merge_all_sources, _1, &sources_used_by_this_snapshot), false);
}
/* collect audio sources for this session, calc total size for encoding
diff --git a/libs/ardour/track.cc b/libs/ardour/track.cc
index 045f8297a0..d94ab81ac1 100644
--- a/libs/ardour/track.cc
+++ b/libs/ardour/track.cc
@@ -181,11 +181,11 @@ Track::set_state (const XMLNode& node, int version)
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);
}
}
@@ -390,7 +390,7 @@ Track::set_name (const string& str)
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.
@@ -608,7 +608,7 @@ Track::find_and_use_playlist (DataType dt, PBD::ID const & id)
{
boost::shared_ptr<Playlist> playlist;
- if ((playlist = _session.playlists->by_id (id)) == 0) {
+ if ((playlist = _session.playlists()->by_id (id)) == 0) {
return -1;
}