new automation state model, sort of working, but not really
[ardour.git] / libs / ardour / audiofilesource.cc
index 9564fff53b79b6bf7183caf7907ec9f423b320a3..77709e3a3cb58294ac6c29c42937ae3921cbabe4 100644 (file)
@@ -59,8 +59,7 @@ string AudioFileSource::search_path;
 sigc::signal<void> AudioFileSource::HeaderPositionOffsetChanged;
 uint64_t           AudioFileSource::header_position_offset = 0;
 
-char   AudioFileSource::bwf_country_code[3] = "US";
-char   AudioFileSource::bwf_organization_code[4] = "LAS";
+/* XXX maybe this too */
 char   AudioFileSource::bwf_serial_number[13] = "000000000000";
 
 AudioFileSource::AudioFileSource (Session& s, string idstr, Flag flags)
@@ -120,7 +119,9 @@ AudioFileSource::init (string pathstr, bool must_exist)
        _length = 0;
        timeline_position = 0;
        next_peak_clear_should_notify = false;
-       
+       _peaks_built = false;
+       file_is_new = false;
+
        if (!find (pathstr, must_exist, is_new)) {
                return -1;
        }
@@ -285,7 +286,8 @@ AudioFileSource::mark_for_remove ()
        if (!writable()) {
                return;
        }
-       _flags = Flag (_flags | RemoveAtDestroy);
+
+       _flags = Flag (_flags | Removable | RemoveAtDestroy);
 }
 
 void
@@ -518,8 +520,14 @@ AudioFileSource::set_timeline_position (nframes_t pos)
 void
 AudioFileSource::set_allow_remove_if_empty (bool yn)
 {
-       if (writable()) {
+       if (!writable()) {
+               return;
+       }
+
+       if (yn) {
                _flags = Flag (_flags | RemovableIfEmpty);
+       } else {
+               _flags = Flag (_flags & ~RemovableIfEmpty);
        }
 }
 
@@ -565,3 +573,12 @@ AudioFileSource::is_empty (Session& s, string path)
        return ret;
 }
 
+int
+AudioFileSource::setup_peakfile ()
+{
+       if (!(_flags & NoPeakFile)) {
+               return initialize_peakfile (file_is_new, _path);
+       } else {
+               return 0;
+       }
+}