<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">r476 | r2d | 2011-11-24 22:45:02 +0000 (Thu, 24 Nov 2011) | 4 lines
Changed paths:
   M /libmpc/trunk/libmpcdec/mpc_demux.c

changes a seeking behavior that confused some people using the library.
mpc_demux_decode() would return zero samples a couple of times requiring the caller to loop over.
patch by DEATH

------------------------------------------------------------------------
Index: libmpcdec/mpc_demux.c
===================================================================
diff --git a/libmpcdec/mpc_demux.c b/libmpc/libmpcdec/mpc_demux.c
--- a/libmpcdec/mpc_demux.c	(revision 475)
+++ b/libmpcdec/mpc_demux.c	(revision 476)
@@ -637,10 +637,15 @@
 }
 
 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-&gt;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-&gt;bits = -1; // we pretend it's end of file
+
+		if (MPC_IS_FAILURE(s) || i-&gt;samples &gt; 0)
+			return s;
+	}
 }
 
 mpc_status mpc_demux_seek_second(mpc_demux * d, double seconds)
</pre></body></html>