Fix importing to a fixed-point format with resampling
[ardour.git] / libs / ardour / file_source.cc
index 8b503d4894d4d207c02fa6db42d5ee718f605a80..37af5b8c38233a85726acb9fd60e6074b81283e0 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;
@@ -519,6 +519,7 @@ FileSource::mark_immutable ()
        /* destructive sources stay writable, and their other flags don't change.  */
        if (!(_flags & Destructive)) {
                _flags = Flag (_flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy|CanRename));
+               close();
        }
 }