Restore the interrupted flag after blocking operations
If the main thread was interrupted during ExoPlayerImplInternal.blockingSendMessage/release, the interrupted flag was immediately set but then wait() was called on the next iteration. wait() would immediately throw InterruptedException, causing the main thread to spin until the blocking operation completed. Instead of resetting the flag immediately, reset it after the blocking operation completes. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=165426493
This commit is contained in:
parent
e0b69b8115
commit
bbc3b182bb
@ -263,13 +263,18 @@ import java.io.IOException;
|
||||
}
|
||||
int messageNumber = customMessagesSent++;
|
||||
handler.obtainMessage(MSG_CUSTOM, messages).sendToTarget();
|
||||
boolean wasInterrupted = false;
|
||||
while (customMessagesProcessed <= messageNumber) {
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
wasInterrupted = true;
|
||||
}
|
||||
}
|
||||
if (wasInterrupted) {
|
||||
// Restore the interrupted status.
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
@ -277,13 +282,18 @@ import java.io.IOException;
|
||||
return;
|
||||
}
|
||||
handler.sendEmptyMessage(MSG_RELEASE);
|
||||
boolean wasInterrupted = false;
|
||||
while (!released) {
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
wasInterrupted = true;
|
||||
}
|
||||
}
|
||||
if (wasInterrupted) {
|
||||
// Restore the interrupted status.
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
internalPlaybackThread.quit();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user