Skip to content

Commit

Permalink
Allow playback of slightly incorrect wav files.
Browse files Browse the repository at this point in the history
It will now truncate wavs where metadata says the sample is longer than it actually is.
  • Loading branch information
Altazimuth committed Jan 21, 2017
1 parent e6bfd6b commit 6526ffa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
19 changes: 19 additions & 0 deletions changelogs/maxw_changelog_1.txt
Expand Up @@ -76,6 +76,25 @@ Add Plane_Copy. It copies slopes.
Updated the credits screen to include myself, and amend Sarah Mancuso's name.
The credits now have two names per column, and are separated down the middle.

-------------------------------------------------------------------------------
2017/01/08
Fixed CMake for Windows VS2015 generation.

-------------------------------------------------------------------------------
2017/01/13
Added thing specials, made them activate on death. Useable in UDMF and
ExtraData.

-------------------------------------------------------------------------------
2017/01/14
Added ZDoom codepointer, A_SetSpecial. Fixed x/y offsets on png's being broken.
They're now no longer sunk into the floor.

-------------------------------------------------------------------------------
2017/01/21
Allow playback of slightly faulty wav files, such as those in Darch's Preacher
BOOM mapset.

================================================================================
EOF
================================================================================
8 changes: 6 additions & 2 deletions source/s_formats.cpp
Expand Up @@ -264,10 +264,14 @@ static bool S_isWaveSample(byte *data, size_t len, sounddata_t &sd)

r += 4;
size_t bytes = GetBinaryUDWord(&r);
if(!bytes || bytes + totalMDSize > len) // empty or truncated sample stream
if(!bytes) // empty sample stream
return false;

sd.samplecount = bytes / (bps/8);
if(bytes + totalMDSize > len) // truncated sample stream
sd.samplecount = (len - totalMDSize) / (bps / 8);
else
sd.samplecount = bytes / (bps / 8);

sd.samplestart = data + sampleOffset;

return true;
Expand Down

0 comments on commit 6526ffa

Please sign in to comment.