#include <ardour/configuration.h>
#include <ardour/session.h>
#include <ardour/session_directory.h>
+#include <ardour/session_metadata.h>
#include <ardour/utils.h>
#include <ardour/audio_diskstream.h>
#include <ardour/audioplaylist.h>
sigc::signal<void> Session::SMPTEOffsetChanged;
sigc::signal<void> Session::StartTimeChanged;
sigc::signal<void> Session::EndTimeChanged;
-
sigc::signal<void> Session::AutoBindingOn;
sigc::signal<void> Session::AutoBindingOff;
+sigc::signal<void, std::string, std::string> Session::Exported;
Session::Session (AudioEngine &eng,
const string& fullpath,
diskstreams (new DiskstreamList),
routes (new RouteList),
auditioner ((Auditioner*) 0),
+ _total_free_4k_blocks (0),
_bundle_xml_node (0),
_click_io ((IO*) 0),
- main_outs (0)
+ main_outs (0),
+ _metadata (new SessionMetadata())
{
bool new_session;
cerr << "Loading session " << fullpath << " using snapshot " << snapshot_name << " (1)" << endl;
- n_physical_outputs = _engine.n_physical_outputs();
- n_physical_inputs = _engine.n_physical_inputs();
+ n_physical_outputs = _engine.n_physical_outputs(DataType::AUDIO);
+ n_physical_inputs = _engine.n_physical_inputs(DataType::AUDIO);
first_stage_init (fullpath, snapshot_name);
midi_requests (16),
diskstreams (new DiskstreamList),
routes (new RouteList),
+ _total_free_4k_blocks (0),
_bundle_xml_node (0),
main_outs (0)
cerr << "Loading session " << fullpath << " using snapshot " << snapshot_name << " (2)" << endl;
- n_physical_outputs = _engine.n_physical_outputs();
- n_physical_inputs = _engine.n_physical_inputs();
+ n_physical_outputs = _engine.n_physical_outputs (DataType::AUDIO);
+ n_physical_inputs = _engine.n_physical_inputs (DataType::AUDIO);
if (n_physical_inputs) {
n_physical_inputs = max (requested_physical_in, n_physical_inputs);
set_loop = true;
}
+ if (location->is_start()) {
+ start_location = location;
+ }
+ if (location->is_end()) {
+ end_location = location;
+ }
}
if (!set_loop) {
}
}
- /*
+#if 0
vector<string> physinputs;
vector<string> physoutputs;
+
+ _engine.get_physical_outputs (DataType::MIDI, physoutputs);
+ _engine.get_physical_inputs (DataType::MIDI, physinputs);
uint32_t nphysical_in;
uint32_t nphysical_out;
-
- _engine.get_physical_outputs (physoutputs);
- _engine.get_physical_inputs (physinputs);
- control_id = ntracks() + nbusses() + 1;
- */
+ control_id = ntracks() + nbusses();
+#endif
while (how_many) {
} while (track_id < (UINT_MAX-1));
/*
- if (Config->get_input_auto_connect() & AutoConnectPhysical) {
+ if (Config->get_input_auto_connect() & AutoConnectPhysical) {
nphysical_in = min (n_physical_inputs, (uint32_t) physinputs.size());
} else {
nphysical_in = 0;
uint32_t nphysical_in;
uint32_t nphysical_out;
- _engine.get_physical_outputs (physoutputs);
- _engine.get_physical_inputs (physinputs);
+ _engine.get_physical_outputs (DataType::AUDIO, physoutputs);
+ _engine.get_physical_inputs (DataType::AUDIO, physinputs);
control_id = ntracks() + nbusses() + 1;
while (how_many) {
vector<string> physinputs;
vector<string> physoutputs;
- _engine.get_physical_outputs (physoutputs);
- _engine.get_physical_inputs (physinputs);
+ _engine.get_physical_outputs (DataType::AUDIO, physoutputs);
+ _engine.get_physical_inputs (DataType::AUDIO, physinputs);
control_id = ntracks() + nbusses() + 1;
while (how_many) {
boost::shared_ptr<DiskstreamList> dsl = diskstreams.reader();
for (DiskstreamList::const_iterator i = dsl->begin(); i != dsl->end(); ++i) {
+ if ((*i)->destructive()) //ignore tape tracks when getting max extents
+ continue;
boost::shared_ptr<Playlist> pl = (*i)->playlist();
if ((me = pl->get_maximum_extent()) > max) {
max = me;
}
int
-Session::region_name (string& result, string base, bool newlevel) const
+Session::region_name (string& result, string base, bool newlevel)
{
char buf[16];
string subbase;
Glib::Mutex::Lock lm (region_lock);
snprintf (buf, sizeof (buf), "%d", (int)regions.size() + 1);
-
-
result = "region.";
result += buf;
} else {
- /* XXX this is going to be slow. optimize me later */
-
if (newlevel) {
subbase = base;
} else {
}
- bool name_taken = true;
-
{
Glib::Mutex::Lock lm (region_lock);
- for (int n = 1; n < 5000; ++n) {
+ map<string,uint32_t>::iterator x;
- result = subbase;
- snprintf (buf, sizeof (buf), ".%d", n);
- result += buf;
-
- name_taken = false;
+ result = subbase;
- for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) {
- if (i->second->name() == result) {
- name_taken = true;
- break;
- }
- }
+ if ((x = region_name_map.find (subbase)) == region_name_map.end()) {
+ result += ".1";
+ region_name_map[subbase] = 1;
+ } else {
+ x->second++;
+ snprintf (buf, sizeof (buf), ".%d", x->second);
- if (!name_taken) {
- break;
- }
+ result += buf;
}
}
-
- if (name_taken) {
- fatal << string_compose(_("too many regions with names like %1"), base) << endmsg;
- /*NOTREACHED*/
- }
}
+
return 0;
}
add the region to the region list.
*/
- set_dirty();
+ set_dirty ();
if (added) {
region->StateChanged.connect (sigc::bind (mem_fun (*this, &Session::region_changed), boost::weak_ptr<Region>(region)));
region->GoingAway.connect (sigc::bind (mem_fun (*this, &Session::remove_region), boost::weak_ptr<Region>(region)));
+
+ update_region_name_map (region);
}
if (!v.empty()) {
}
}
+void
+Session::update_region_name_map (boost::shared_ptr<Region> region)
+{
+ string::size_type last_period = region->name().find_last_of ('.');
+
+ if (last_period != string::npos && last_period < region->name().length() - 1) {
+
+ string base = region->name().substr (0, last_period);
+ string number = region->name().substr (last_period+1);
+ map<string,uint32_t>::iterator x;
+
+ /* note that if there is no number, we get zero from atoi,
+ which is just fine
+ */
+
+ region_name_map[base] = atoi (number);
+ }
+}
+
void
Session::region_changed (Change what_changed, boost::weak_ptr<Region> weak_region)
{
/* relay hidden changes */
RegionHiddenChange (region);
}
+
+ if (what_changed & NameChanged) {
+ update_region_name_map (region);
+ }
}
void
return 0;
}
-int
-Session::write_one_audio_track (AudioTrack& track, nframes_t start, nframes_t len,
- bool overwrite, vector<boost::shared_ptr<Source> >& srcs, InterThreadInfo& itt)
+boost::shared_ptr<Region>
+Session::write_one_track (AudioTrack& track, nframes_t start, nframes_t end,
+ bool overwrite, vector<boost::shared_ptr<Source> >& srcs, InterThreadInfo& itt)
{
- int ret = -1;
+ boost::shared_ptr<Region> result;
boost::shared_ptr<Playlist> playlist;
boost::shared_ptr<AudioFileSource> fsource;
uint32_t x;
BufferSet buffers;
SessionDirectory sdir(get_best_session_directory_for_new_source ());
const string sound_dir = sdir.sound_path().to_string();
+ nframes_t len = end - start;
+
+ if (end <= start) {
+ error << string_compose (_("Cannot write a range where end <= start (e.g. %1 <= %2)"),
+ end, start) << endmsg;
+ return result;
+ }
// any bigger than this seems to cause stack overflows in called functions
const nframes_t chunk_size = (128 * 1024)/4;
/* construct a region to represent the bounced material */
- boost::shared_ptr<Region> aregion = RegionFactory::create (srcs, 0, srcs.front()->length(),
- region_name_from_path (srcs.front()->name(), true));
-
- ret = 0;
+ result = RegionFactory::create (srcs, 0, srcs.front()->length(),
+ region_name_from_path (srcs.front()->name(), true));
}
out:
- if (ret) {
+ if (!result) {
for (vector<boost::shared_ptr<Source> >::iterator src = srcs.begin(); src != srcs.end(); ++src) {
boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource>(*src);
if (afs) {
afs->mark_for_remove ();
}
-
+
(*src)->drop_references ();
}
g_atomic_int_set (&processing_prohibited, 0);
- return ret;
+ return result;
}
BufferSet&