summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorJohn Emmas <johne53@tiscali.co.uk>2013-08-09 17:56:14 +0100
committerJohn Emmas <johne53@tiscali.co.uk>2013-08-09 17:56:14 +0100
commit5f703f25a9c73912d2d28c29c52130e5f363c768 (patch)
treea3bdba0ab67a167e8601b626bed41ad002b3f834 /libs
parent64cc518e72c684f05a3dc48d97ec985fbe6186d1 (diff)
'libs/ardour' - If the platform is Windows, prevent lengthy caching by flushing imported files on completion of the import
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/audiofilesource.h1
-rw-r--r--libs/ardour/ardour/coreaudiosource.h2
-rw-r--r--libs/ardour/ardour/silentfilesource.h1
-rw-r--r--libs/ardour/ardour/sndfilesource.h1
-rw-r--r--libs/ardour/import.cc8
-rw-r--r--libs/ardour/sndfilesource.cc24
6 files changed, 37 insertions, 0 deletions
diff --git a/libs/ardour/ardour/audiofilesource.h b/libs/ardour/ardour/audiofilesource.h
index c5fd7b3af2..af5dabe388 100644
--- a/libs/ardour/ardour/audiofilesource.h
+++ b/libs/ardour/ardour/audiofilesource.h
@@ -64,6 +64,7 @@ public:
virtual void clear_capture_marks() {}
virtual bool one_of_several_channels () const { return false; }
+ virtual void flush () = 0;
virtual int update_header (framepos_t when, struct tm&, time_t) = 0;
virtual int flush_header () = 0;
diff --git a/libs/ardour/ardour/coreaudiosource.h b/libs/ardour/ardour/coreaudiosource.h
index 820fa0b9d8..30c66069f6 100644
--- a/libs/ardour/ardour/coreaudiosource.h
+++ b/libs/ardour/ardour/coreaudiosource.h
@@ -43,6 +43,8 @@ class CoreAudioSource : public AudioFileSource {
void set_header_timeline_position () {};
bool clamped_at_unity () const { return false; }
+ void flush () {}
+
static int get_soundfile_info (string path, SoundFileInfo& _info, string& error_msg);
protected:
diff --git a/libs/ardour/ardour/silentfilesource.h b/libs/ardour/ardour/silentfilesource.h
index 5cdade3751..b8ac40e178 100644
--- a/libs/ardour/ardour/silentfilesource.h
+++ b/libs/ardour/ardour/silentfilesource.h
@@ -32,6 +32,7 @@ public:
float sample_rate () const { return _sample_rate; }
void set_length (framecnt_t len) { _length = len; }
+ void flush () {}
bool destructive() const { return false; }
bool can_be_analysed() const { return false; }
diff --git a/libs/ardour/ardour/sndfilesource.h b/libs/ardour/ardour/sndfilesource.h
index 3f63f1c598..bed431c490 100644
--- a/libs/ardour/ardour/sndfilesource.h
+++ b/libs/ardour/ardour/sndfilesource.h
@@ -46,6 +46,7 @@ class SndFileSource : public AudioFileSource {
float sample_rate () const;
int update_header (framepos_t when, struct tm&, time_t);
int flush_header ();
+ void flush ();
framepos_t natural_position () const;
diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc
index 9be72a9966..b66f354224 100644
--- a/libs/ardour/import.cc
+++ b/libs/ardour/import.cc
@@ -334,6 +334,14 @@ write_audio_data_to_new_files (ImportableSource* source, ImportStatus& status,
uint32_t chn;
if ((nread = source->read (data.get(), nframes)) == 0) {
+#ifdef PLATFORM_WINDOWS
+ /* Flush the data once we've finished importing the file. Windows can */
+ /* cache the data for very long periods of time (perhaps not writing */
+ /* it to disk until Ardour closes). So let's force it to flush now. */
+ for (chn = 0; chn < channels; ++chn)
+ if ((afs = boost::dynamic_pointer_cast<AudioFileSource>(newfiles[chn])) != 0)
+ afs->flush ();
+#endif
break;
}
diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc
index b5d821ffda..1c3144f164 100644
--- a/libs/ardour/sndfilesource.cc
+++ b/libs/ardour/sndfilesource.cc
@@ -550,6 +550,30 @@ SndFileSource::flush_header ()
return r;
}
+void
+SndFileSource::flush ()
+{
+ if (!_open) {
+ warning << string_compose (_("attempt to flush an un-opened audio file source (%1)"), _path) << endmsg;
+ return;
+ }
+
+ if (!writable()) {
+ warning << string_compose (_("attempt to flush a non-writable audio file source (%1)"), _path) << endmsg;
+ return;
+ }
+
+ SNDFILE* sf = _descriptor->allocate ();
+ if (sf == 0) {
+ error << string_compose (_("could not allocate file %1 to flush contents"), _path) << endmsg;
+ return;
+ }
+
+ // Hopefully everything OK
+ sf_write_sync (sf);
+ _descriptor->release ();
+}
+
int
SndFileSource::setup_broadcast_info (framepos_t /*when*/, struct tm& now, time_t /*tnow*/)
{