Fix wave file header lengths

This commit is contained in:
Peter L Jones 2019-04-21 22:13:07 +01:00
parent 1d2a240eec
commit e3025e5492
3 changed files with 8 additions and 4 deletions

View file

@ -120,10 +120,13 @@ void CWaveStream::waveStreamHeaders()
*this << scHdrRiff << cFmtSubChunk << scDataSubChunkHdr; *this << scHdrRiff << cFmtSubChunk << scDataSubChunkHdr;
} }
CWaveStream::~CWaveStream() void CWaveStream::finalise()
{ {
static const uint32_t hdrRiffChunkSize = sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t);
static const uint32_t fmtSubChunkSize = sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t);
static const uint32_t hdrRiffChunkSizeOffset = sizeof(uint32_t); static const uint32_t hdrRiffChunkSizeOffset = sizeof(uint32_t);
static const uint32_t dataSubChunkHdrChunkSizeOffset = sizeof(HdrRiff) + sizeof(FmtSubChunk) + sizeof (uint32_t) + sizeof (uint32_t); static const uint32_t dataSubChunkHdrChunkSizeOffset = hdrRiffChunkSize + fmtSubChunkSize + sizeof (uint32_t);
const int64_t currentPos = this->device()->pos(); const int64_t currentPos = this->device()->pos();
const uint32_t fileLength = static_cast<uint32_t>(currentPos - initialPos); const uint32_t fileLength = static_cast<uint32_t>(currentPos - initialPos);

View file

@ -73,7 +73,8 @@ public:
explicit CWaveStream(QIODevice *iod, const uint16_t numChannels); explicit CWaveStream(QIODevice *iod, const uint16_t numChannels);
CWaveStream(QByteArray *iod, QIODevice::OpenMode flags, const uint16_t numChannels); CWaveStream(QByteArray *iod, QIODevice::OpenMode flags, const uint16_t numChannels);
CWaveStream(const QByteArray &ba, const uint16_t numChannels); CWaveStream(const QByteArray &ba, const uint16_t numChannels);
~CWaveStream();
void finalise();
private: private:
void waveStreamHeaders(); void waveStreamHeaders();

View file

@ -87,7 +87,7 @@ void CJamClient::Frame(const QString _name, const CVector<int16_t>& pcm)
*/ */
void CJamClient::Disconnect() void CJamClient::Disconnect()
{ {
delete out; static_cast<CWaveStream*>(out)->finalise();
out = nullptr; out = nullptr;
wavFile->close(); wavFile->close();