Modify MediaRecorder stopping process to avoid blocking

1. Puller.setStopTimeUs() and Puller.stopSource() should not traverse
the looper thread because the thread may be blocked by MediaSource.read().
2. Encoder should always be released before stopping MediaSource because
MediaSource.stop() would be blocked if there are still some input
buffers being encoding.

Bug: 143046445
Bug: 148988986

Test: atest android.media.cts.MediaRecorderTest
Test: atest android.mediastress.cts.MediaRecorderStressTest
Test: atest android.hardware.cts.CameraTest

Change-Id: Ia576619dfb40c45fc7840d8febd1614d5ef09118
(cherry picked from commit 96ae963ea8703fcf9d20fc46327d0dabf538fde5)
1 file changed