Infinite WAV loading fix

This commit is contained in:
Joshua Granick
2014-12-16 14:54:25 -08:00
parent 2f9fe75679
commit f0bebdcc9d
2 changed files with 6 additions and 3 deletions

View File

@@ -501,6 +501,9 @@ namespace nme
bool foundData = false; bool foundData = false;
while (!foundData) while (!foundData)
{ {
// Save the current position indicator of the stream
currentHead = ftell(f);
//Read in the the last byte of data before the sound file //Read in the the last byte of data before the sound file
result = fread(&wave_data, sizeof(WAVE_Data), 1, f); result = fread(&wave_data, sizeof(WAVE_Data), 1, f);
@@ -518,7 +521,7 @@ namespace nme
//fseek(f, wave_data.subChunkSize, SEEK_CUR); //fseek(f, wave_data.subChunkSize, SEEK_CUR);
//fseek(f, wave_data.subChunkSize, SEEK_CUR); //fseek(f, wave_data.subChunkSize, SEEK_CUR);
// Goto next chunk. // Goto next chunk.
fseek(f, currentHead + sizeof(WAVE_Data) + wave_format.subChunkSize, SEEK_SET); fseek(f, currentHead + sizeof(WAVE_Data) + wave_data.subChunkSize, SEEK_SET);
} }
else else
{ {

View File

@@ -83,7 +83,6 @@ namespace lime {
while (!foundFormat) { while (!foundFormat) {
currentHead = lime::ftell (file); currentHead = lime::ftell (file);
result = lime::fread (&wave_format, sizeof (WAVE_Format), 1, file); result = lime::fread (&wave_format, sizeof (WAVE_Format), 1, file);
if (result != 1) { if (result != 1) {
@@ -115,6 +114,7 @@ namespace lime {
while (!foundData) { while (!foundData) {
currentHead = lime::ftell (file);
result = lime::fread (&wave_data, sizeof (WAVE_Data), 1, file); result = lime::fread (&wave_data, sizeof (WAVE_Data), 1, file);
if (result != 1) { if (result != 1) {
@@ -126,7 +126,7 @@ namespace lime {
if (wave_data.subChunkID[0] != 'd' || wave_data.subChunkID[1] != 'a' || wave_data.subChunkID[2] != 't' || wave_data.subChunkID[3] != 'a') { if (wave_data.subChunkID[0] != 'd' || wave_data.subChunkID[1] != 'a' || wave_data.subChunkID[2] != 't' || wave_data.subChunkID[3] != 'a') {
lime::fseek (file, currentHead + sizeof (WAVE_Data) + wave_format.subChunkSize, SEEK_SET); lime::fseek (file, currentHead + sizeof (WAVE_Data) + wave_data.subChunkSize, SEEK_SET);
} else { } else {