Move destruction of VEAEncoder to encoding task runner
We were seeing random crashes in WebRtcMediaRecorderTest.*FiresErrorEvent tests
- GpuVideoEncodeAcceleratorHost::Initialize() takes a naked ptr to |client|
which is VEAEncoder.
- GpuVideoEncodeAcceleratorHost::OnRequireBitstreamBuffers() calls
- While VEAEncoder::RequireBitstreamBuffers() is running on
|encoding_task_runner_|, ~VEAEncoder() gets called on main render thread
through ~VideoTrackRecorder() after the error event.
~ VEAEncoder() needs a mechanism similar to H264Encoder::ShutdownEncoder() to
make sure that shutdown tasks on |encoding_task_runner_| are completed before
This CL solves the issues by making sure that dtor completes tasks on encoding
task runner via DestroyOnEncodingTaskRunner().
TEST=WebRtcMediaRecorderTest.*FiresErrorEvent tests consistently pass on
local Mac builds.