diff --git a/apps/codecs/libmusepack/mpc_demux.c b/apps/codecs/libmusepack/mpc_demux.c index 97a431e597..3f4c9d021a 100644 --- a/apps/codecs/libmusepack/mpc_demux.c +++ b/apps/codecs/libmusepack/mpc_demux.c @@ -625,10 +625,15 @@ static mpc_status mpc_demux_decode_inner(mpc_demux * d, mpc_frame_info * i) } mpc_status mpc_demux_decode(mpc_demux * d, mpc_frame_info * i) { - mpc_status s = mpc_demux_decode_inner(d, i); - if (MPC_IS_FAILURE(s)) - i->bits = -1; // we pretend it's end of file - return s; + for(;;) { + // mpc_demux_decode_inner may return 0 samples and require repeated calls after a seek. Loop over until we have data to return. + mpc_status s = mpc_demux_decode_inner(d, i); + if (MPC_IS_FAILURE(s)) + i->bits = -1; // we pretend it's end of file + + if (MPC_IS_FAILURE(s) || i->samples > 0) + return s; + } } /* rockbox: not used