summaryrefslogtreecommitdiff
path: root/libs/audiographer/audiographer/sndfile/tmp_file.h
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-07-15 17:03:07 +0200
committerRobin Gareus <robin@gareus.org>2016-07-16 02:14:13 +0200
commit77687519b69f39aaa2354f4c9945958fc1c630fe (patch)
tree36ed0f367bc81cccaba0ed01d837c56ff2fea072 /libs/audiographer/audiographer/sndfile/tmp_file.h
parent6626723880e6d464bf8d59178120d191a8423c93 (diff)
Refactor TmpFile into an abstract base class
This allows a TmpFile pointer to be either a Sync or Async (Threaded) writer. As result we must be able to handle both RT and non RT processing. Still, post-processing (normalization and encoding) should always happen faster than realtime (freewheeling). Since jack does not allow a client to change to freewheeling from within the process-callback, the async-writer disk-thread FileFlushed is used to initiate post-processing.
Diffstat (limited to 'libs/audiographer/audiographer/sndfile/tmp_file.h')
-rw-r--r--libs/audiographer/audiographer/sndfile/tmp_file.h32
1 files changed, 5 insertions, 27 deletions
diff --git a/libs/audiographer/audiographer/sndfile/tmp_file.h b/libs/audiographer/audiographer/sndfile/tmp_file.h
index c53557beda..d6bc5546a5 100644
--- a/libs/audiographer/audiographer/sndfile/tmp_file.h
+++ b/libs/audiographer/audiographer/sndfile/tmp_file.h
@@ -15,36 +15,14 @@ namespace AudioGrapher
/// A temporary file deleted after this class is destructed
template<typename T = DefaultSampleType>
-class TmpFile : public SndfileWriter<T>, public SndfileReader<T>
+class TmpFile
+ : public SndfileWriter<T>
+ , public SndfileReader<T>
{
public:
+ virtual ~TmpFile () {}
+ PBD::Signal0<void> FileFlushed;
- /// \a filename_template must match the requirements for mkstemp, i.e. end in "XXXXXX"
- TmpFile (char * filename_template, int format, ChannelCount channels, framecnt_t samplerate)
- : SndfileHandle (g_mkstemp(filename_template), true, SndfileBase::ReadWrite, format, channels, samplerate)
- , filename (filename_template)
- {}
-
- TmpFile (int format, ChannelCount channels, framecnt_t samplerate)
- : SndfileHandle (fileno (tmpfile()), true, SndfileBase::ReadWrite, format, channels, samplerate)
- {}
-
- TmpFile (TmpFile const & other) : SndfileHandle (other) {}
- using SndfileHandle::operator=;
-
- ~TmpFile()
- {
- /* explicitly close first, some OS (yes I'm looking at you windows)
- * cannot delete files that are still open
- */
- if (!filename.empty()) {
- SndfileBase::close();
- std::remove(filename.c_str());
- }
- }
-
- private:
- std::string filename;
};
} // namespace