summaryrefslogtreecommitdiff
path: root/libs/ardour/audiosource.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-09-15 14:41:27 +0200
committerRobin Gareus <robin@gareus.org>2015-09-15 14:44:05 +0200
commit04e7cfabbe58605e6770adbd9e27bf871a957bef (patch)
tree422e05f8dc36f1e9c9138eba704668b7f23bba56 /libs/ardour/audiosource.cc
parent551e20b926e164b3579d5e6b39f5e2fcb1ced93e (diff)
prepare peak-file cleanup/recreate.
Diffstat (limited to 'libs/ardour/audiosource.cc')
-rw-r--r--libs/ardour/audiosource.cc30
1 files changed, 29 insertions, 1 deletions
diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc
index 4439669c4f..d4be1df22e 100644
--- a/libs/ardour/audiosource.cc
+++ b/libs/ardour/audiosource.cc
@@ -752,8 +752,9 @@ AudioSource::build_peaks_from_scratch ()
lp.release(); // allow butler to refill buffers
- if (_session.deletion_in_progress()) {
+ if (_session.deletion_in_progress() || _session.peaks_cleanup_in_progres()) {
cerr << "peak file creation interrupted: " << _name << endmsg;
+ lp.acquire();
done_with_peakfile_writes (false);
goto out;
}
@@ -789,8 +790,27 @@ AudioSource::build_peaks_from_scratch ()
}
int
+AudioSource::close_peakfile ()
+{
+ Glib::Threads::Mutex::Lock lp (_lock);
+ if (_peakfile_fd >= 0) {
+ close (_peakfile_fd);
+ _peakfile_fd = -1;
+ }
+ if (!_peakpath.empty()) {
+ ::g_unlink (_peakpath.c_str());
+ }
+ _peaks_built = false;
+ return 0;
+}
+
+int
AudioSource::prepare_for_peakfile_writes ()
{
+ if (_session.deletion_in_progress() || _session.peaks_cleanup_in_progres()) {
+ return -1;
+ }
+
if ((_peakfile_fd = g_open (_peakpath.c_str(), O_CREAT|O_RDWR, 0664)) < 0) {
error << string_compose(_("AudioSource: cannot open _peakpath (c) \"%1\" (%2)"), _peakpath, strerror (errno)) << endmsg;
return -1;
@@ -801,6 +821,14 @@ AudioSource::prepare_for_peakfile_writes ()
void
AudioSource::done_with_peakfile_writes (bool done)
{
+ if (_session.deletion_in_progress() || _session.peaks_cleanup_in_progres()) {
+ if (_peakfile_fd) {
+ close (_peakfile_fd);
+ _peakfile_fd = -1;
+ }
+ return;
+ }
+
if (peak_leftover_cnt) {
compute_and_write_peaks (0, 0, 0, true, false, _FPP);
}