Adds support to cancel decoding, periodic checks for cancellation.