mirror of
https://github.com/samsonjs/media.git
synced 2026-03-25 09:25:53 +00:00
Wait for HandlerThread to terminate after calling quit.
Calling HandlerThread.quit() or .quitSafely() doesn't immediately terminate the thread. It just instructs the Looper not to accept any new messages and to terminate at the next opportunity. Added a HandlerThread.join() everywhere where the intention is to close and release all resources and to stop all threads. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=171525241
This commit is contained in:
parent
54d3df4b63
commit
030f52b41b
2 changed files with 9 additions and 1 deletions
|
|
@ -304,7 +304,6 @@ import java.io.IOException;
|
|||
// Restore the interrupted status.
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
internalPlaybackThread.quit();
|
||||
}
|
||||
|
||||
public Looper getPlaybackLooper() {
|
||||
|
|
@ -840,6 +839,7 @@ import java.io.IOException;
|
|||
resetInternal(true);
|
||||
loadControl.onReleased();
|
||||
setState(Player.STATE_IDLE);
|
||||
internalPlaybackThread.quit();
|
||||
synchronized (this) {
|
||||
released = true;
|
||||
notifyAll();
|
||||
|
|
|
|||
|
|
@ -212,9 +212,17 @@ public class FakeSimpleExoPlayer extends SimpleExoPlayer {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("ThreadJoinLoop")
|
||||
public void release() {
|
||||
stop();
|
||||
playbackThread.quitSafely();
|
||||
while (playbackThread.isAlive()) {
|
||||
try {
|
||||
playbackThread.join();
|
||||
} catch (InterruptedException e) {
|
||||
// Ignore interrupt.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in a new issue