///////////////////////////////////////////////////////
| 310 | |
| 311 | //////////////////////////////////////////////////////////// |
| 312 | void SoundFileWriterWav::close() |
| 313 | { |
| 314 | // If the file is open, finalize the header and close it |
| 315 | if (m_file.is_open()) |
| 316 | { |
| 317 | m_file.flush(); |
| 318 | |
| 319 | // Update the main chunk size and data sub-chunk size |
| 320 | const std::uint32_t fileSize = static_cast<std::uint32_t>(m_file.tellp()); |
| 321 | m_file.seekp(4); |
| 322 | encode(m_file, fileSize - 8); // 8 bytes RIFF header |
| 323 | m_file.seekp(40); |
| 324 | encode(m_file, fileSize - 44); // 44 bytes RIFF + WAVE headers |
| 325 | |
| 326 | m_file.close(); |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | } // namespace sf::priv |