libgme / game-music-emu

Blargg's video game music emulation library, which allows audio applications to easily add playback support for the music of many classic video game consoles.
GNU Lesser General Public License v2.1
68 stars 12 forks source link

Seek time is doubled on stereo channels #28

Open Wohlstand opened 5 years ago

Wohlstand commented 5 years ago

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.

Wohlstand commented 5 years ago

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.