In my mind, pi_start is really just a special case of pi_next, so the code
flow makes sense to me. I'm happy to change it to whatever you like, but
it's not immediately obvious to me what that is :-)
Good question! I have missed that pi_start() can be called also with non-zero
pos when seeking.
OK, pi_start() has to handle pos == 0 special way, so let's handle it
there. Call pi_next() only when pos != 0.
The following code should do the job. I took this from my previous reply.
It is already based on the other suggested changes: