#include "pbd/error.h"
#include "pbd/boost_debug.h"
-#include "pbd/pathscanner.h"
#include "pbd/stl_delete.h"
#include "pbd/basename.h"
#include "pbd/stacktrace.h"
#include "ardour/region_factory.h"
#include "ardour/route_graph.h"
#include "ardour/route_group.h"
+#include "ardour/route_sorters.h"
#include "ardour/send.h"
#include "ardour/session.h"
#include "ardour/session_directory.h"
, state_tree (0)
, state_was_pending (false)
, _state_of_the_state (StateOfTheState(CannotSave|InitialConnecting|Loading))
+ , _suspend_save (0)
+ , _save_queued (false)
, _last_roll_location (0)
, _last_roll_or_reversal_location (0)
, _last_record_location (0)
, routes (new RouteList)
, _adding_routes_in_progress (false)
, destructive_index (0)
+ , _track_number_decimals(1)
, solo_update_disabled (false)
, default_fade_steepness (0)
, default_fade_msecs (0)
throw failed_constructor ();
}
+ /* load default session properties - if any */
+ config.load_state();
+
} else {
if (load_state (_current_snapshot_name)) {
failed:
if (!new_routes.empty()) {
+ StateProtector sp (this);
add_routes (new_routes, true, true, true);
if (instrument) {
failed:
if (!new_routes.empty()) {
+ StateProtector sp (this);
add_routes (new_routes, true, true, true);
}
failure:
if (!ret.empty()) {
+ StateProtector sp (this);
add_routes (ret, false, true, true); // autoconnect outputs only
}
out:
if (!ret.empty()) {
+ StateProtector sp (this);
add_routes (ret, true, true, true);
IO::enable_connecting ();
}
save_state (_current_snapshot_name);
}
+ reassign_track_numbers();
+
RouteAdded (new_routes); /* EMIT SIGNAL */
}
if (save_state (_current_snapshot_name)) {
save_history (_current_snapshot_name);
}
+ reassign_track_numbers();
}
void
return boost::shared_ptr<Route> ((Route*) 0);
}
+
+void
+Session::reassign_track_numbers ()
+{
+ int64_t tn = 0;
+ int64_t bn = 0;
+ RouteList r (*(routes.reader ()));
+ SignalOrderRouteSorter sorter;
+ r.sort (sorter);
+
+ StateProtector sp (this);
+
+ for (RouteList::iterator i = r.begin(); i != r.end(); ++i) {
+ if (boost::dynamic_pointer_cast<Track> (*i)) {
+ (*i)->set_track_number(++tn);
+ }
+ else if (!(*i)->is_master() && !(*i)->is_monitor() && !(*i)->is_auditioner()) {
+ (*i)->set_track_number(--bn);
+ }
+ }
+ const uint32_t decimals = ceilf (log10f (tn + 1));
+ const bool decimals_changed = _track_number_decimals != decimals;
+ _track_number_decimals = decimals;
+
+ if (decimals_changed && config.get_track_name_number ()) {
+ for (RouteList::iterator i = r.begin(); i != r.end(); ++i) {
+ boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (*i);
+ if (t) {
+ t->resync_track_name();
+ }
+ }
+ // trigger GUI re-layout
+ config.ParameterChanged("track-name-number");
+ }
+}
+
void
Session::playlist_region_added (boost::weak_ptr<Region> w)
{
boost::shared_ptr<Playlist> playlist;
boost::shared_ptr<AudioFileSource> fsource;
uint32_t x;
- char buf[PATH_MAX+1];
ChanCount diskstream_channels (track.n_channels());
framepos_t position;
framecnt_t this_chunk;
bool need_block_size_reset = false;
string ext;
ChanCount const max_proc = track.max_processor_streams ();
+ string legal_playlist_name;
+ string possible_path;
if (end <= start) {
error << string_compose (_("Cannot write a range where end <= start (e.g. %1 <= %2)"),
goto out;
}
+ legal_playlist_name = legalize_for_path (playlist->name());
+
ext = native_header_format_extension (config.get_native_file_header_format(), DataType::AUDIO);
for (uint32_t chan_n = 0; chan_n < diskstream_channels.n_audio(); ++chan_n) {
for (x = 0; x < 99999; ++x) {
- snprintf (buf, sizeof(buf), "%s/%s-%d-bounce-%" PRIu32 "%s", sound_dir.c_str(), playlist->name().c_str(), chan_n, x+1, ext.c_str());
- if (!Glib::file_test (buf, Glib::FILE_TEST_EXISTS)) {
+ possible_path = Glib::build_filename (sound_dir, string_compose ("%1-%2-bounce-%3%4", legal_playlist_name.c_str(), chan_n, x+1, ext.c_str()));
+ if (!Glib::file_test (possible_path, Glib::FILE_TEST_EXISTS)) {
break;
}
}
try {
fsource = boost::dynamic_pointer_cast<AudioFileSource> (
- SourceFactory::createWritable (DataType::AUDIO, *this, buf, false, frame_rate()));
+ SourceFactory::createWritable (DataType::AUDIO, *this, possible_path, false, frame_rate()));
}
catch (failed_constructor& err) {
- error << string_compose (_("cannot create new audio file \"%1\" for %2"), buf, track.name()) << endmsg;
+ error << string_compose (_("cannot create new audio file \"%1\" for %2"), possible_path, track.name()) << endmsg;
goto out;
}
DEBUG_TRACE (DEBUG::OrderKeys, "Sync Order Keys.\n");
+ reassign_track_numbers();
+
Route::SyncOrderKeys (); /* EMIT SIGNAL */
DEBUG_TRACE (DEBUG::OrderKeys, "\tsync done\n");