Otherwise, the value of stream_index is kept from the last packet read, which is not necessarily the stream that needs flushing.