From f57da9b00e0660640c7a4cbb48f32ef63830d463 Mon Sep 17 00:00:00 2001 From: Sakari Bergen Date: Tue, 24 Jan 2012 20:21:54 +0000 Subject: Show proper progress information for export while normalizing git-svn-id: svn://localhost/ardour2/branches/3.0@11337 d708f5d6-7413-0410-9779-e7cbd77b26cf --- .../audiographer/sndfile/sndfile_writer.h | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'libs/audiographer/audiographer') diff --git a/libs/audiographer/audiographer/sndfile/sndfile_writer.h b/libs/audiographer/audiographer/sndfile/sndfile_writer.h index 6e8ecc2567..984ec01d41 100644 --- a/libs/audiographer/audiographer/sndfile/sndfile_writer.h +++ b/libs/audiographer/audiographer/sndfile/sndfile_writer.h @@ -31,7 +31,7 @@ class SndfileWriter : SndfileHandle (path, Write, format, channels, samplerate) , path (path) { - add_supported_flag (ProcessContext::EndOfInput); + init(); if (broadcast_info) { broadcast_info->write_to_file (this); @@ -40,8 +40,16 @@ class SndfileWriter virtual ~SndfileWriter () {} - SndfileWriter (SndfileWriter const & other) : SndfileHandle (other) {} + SndfileWriter (SndfileWriter const & other) + : SndfileHandle (other) + { + init(); + } + using SndfileHandle::operator=; + + framecnt_t get_frames_written() const { return frames_written; } + void reset_frames_written_count() { frames_written = 0; } /// Writes data to file void process (ProcessContext const & c) @@ -55,6 +63,8 @@ class SndfileWriter } framecnt_t const written = write (c.data(), c.frames()); + frames_written += written; + if (throw_level (ThrowProcess) && written != c.frames()) { throw Exception (*this, boost::str (boost::format ("Could not write data to output file (%1%)") @@ -75,11 +85,18 @@ class SndfileWriter /// SndfileHandle has to be constructed directly by deriving classes SndfileWriter () { + init(); + } + + void init() + { + frames_written = 0; add_supported_flag (ProcessContext::EndOfInput); } - + protected: std::string path; + framecnt_t frames_written; }; } // namespace -- cgit v1.2.3