mirror of
https://github.com/samsonjs/media.git
synced 2026-04-17 13:15:47 +00:00
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
0e16c43f0c
commit
94a5e9bc3a
1 changed files with 12 additions and 2 deletions
|
|
@ -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…
Reference in a new issue