X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Faudiographer%2Faudiographer%2Fsndfile%2Fsndfile_writer.h;h=984ec01d4126bfa180b83bfc3e4779241d2e7d81;hb=69a8fc43e2552d9d3c72f9117131ca6b9392093b;hp=7b3c2968fff0dfd690537347fdc1995fc055a042;hpb=73192bc1a7ea55fa1864dc3826845b15c00dd2ec;p=ardour.git diff --git a/libs/audiographer/audiographer/sndfile/sndfile_writer.h b/libs/audiographer/audiographer/sndfile/sndfile_writer.h index 7b3c2968ff..984ec01d41 100644 --- a/libs/audiographer/audiographer/sndfile/sndfile_writer.h +++ b/libs/audiographer/audiographer/sndfile/sndfile_writer.h @@ -1,10 +1,10 @@ #ifndef AUDIOGRAPHER_SNDFILE_WRITER_H #define AUDIOGRAPHER_SNDFILE_WRITER_H -#include -#include #include +#include + #include "audiographer/flag_debuggable.h" #include "audiographer/sink.h" #include "audiographer/types.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