#include <unistd.h>
#include <sys/stat.h>
#include <climits>
-#include <fcntl.h>
-#include <poll.h>
#include <signal.h>
-#include <sys/mman.h>
#include <sys/time.h>
#ifdef HAVE_SYS_VFS_H
#include <sys/vfs.h>
-#else
+#endif
+
+#ifdef __APPLE__
#include <sys/param.h>
#include <sys/mount.h>
#endif
#include "pbd/enumwriter.h"
#include "pbd/error.h"
#include "pbd/file_utils.h"
+#include "pbd/pathexpand.h"
#include "pbd/pathscanner.h"
#include "pbd/pthread_utils.h"
#include "pbd/stacktrace.h"
#include "pbd/convert.h"
#include "pbd/clear_dir.h"
+#include "pbd/localtime_r.h"
#include "ardour/amp.h"
+#include "ardour/async_midi_port.h"
#include "ardour/audio_diskstream.h"
#include "ardour/audio_track.h"
#include "ardour/audioengine.h"
#include "ardour/midi_model.h"
#include "ardour/midi_patch_manager.h"
#include "ardour/midi_region.h"
+#include "ardour/midi_scene_changer.h"
#include "ardour/midi_source.h"
#include "ardour/midi_track.h"
#include "ardour/pannable.h"
/* discover canonical fullpath */
- char buf[PATH_MAX+1];
- if (!realpath (fullpath.c_str(), buf) && (errno != ENOENT)) {
- error << string_compose(_("Could not use path %1 (%2)"), buf, strerror(errno)) << endmsg;
- destroy ();
- throw failed_constructor();
- }
+ _path = canonical_path(fullpath);
- _path = string(buf);
-
/* we require _path to end with a dir separator */
if (_path[_path.length()-1] != G_DIR_SEPARATOR) {
BootMessage (_("Using configuration"));
_midi_ports = new MidiPortManager;
+
+ MIDISceneChanger* msc;
+
+ _scene_changer = msc = new MIDISceneChanger (*this);
+ msc->set_input_port (scene_input_port());
+ msc->set_output_port (scene_out());
+
+ boost::function<framecnt_t(void)> timer_func (boost::bind (&Session::audible_frame, this));
+ boost::dynamic_pointer_cast<AsyncMIDIPort>(scene_in())->set_timer (timer_func);
+
setup_midi_machine_control ();
if (_butler->start_thread()) {
string
Session::raid_path () const
{
- SearchPath raid_search_path;
+ Searchpath raid_search_path;
for (vector<space_and_path>::const_iterator i = session_dirs.begin(); i != session_dirs.end(); ++i) {
raid_search_path += (*i).path;
session_dirs.clear ();
- SearchPath search_path(path);
- SearchPath sound_search_path;
- SearchPath midi_search_path;
+ Searchpath search_path(path);
+ Searchpath sound_search_path;
+ Searchpath midi_search_path;
- for (SearchPath::const_iterator i = search_path.begin(); i != search_path.end(); ++i) {
+ for (Searchpath::const_iterator i = search_path.begin(); i != search_path.end(); ++i) {
sp.path = *i;
sp.blocks = 0; // not needed
session_dirs.push_back (sp);
} else {
- if (::rename (tmp_path.c_str(), xml_path.c_str()) != 0) {
- error << string_compose (_("could not rename temporary session file %1 to %2"),
- tmp_path, xml_path) << endmsg;
+ if (::g_rename (tmp_path.c_str(), xml_path.c_str()) != 0) {
+ error << string_compose (_("could not rename temporary session file %1 to %2 (%3)"),
+ tmp_path, xml_path, g_strerror(errno)) << endmsg;
if (g_remove (tmp_path.c_str()) != 0) {
error << string_compose(_("Could not remove temporary session file at path \"%1\" (%2)"),
tmp_path, g_strerror (errno)) << endmsg;
set_dirty();
- _writable = exists_and_writable (xmlpath);
+ _writable = exists_and_writable (xmlpath) && exists_and_writable(Glib::path_get_dirname(xmlpath));
if (!state_tree->read (xmlpath)) {
error << string_compose(_("Could not understand session file %1"), xmlpath) << endmsg;
p += (*i).path;
if (next != session_dirs.end()) {
- p += ':';
+ p += G_SEARCHPATH_SEPARATOR;
} else {
break;
}
_total_free_4k_blocks_uncertain = true;
}
}
+#elif defined (COMPILER_MSVC)
+ vector<string> scanned_volumes;
+ vector<string>::iterator j;
+ vector<space_and_path>::iterator i;
+ DWORD nSectorsPerCluster, nBytesPerSector,
+ nFreeClusters, nTotalClusters;
+ char disk_drive[4];
+ bool volume_found;
+
+ _total_free_4k_blocks = 0;
+
+ for (i = session_dirs.begin(); i != session_dirs.end(); i++) {
+ strncpy (disk_drive, (*i).path.c_str(), 3);
+ disk_drive[3] = 0;
+ strupr(disk_drive);
+
+ volume_found = false;
+ if (0 != (GetDiskFreeSpace(disk_drive, &nSectorsPerCluster, &nBytesPerSector, &nFreeClusters, &nTotalClusters)))
+ {
+ int64_t nBytesPerCluster = nBytesPerSector * nSectorsPerCluster;
+ int64_t nFreeBytes = nBytesPerCluster * (int64_t)nFreeClusters;
+ i->blocks = (uint32_t)(nFreeBytes / 4096);
+
+ for (j = scanned_volumes.begin(); j != scanned_volumes.end(); j++) {
+ if (0 == j->compare(disk_drive)) {
+ volume_found = true;
+ break;
+ }
+ }
+
+ if (!volume_found) {
+ scanned_volumes.push_back(disk_drive);
+ _total_free_4k_blocks += i->blocks;
+ }
+ }
+ }
+
+ if (0 == _total_free_4k_blocks) {
+ strncpy (disk_drive, path().c_str(), 3);
+ disk_drive[3] = 0;
+
+ if (0 != (GetDiskFreeSpace(disk_drive, &nSectorsPerCluster, &nBytesPerSector, &nFreeClusters, &nTotalClusters)))
+ {
+ int64_t nBytesPerCluster = nBytesPerSector * nSectorsPerCluster;
+ int64_t nFreeBytes = nBytesPerCluster * (int64_t)nFreeClusters;
+ _total_free_4k_blocks = (uint32_t)(nFreeBytes / 4096);
+ }
+ }
#endif
}
}
static bool
-state_file_filter (const string &str, void */*arg*/)
+state_file_filter (const string &str, void* /*arg*/)
{
return (str.length() > strlen(statefile_suffix) &&
str.find (statefile_suffix) == (str.length() - strlen (statefile_suffix)));
}
static bool
-accept_all_audio_files (const string& path, void */*arg*/)
+accept_all_audio_files (const string& path, void* /*arg*/)
{
if (!Glib::file_test (path, Glib::FILE_TEST_IS_REGULAR)) {
return false;
}
static bool
-accept_all_midi_files (const string& path, void */*arg*/)
+accept_all_midi_files (const string& path, void* /*arg*/)
{
if (!Glib::file_test (path, Glib::FILE_TEST_IS_REGULAR)) {
return false;
}
static bool
-accept_all_state_files (const string& path, void */*arg*/)
+accept_all_state_files (const string& path, void* /*arg*/)
{
if (!Glib::file_test (path, Glib::FILE_TEST_IS_REGULAR)) {
return false;
bool used;
string spath;
int ret = -1;
+ string tmppath1;
+ string tmppath2;
_state_of_the_state = (StateOfTheState) (_state_of_the_state | InCleanup);
audio_path += sdir.sound_path();
if (nexti != session_dirs.end()) {
- audio_path += ':';
+ audio_path += G_SEARCHPATH_SEPARATOR;
}
i = nexti;
midi_path += sdir.midi_path();
if (nexti != session_dirs.end()) {
- midi_path += ':';
+ midi_path += G_SEARCHPATH_SEPARATOR;
}
i = nexti;
++tmp;
if ((fs = boost::dynamic_pointer_cast<FileSource> (i->second)) != 0) {
- if (playlists->source_use_count (fs) != 0) {
- all_sources.insert (fs->path());
- } else {
- /* we might not remove this source from disk, because it may be used
- by other snapshots, but its not being used in this version
- so lets get rid of it now, along with any representative regions
- in the region list.
- */
+ if (!fs->is_stub()) {
- RegionFactory::remove_regions_using_source (i->second);
- sources.erase (i);
- }
+ if (playlists->source_use_count (fs) != 0) {
+ all_sources.insert (fs->path());
+ } else {
+
+ /* we might not remove this source from disk, because it may be used
+ by other snapshots, but its not being used in this version
+ so lets get rid of it now, along with any representative regions
+ in the region list.
+ */
+
+ RegionFactory::remove_regions_using_source (i->second);
+ sources.erase (i);
+ }
+ }
}
i = tmp;
}
- char tmppath1[PATH_MAX+1];
- char tmppath2[PATH_MAX+1];
-
if (candidates) {
for (vector<string*>::iterator x = candidates->begin(); x != candidates->end(); ++x) {
for (set<string>::iterator i = all_sources.begin(); i != all_sources.end(); ++i) {
- if (realpath(spath.c_str(), tmppath1) == 0) {
- error << string_compose (_("Cannot expand path %1 (%2)"),
- spath, strerror (errno)) << endmsg;
- continue;
- }
-
- if (realpath((*i).c_str(), tmppath2) == 0) {
- error << string_compose (_("Cannot expand path %1 (%2)"),
- (*i), strerror (errno)) << endmsg;
- continue;
- }
+ tmppath1 = canonical_path (spath);
+ tmppath2 = canonical_path ((*i));
- if (strcmp(tmppath1, tmppath2) == 0) {
+ if (tmppath1 == tmppath2) {
used = true;
break;
}
string peakpath = peak_path (base);
if (Glib::file_test (peakpath.c_str(), Glib::FILE_TEST_EXISTS)) {
- if (::unlink (peakpath.c_str()) != 0) {
+ if (::g_unlink (peakpath.c_str()) != 0) {
error << string_compose (_("cannot remove peakfile %1 for %2 (%3)"),
peakpath, _path, strerror (errno))
<< endmsg;
/* XXX DO SOMETHING HERE TO TELL THE GUI THAT WE NEED
TO SET REMOTE ID'S
*/
- } else if (p == "sync-all-route-ordering") {
-
- /* sync to editor order unless mixer is used for remote IDs
- */
-
- switch (Config->get_remote_model()) {
- case UserOrdered:
- sync_order_keys (EditorSort);
- break;
- case EditorOrdered:
- sync_order_keys (EditorSort);
- break;
- case MixerOrdered:
- sync_order_keys (MixerSort);
- }
-
} else if (p == "initial-program-change") {
if (_mmc->output_port() && Config->get_initial_program_change() >= 0) {
string const old_sources_root = _session_dir->sources_root();
-#define RENAME ::rename
-
/* Rename:
* session directory
cerr << "Rename " << oldstr << " => " << newstr << endl;
- if (RENAME (oldstr.c_str(), newstr.c_str()) != 0) {
+ if (::g_rename (oldstr.c_str(), newstr.c_str()) != 0) {
+ error << string_compose (_("renaming %s as %2 failed (%3)"), oldstr, newstr, g_strerror (errno)) << endmsg;
return 1;
}
cerr << "Rename " << oldstr << " => " << newstr << endl;
- if (RENAME (oldstr.c_str(), newstr.c_str()) != 0) {
+ if (::g_rename (oldstr.c_str(), newstr.c_str()) != 0) {
+ error << string_compose (_("renaming %s as %2 failed (%3)"), oldstr, newstr, g_strerror (errno)) << endmsg;
return 1;
}
}
cerr << "Rename " << oldstr << " => " << newstr << endl;
- if (RENAME (oldstr.c_str(), newstr.c_str()) != 0) {
+ if (::g_rename (oldstr.c_str(), newstr.c_str()) != 0) {
+ error << string_compose (_("renaming %s as %2 failed (%3)"), oldstr, newstr, g_strerror (errno)) << endmsg;
return 1;
}
cerr << "Rename " << oldstr << " => " << newstr << endl;
- if (RENAME (oldstr.c_str(), newstr.c_str()) != 0) {
+ if (::g_rename (oldstr.c_str(), newstr.c_str()) != 0) {
+ error << string_compose (_("renaming %s as %2 failed (%3)"), oldstr, newstr, g_strerror (errno)) << endmsg;
return 1;
}
}
_current_snapshot_name = new_name;
_name = new_name;
+ /* re-add directory separator - reverse hack to oldstr above */
+ if (_path[_path.length()-1] != G_DIR_SEPARATOR) {
+ _path += G_DIR_SEPARATOR;
+ }
+
set_dirty ();
/* save state again to get everything just right */
store_recent_sessions (new_name, _path);
return 0;
-
-#undef RENAME
}
int