Just using a while loop is not realy an option here, as it'd not work with the timeout.
Anyway, I'm going to remove this function entirely, as I stopped using it in CDecoder::GetPicture, which was the only place where it was used.