Fix stripable order for new strips & master-order
[ardour.git] / libs / ardour / file_source.cc
index 37e156ec8f5b49b34180a2b09cc7b6a282f95ccb..c1aa50d4a47f3c069fb8674d44cab06d26c797a9 100644 (file)
@@ -61,6 +61,7 @@ FileSource::FileSource (Session& session, DataType type, const string& path, con
        , _file_is_new (!origin.empty()) // if origin is left unspecified (empty string) then file must exist
        , _channel (0)
        , _origin (origin)
+       , _gain (1.f)
 {
        set_within_session_from_path (path);
 }
@@ -69,6 +70,7 @@ FileSource::FileSource (Session& session, const XMLNode& node, bool /*must_exist
        : Source (session, node)
        , _file_is_new (false)
        , _channel (0)
+       , _gain (1.f)
 {
        /* this setting of _path is temporary - we expect derived classes
           to call ::init() which will actually locate the file
@@ -142,16 +144,14 @@ FileSource::init (const string& pathstr, bool must_exist)
 int
 FileSource::set_state (const XMLNode& node, int /*version*/)
 {
-       XMLProperty const * prop;
-
-       if ((prop = node.property (X_("channel"))) != 0) {
-               _channel = atoi (prop->value());
-       } else {
+       if (!node.get_property (X_("channel"), _channel)) {
                _channel = 0;
        }
 
-       if ((prop = node.property (X_("origin"))) != 0) {
-               _origin = prop->value();
+       node.get_property (X_("origin"), _origin);
+
+       if (!node.get_property (X_("gain"), _gain)) {
+               _gain = 1.f;
        }
 
        return 0;
@@ -210,7 +210,7 @@ FileSource::move_to_trash (const string& trash_dir_name)
        if (::g_rename (_path.c_str(), newpath.c_str()) != 0) {
                PBD::error << string_compose (
                                _("cannot rename file source from %1 to %2 (%3)"),
-                               _path, newpath, strerror (errno)) << endmsg;
+                               _path, newpath, g_strerror (errno)) << endmsg;
                return -1;
        }
 
@@ -433,7 +433,7 @@ FileSource::find_2X (Session& s, DataType type, const string& path, bool must_ex
                if (cnt > 1) {
 
                        error << string_compose (
-                                       _("FileSource: \"%1\" is ambigous when searching\n\t"), pathstr) << endmsg;
+                                       _("FileSource: \"%1\" is ambiguous when searching\n\t"), pathstr) << endmsg;
                        goto out;
 
                } else if (cnt == 0) {
@@ -486,7 +486,7 @@ FileSource::find_2X (Session& s, DataType type, const string& path, bool must_ex
                        if (must_exist) {
                                error << string_compose(
                                                _("Filesource: cannot find required file (%1): %2"),
-                                               path, strerror (errno)) << endmsg;
+                                               path, g_strerror (errno)) << endmsg;
                                goto out;
                        }
 
@@ -494,7 +494,7 @@ FileSource::find_2X (Session& s, DataType type, const string& path, bool must_ex
                        if (errno != ENOENT) {
                                error << string_compose(
                                                _("Filesource: cannot check for existing file (%1): %2"),
-                                               path, strerror (errno)) << endmsg;
+                                               path, g_strerror (errno)) << endmsg;
                                goto out;
                        }
 #endif
@@ -556,6 +556,15 @@ FileSource::set_path (const std::string& newpath)
        }
 }
 
+
+void
+FileSource::replace_file (const std::string& newpath)
+{
+       close ();
+       _path = newpath;
+       _name = Glib::path_get_basename (newpath);
+}
+
 void
 FileSource::inc_use_count ()
 {
@@ -595,7 +604,7 @@ FileSource::rename (const string& newpath)
        if (Glib::file_test (oldpath.c_str(), Glib::FILE_TEST_EXISTS)) {
                /* rename only needed if file exists on disk */
                if (::g_rename (oldpath.c_str(), newpath.c_str()) != 0) {
-                       error << string_compose (_("cannot rename file %1 to %2 (%3)"), oldpath, newpath, strerror(errno)) << endmsg;
+                       error << string_compose (_("cannot rename file %1 to %2 (%3)"), oldpath, newpath, g_strerror(errno)) << endmsg;
                        return -1;
                }
        }