Browse Source

+ support reading .wav files that have extra data in the end of the 'fmt '
chunk. Added test case, which is a file, generated by the Euphoric emulator.

git-svn-id: trunk@47461 -

nickysn 4 years ago
parent
commit
46b35256bd

+ 3 - 0
.gitattributes

@@ -4344,6 +4344,9 @@ packages/fcl-sound/tests/data/wav/reader/valid/44k_stereo_32.wav.raw -text
 packages/fcl-sound/tests/data/wav/reader/valid/44k_stereo_8.wav -text svneol=unset#audio/x-wav
 packages/fcl-sound/tests/data/wav/reader/valid/44k_stereo_8.wav.info.txt svneol=native#text/plain
 packages/fcl-sound/tests/data/wav/reader/valid/44k_stereo_8.wav.raw -text svneol=unset#application/octet-stream
+packages/fcl-sound/tests/data/wav/reader/valid/euphoric_tape.wav -text svneol=unset#audio/x-wav
+packages/fcl-sound/tests/data/wav/reader/valid/euphoric_tape.wav.info.txt svneol=native#text/plain
+packages/fcl-sound/tests/data/wav/reader/valid/euphoric_tape.wav.raw -text svneol=unset#application/octet-stream
 packages/fcl-sound/tests/tcwavreader.pas svneol=native#text/plain
 packages/fcl-sound/tests/testfclsound.lpi svneol=native#text/plain
 packages/fcl-sound/tests/testfclsound.lpr svneol=native#text/plain

+ 3 - 1
packages/fcl-sound/src/fpwavreader.pas

@@ -94,7 +94,9 @@ begin
   Result := Result and (riff.ChunkHeader.ID = AUDIO_CHUNK_ID_RIFF) and (riff.Format = AUDIO_CHUNK_ID_WAVE);
   Result := Result and (fStream.Read(fmt, sizeof(fmt)) = sizeof(fmt));
   LEtoN(fmt);
-  Result := Result and (fmt.ChunkHeader.ID = AUDIO_CHUNK_ID_fmt);
+  Result := Result and (fmt.ChunkHeader.ID = AUDIO_CHUNK_ID_fmt) and ((fmt.ChunkHeader.Size + 8) >= sizeof(fmt));
+  if Result and ((fmt.ChunkHeader.Size + 8) > sizeof(fmt)) then
+    fStream.Seek((fmt.ChunkHeader.Size + 8) - sizeof(fmt), soCurrent);
   if Result and (fmt.Format <> 1) then 
     Exit(False);
 end;

BIN
packages/fcl-sound/tests/data/wav/reader/valid/euphoric_tape.wav


+ 1 - 0
packages/fcl-sound/tests/data/wav/reader/valid/euphoric_tape.wav.info.txt

@@ -0,0 +1 @@
+4800 1 8

File diff suppressed because it is too large
+ 0 - 0
packages/fcl-sound/tests/data/wav/reader/valid/euphoric_tape.wav.raw


+ 1 - 0
packages/fcl-sound/tests/tcwavreader.pas

@@ -84,6 +84,7 @@ begin
   TestValidFile('44k_stereo_24.wav');
   TestValidFile('44k_stereo_32.wav');
   TestValidFile('44k_mono_16_tag.wav');
+  TestValidFile('euphoric_tape.wav');
 end;
 
 

+ 1 - 0
packages/fcl-sound/tests/testfclsound.lpi

@@ -49,6 +49,7 @@
     </Target>
     <SearchPaths>
       <IncludeFiles Value="$(ProjOutDir)"/>
+      <OtherUnitFiles Value="../src"/>
       <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
     </SearchPaths>
     <Linking>

Some files were not shown because too many files changed in this diff