RIFF: fix sizes. (PR #1214)

This commit is contained in:
Andrea 2023-04-23 21:10:51 +02:00 committed by GitHub
parent 273d07d83f
commit a140946a23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,7 +32,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
static HANDLE g_hRiffFile = INVALID_HANDLE_VALUE;
static DWORD dwTotalOffset;
static DWORD dwDataOffset;
static DWORD g_dwTotalNumberOfBytesWritten = 0;
static unsigned int g_NumChannels = 2;
bool RiffInitWriteFile(const char* pszFile, unsigned int sample_rate, unsigned int NumChannels)
@ -106,11 +105,13 @@ bool RiffFinishWriteFile()
DWORD dwNumberOfBytesWritten;
temp32 = g_dwTotalNumberOfBytesWritten - (dwTotalOffset + 4);
DWORD fileSize = SetFilePointer(g_hRiffFile, 0, NULL, FILE_END);
temp32 = fileSize - (dwTotalOffset + 4);
SetFilePointer(g_hRiffFile, dwTotalOffset, NULL, FILE_BEGIN);
WriteFile(g_hRiffFile, &temp32, 4, &dwNumberOfBytesWritten, NULL);
temp32 = g_dwTotalNumberOfBytesWritten - (dwDataOffset + 4);
temp32 = fileSize - (dwDataOffset + 4);
SetFilePointer(g_hRiffFile, dwDataOffset, NULL, FILE_BEGIN);
WriteFile(g_hRiffFile, &temp32, 4, &dwNumberOfBytesWritten, NULL);
@ -133,7 +134,5 @@ bool RiffPutSamples(const short* buf, unsigned int uSamples)
&dwNumberOfBytesWritten,
NULL);
g_dwTotalNumberOfBytesWritten += dwNumberOfBytesWritten;
return true;
}