From f0704d7f9028676e86efd1d00401ecaae13d7e33 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sun, 11 May 2008 20:09:39 -0500 Subject: [PATCH] Oops. Finalize peak capture in the right place! --- Timeline/Audio_Region.C | 4 +--- Timeline/Peaks.C | 9 ++++----- Timeline/Track.C | 9 ++++++++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Timeline/Audio_Region.C b/Timeline/Audio_Region.C index ee3e878..017e490 100644 --- a/Timeline/Audio_Region.C +++ b/Timeline/Audio_Region.C @@ -867,14 +867,12 @@ Audio_Region::finalize ( nframes_t frame ) { log_end(); - _clip->finalize(); - _clip->close(); _clip->open(); /* FIXME: should we attempt to truncate the file? */ - _range.length = frame - _range.start - _range.offset; + _range.length = frame - _range.start; redraw(); diff --git a/Timeline/Peaks.C b/Timeline/Peaks.C index 4499aa0..45d1fb3 100644 --- a/Timeline/Peaks.C +++ b/Timeline/Peaks.C @@ -568,11 +568,10 @@ Peaks::prepare_for_writing ( void ) void Peaks::finish_writing ( void ) { - if ( _peak_writer ) - { - delete _peak_writer; - _peak_writer = NULL; - } + assert( _peak_writer ); + + delete _peak_writer; + _peak_writer = NULL; /* now fill in the rest of the cache */ make_peaks_mipmap(); diff --git a/Timeline/Track.C b/Timeline/Track.C index 94c0284..f2d7a99 100644 --- a/Timeline/Track.C +++ b/Timeline/Track.C @@ -769,12 +769,14 @@ uuid ( void ) void Track::record ( nframes_t frame ) { - assert( _capture == NULL ); + assert( ! _capture ); + assert( ! _capture_af ); char pat[256]; snprintf( pat, sizeof( pat ), "%s-%llu", name(), uuid() ); + _capture_af = Audio_File_SF::create( pat, engine->sample_rate(), input.size(), Track::capture_format ); if ( ! _capture_af ) @@ -810,4 +812,9 @@ Track::stop ( nframes_t frame ) _capture->finalize( frame ); _capture = NULL; + + _capture_af->finalize(); + + delete _capture_af; + _capture_af = NULL; }