summaryrefslogtreecommitdiff
path: root/Audio/BWFFile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Audio/BWFFile.cpp')
-rw-r--r--Audio/BWFFile.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/Audio/BWFFile.cpp b/Audio/BWFFile.cpp
index 5ddf9d8b..e7628ccf 100644
--- a/Audio/BWFFile.cpp
+++ b/Audio/BWFFile.cpp
@@ -1171,6 +1171,27 @@ bool BWFFile::flush ()
return success;
}
+bool BWFFile::finalize ()
+{
+ if (!isOpen () || !(openMode () & WriteOnly)) {
+ setErrorString ("Cannot finalize a WAV file that is not open for writing");
+ return false;
+ }
+ auto const samplesSize = size ();
+ bool const success = m_->update_header () && m_->file_.flush ();
+ if (!success) {
+ m_->error_ = FileError::WriteError;
+ setErrorString (m_->file_.error () == FileError::NoError
+ ? QStringLiteral ("Unable to finalize WAV file header")
+ : m_->file_.errorString ());
+ }
+ m_->data_size_ = samplesSize;
+ m_->header_dirty_ = false;
+ QIODevice::close ();
+ m_->file_.close ();
+ return success;
+}
+
int BWFFile::handle () const
{
int h {m_->file_.handle ()};