From 3c63cb29e945ae8e4af1a682f35f04cae5445e19 Mon Sep 17 00:00:00 2001 From: Andree Buschmann Date: Tue, 29 Nov 2011 19:48:57 +0000 Subject: [PATCH] Resync mpc to r476 of svn.musepack.org. Improves error handling after seek. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31093 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/libmusepack/mpc_demux.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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