one of our players reported a game freeze when opening a map that has a soundtrack in .mod tracker format. We looked into the problem and tracked it down to a hang in FMOD_Channel_SetPosition. This appears to be an infinite loop since the function does not return even if we let the function run for 10+ minutes.
The level was configured to start music playback at offset 40 in the track’s sequence. The sequence has 67 elements in total, so offset 40 is valid. The track also has 47 patterns in total.
We open the track with FMOD_LOOP_OFF | FMOD_ACCURATETIME because we need to manually reset music channels whenever a sequence ends. Using FMOD_Channel_SetPosition(MusicChannel, Offset, FMOD_TIMEUNIT_MODORDER), we can seek to offsets 0-29 with no issues whatsoever, but seeking to offset 30 or higher makes fmod hang.
If we open the track without FMOD_ACCURATETIME, seeking to offsets 30+ works as expected. The track is copyrighted so I do not want to post a public URL here. If anyone wants to look into this, then I’d be glad to send the track over directly.
** EDIT **: I tested this with FMOD Engine 2.1.08.
To follow up on this - the hang is wrong, so i’ve submitted a patch for that so thanks for reporting it.
FMOD is trying to seek through the song by playing it in a non real-time fashion (from the start) during the setPosition call, so that it sounds right when the audio starts (no missing tracks/notes etc from the previous pattern for example).
During this process it had actually hit ‘the end of the song’, thanks to FMOD_ACCURATETIME calculating the song length as 3m46s. This is correct because the song has a ‘jump to start’ command at order 29 (even though there are many more orders). Without FMOD_ACCURATETIME it puts the length as infinity and you don’t get this issue.
This is where the setposition s3m code got confused though, and got hung up. (yes its actually a .s3m file not a .mod! )
Another workaround is to remove the b02 command from the bottom of order 29. It is a common situation to have multiple ‘songs’ inside a mod, but it doesn’t mix with FMOD_ACCURATETIME.