diff options
author | Chris Robinson <[email protected]> | 2019-03-19 22:10:49 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-03-19 22:10:49 -0700 |
commit | 8a1b1f4204cf6925c1be43a38739632ba7c29036 (patch) | |
tree | 287a6c9312d3a759069c8802a2cd158f166379b6 /Alc | |
parent | 7880540407197794a24d3a0078d377603178083e (diff) |
Make sure the file is rewound before writing the wave header
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/backends/wave.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Alc/backends/wave.cpp b/Alc/backends/wave.cpp index 50142025..bf1736f2 100644 --- a/Alc/backends/wave.cpp +++ b/Alc/backends/wave.cpp @@ -224,7 +224,7 @@ ALCenum WaveBackend::open(const ALCchar *name) ALCboolean WaveBackend::reset() { - ALuint channels=0, bits=0, chanmask=0; + ALuint channels=0, bytes=0, chanmask=0; int isbformat = 0; size_t val; @@ -272,9 +272,11 @@ ALCboolean WaveBackend::reset() chanmask = 0; break; } - bits = mDevice->bytesFromFmt() * 8; + bytes = mDevice->bytesFromFmt(); channels = mDevice->channelsFromFmt(); + rewind(mFile); + fputs("RIFF", mFile); fwrite32le(0xFFFFFFFF, mFile); // 'RIFF' header len; filled in at close @@ -290,15 +292,15 @@ ALCboolean WaveBackend::reset() // 32-bit val, frequency fwrite32le(mDevice->Frequency, mFile); // 32-bit val, bytes per second - fwrite32le(mDevice->Frequency * channels * bits / 8, mFile); + fwrite32le(mDevice->Frequency * channels * bytes, mFile); // 16-bit val, frame size - fwrite16le(channels * bits / 8, mFile); + fwrite16le(channels * bytes, mFile); // 16-bit val, bits per sample - fwrite16le(bits, mFile); + fwrite16le(bytes * 8, mFile); // 16-bit val, extra byte count fwrite16le(22, mFile); // 16-bit val, valid bits per sample - fwrite16le(bits, mFile); + fwrite16le(bytes * 8, mFile); // 32-bit val, channel mask fwrite32le(chanmask, mFile); // 16 byte GUID, sub-type format |