SPC files keep playing past end

Issue #25 resolved
Ben Larson created an issue

I've been trying to convert SPC files to Ogg Vorbis using VLC, but many of the SPC files play past the supposed end. For example, an SPC file with a length of 2:00 will keep going to 2:30 and beyond. I have confirmed that this happens while playing SPC files normally as well, but it's a bigger issue when converting to a different format, because it results in huge file sizes. There are similar issues on the VLC bug tracker, but they haven't been resolved because the issue is in game-music-emu.

After investigating the issue using the source code, I have found that the length from the SPC header (which is read by get_spc_info() in Spc_Emu.cpp) seems to be ignored in Spc_Emu::play_() and similar functions.

It seems that the proper solution would be to put a length check in Spc_Emu::play_() or one of the higher- or lower-level play functions. This should probably be complemented by a similar check in the corresponding skip function.

Comments (4)

  1. Michael Pyne repo owner

    This has normally been a function of the client application itself (using gme_set_fade, to permit the player the option of whether to play for an arbitrary time or not (e.g. as this NaCl-based player does: http://gamemusic.multimedia.cx/).

    But I can see why this would be annoying for this use case. Maybe the best thing is to default the fade start to the encoded SPC length and instead allow the player to set the fade start to 0 for infinite playback.

  2. Ben Larson reporter

    Yeah, that should help. It would probably be best for the default to have the nominal duration and actual duration be exactly equal, rather than adding a few seconds to fade out, because that's what people would expect. FFmpeg treats this library as a decoder, and fading and most other effects fall outside of that scope.

    Also, VLC has a 'skip-underrun' patch for GME that fixes the crash that otherwise occurs whenever a user tries to seek ahead rather than playing the whole audio track sequentially. I suggest that the patch be incorporated into GME.

  3. Log in to comment