libgme/game-music-emu

Seek time is doubled on stereo channels

Wohlstand opened this issue · 1 comments

Original report by jimbo1qaz (Bitbucket: jimbo1qaz, ).


https://github.com/dv1/gst-nonstream-audio/blob/master/ext/gme/gstgmedec.c#L314-L320

static gboolean gst_gme_dec_seek(GstNonstreamAudioDecoder *dec, GstClockTime *new_position)
{
err = gme_seek(gme_dec->emu, *new_position / GST_MSECOND);

BLARGG_EXPORT gme_err_t gme_seek ( Music_Emu* me, int msec ) { return me->seek( msec ); }

blargg_err_t Music_Emu::seek( long msec )
{
return seek_samples( msec_to_samples( msec ) );
}

blargg_long Music_Emu::msec_to_samples( blargg_long msec ) const
{
blargg_long sec = msec / 1000;
msec -= sec * 1000;
return (sec * sample_rate() + msec * sample_rate() / 1000) * out_channels();
}

When I launch vlc file.spc --start-time 1, where file.spc is stereo, VLC uses gstreamer and tries to seek by 1000 ms. But msec_to_samples instead returns 2000 ms (converted into samples). Consequently VLC starts playing 2 seconds in.

Original comment by Michael Pyne (Bitbucket: mpyne, GitHub: mpyne).


Without having looked at the code, perhaps an issue in seek_samples? I can do some digging to figure out whether it was intentional for code like msec_to_samples to inflate by the number of audio channels or not.