libretro / libretro-gme

Port of blargg's Game_Music_Emu library
GNU General Public License v3.0
11 stars 17 forks source link

[VGZ] core crashes when loading Mega Drive music files in .vgz format #4

Closed gingerbeardman closed 6 years ago

gingerbeardman commented 6 years ago

I cannot play any Mega Drive music from http://project2612.org

These are in .vgz format

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   gme_libretro.dylib              0x0000000105c48af4 start_track + 260
1   gme_libretro.dylib              0x0000000105c489e1 open_file + 65
2   gme_libretro.dylib              0x0000000105c47da7 retro_load_game + 71
3   libretro.RetroArch              0x000000010005ad44 core_load_game + 91

In limited testing I can play: NES (.vgm) SNES (.spc) Mega Drive (.vgm) from https://www.zophar.net/music/sega-mega-drive-genesis

larrykoubiak commented 6 years ago

Hello @gingerbeardman,

i managed to reproduce the error, the crash was due to poor handling of an unrecognized file type in my code, i've now posted a fix so it now fails gracefully.

As for actual support of vgz, this seems to be broken when using the gme_load_data method (which i do to generate a playlist from several files). It's actually broken in the gme plugin for xmplay too. It checks the header for the vgm signature, but since it's loading data from memory instead of file, it doesn't decompress the data first so the signature check fails, and it returns a "Wrong file type for this emulator" error. To fix this i either have to switch my code to ask gme to actually use the physical file, or i have to make a special case for vgz to decompress the data first before sending it to gme. I'm at work now so can't work very long on this, but i'll try to come up with something that works this weekend, unless somebody else has a better method, which would be most welcome.

gingerbeardman commented 6 years ago

Thanks, I wasn't expecting such quick attention so any fix is good for me. in your own time

larrykoubiak commented 6 years ago

Ok, seems to be working now. Please let me know if you notice more issues.

FYI, you can now also load a zip file containing all your (supported) vgm files and it will make a playlist of all the recognized files, including vgz.

gingerbeardman commented 6 years ago

I'll try my best to test when the next nightly comes out