raysan5 / rres

A simple and easy-to-use file-format to package resources
MIT License
391 stars 34 forks source link

Segfault loading sounds from unpacked wave files. #25

Open H-Art-Src opened 5 months ago

H-Art-Src commented 5 months ago
Sound SOUND;
int id = rresGetResourceId(ASSETS_DIR , filename);
if(id)
{
      printf("~Loaded sound from rres~\n");
      rresResourceChunk chunk = rresLoadResourceChunk( "resources/DATA.rres" , id);
      UnpackResourceChunk(&chunk);
          Wave tempWave = LoadWaveFromResource(rresLoadResourceChunk( "resources/DATA.rres" , id));
          SOUND = LoadSoundFromWave(tempWave);
          UnloadWave(tempWave);
      rresUnloadResourceChunk(chunk);
}

If the packaged wav file is too large, approximately > 10 mb, LoadSoundFromWave() segfaults.

H-Art-Src commented 5 months ago

Possibly related to https://github.com/raysan5/raylib/issues/1423

raysan5 commented 5 months ago

@H-Art-Src Thanks for reporting! Did you verify the data returned by LoadWaveFromResource() is correct?

H-Art-Src commented 5 months ago
    Sound SOUND;
    int id = rresGetResourceId(ASSETS_DIR , filename);
    if(id)//raysan made this shit bugged for certain wav files I'M GOING TO WORK ON RAYLIB
    {
        printf("~Loaded sound from rres~\n");
        rresResourceChunk chunk = rresLoadResourceChunk( "resources/DATA.rres" , id);
        UnpackResourceChunk(&chunk);
            Wave tempWave = LoadWaveFromResource(chunk);
            SOUND = LoadSoundFromWave(tempWave); // still segfaults here
            UnloadWave(tempWave);
        rresUnloadResourceChunk(chunk);
    }

Realized LoadWaveFromResource() should be passing chunk, but it's still segfaulting from LoadSoundFromWave().

Unpacked sound is reported to be 28,653,396 bytes from FS.

What the log shows when commentating out SOUND = LoadSoundFromWave(tempWave);:

RRES: INFO: Loading resource from file: resources/DATA.rres
RRES: INFO: Found requested resource id: 0x18705889
RRES: WAVE: Id: 0x18705889 | Base size: 28653372 | Packed size: 28653372
RRES: WAVE: WARNING: Data must be decompressed/decrypted
raysan5 commented 5 months ago

@H-Art-Src Please, could you provide some sample with files for testing?

H-Art-Src commented 5 months ago

https://mega.nz/folder/eNAjkK5J#3bnJLs4h0I_u5aQANkZl4Q White noise packed and unpacked