Most of the cases it's enought just to set pts so codec resyncs itself. Also flushing on discontinue isn't good idea.