when renaming redirects, scan all routes AND sends AND port inserts for the name...
[ardour.git] / libs / ardour / audiofilesource.cc
index b5069245134ade82162d68a6f36cc89403e1f93e..b1ec8a3baa7c543b5a283c5f344b2bf3d982d49d 100644 (file)
@@ -96,6 +96,7 @@ AudioFileSource::AudioFileSource (Session& s, ustring path, Flag flags)
                throw failed_constructor ();
        }
 
+       fix_writable_flags ();
 }
 
 AudioFileSource::AudioFileSource (Session& s, ustring path, Flag flags, SampleFormat samp_format, HeaderFormat hdr_format)
@@ -108,6 +109,8 @@ AudioFileSource::AudioFileSource (Session& s, ustring path, Flag flags, SampleFo
        if (init (path, false)) {
                throw failed_constructor ();
        }
+
+       fix_writable_flags ();
 }
 
 AudioFileSource::AudioFileSource (Session& s, const XMLNode& node, bool must_exist)
@@ -125,6 +128,8 @@ AudioFileSource::AudioFileSource (Session& s, const XMLNode& node, bool must_exi
        if (init (foo, must_exist)) {
                throw failed_constructor ();
        }
+
+       fix_writable_flags ();
 }
 
 AudioFileSource::~AudioFileSource ()
@@ -135,6 +140,14 @@ AudioFileSource::~AudioFileSource ()
        }
 }
 
+void
+AudioFileSource::fix_writable_flags ()
+{
+       if (!_session.writable()) {
+               _flags = Flag (_flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy|CanRename));
+       }
+}
+
 bool
 AudioFileSource::determine_embeddedness (ustring path)
 {
@@ -147,6 +160,12 @@ AudioFileSource::removable () const
        return (_flags & Removable) && ((_flags & RemoveAtDestroy) || ((_flags & RemovableIfEmpty) && length() == 0));
 }
 
+bool
+AudioFileSource::writable() const
+{
+       return (_flags & Writable);
+}
+
 int
 AudioFileSource::init (ustring pathstr, bool must_exist)
 {
@@ -298,6 +317,8 @@ AudioFileSource::set_state (const XMLNode& node)
 
        }
 
+       fix_writable_flags ();
+
        if ((prop = node.property (X_("channel"))) != 0) {
                _channel = atoi (prop->value());
        } else {
@@ -324,7 +345,7 @@ AudioFileSource::mark_for_remove ()
        // This operation is not allowed for sources for destructive tracks or embedded files.
        // Fortunately mark_for_remove() is never called for embedded files. This function
        // must be fixed if that ever happens.
-       if (_flags & Destructive) {
+       if (!_session.writable() || (_flags & Destructive)) {
                return;
        }
 
@@ -638,6 +659,8 @@ AudioFileSource::set_allow_remove_if_empty (bool yn)
        } else {
                _flags = Flag (_flags & ~RemovableIfEmpty);
        }
+
+       fix_writable_flags ();
 }
 
 int
@@ -711,9 +734,8 @@ AudioFileSource::safe_file_extension(ustring file)
                ".maud", ".MAUD",
                ".vwe", ".VWE",
                ".paf",
-#ifdef HAVE_FLAC
                ".flac", ".FLAC",
-#endif // HAVE_FLAC
+               ".ogg", ".OGG",
 #ifdef HAVE_COREAUDIO
                ".mp3", ".MP3",
                ".aac", ".AAC",