openplanet-nl / issues

Issue tracker for Openplanet.
10 stars 0 forks source link

Game freeze when unexpected audio type loaded #423

Closed sylae closed 6 months ago

sylae commented 7 months ago
IO::File file(IO::FromStorageFolder("custombonk.wav"), IO::FileMode::Read); // actually an mp3
@bonkSound = Audio::LoadSample(file.Read(file.Size()));
file.Close();

not the end of the world but it'd be nice to check magic or something to verify a file is what the extension says it is, or at least gracefully fail (ie in the above example, setting @bonkSound to null as it does if the file doesnt exist).

codecat commented 6 months ago

Thanks, I've fixed this bug for the next release.

Also, I've added Audio::LoadSampleFromAbsolutePath to do what you're trying to do here, more efficiently. Your current code will load the file into memory twice which is not ideal.