Commit 030f52b4 by tonihei Committed by Oliver Woodman

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
parent 54d3df4b
...@@ -304,7 +304,6 @@ import java.io.IOException; ...@@ -304,7 +304,6 @@ import java.io.IOException;
// Restore the interrupted status. // Restore the interrupted status.
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
internalPlaybackThread.quit();
} }
public Looper getPlaybackLooper() { public Looper getPlaybackLooper() {
...@@ -840,6 +839,7 @@ import java.io.IOException; ...@@ -840,6 +839,7 @@ import java.io.IOException;
resetInternal(true); resetInternal(true);
loadControl.onReleased(); loadControl.onReleased();
setState(Player.STATE_IDLE); setState(Player.STATE_IDLE);
internalPlaybackThread.quit();
synchronized (this) { synchronized (this) {
released = true; released = true;
notifyAll(); notifyAll();
......
...@@ -212,9 +212,17 @@ public class FakeSimpleExoPlayer extends SimpleExoPlayer { ...@@ -212,9 +212,17 @@ public class FakeSimpleExoPlayer extends SimpleExoPlayer {
} }
@Override @Override
@SuppressWarnings("ThreadJoinLoop")
public void release() { public void release() {
stop(); stop();
playbackThread.quitSafely(); playbackThread.quitSafely();
while (playbackThread.isAlive()) {
try {
playbackThread.join();
} catch (InterruptedException e) {
// Ignore interrupt.
}
}
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment