mirror of
https://github.com/samsonjs/media.git
synced 2026-03-26 09:35:47 +00:00
Ignore blockingSendMessage calls after release.
Previously we'd end up blocking forever in this case, which is the worst thing we could do :). We could either throw an exception or just print a warning. Printing a warning is more in line with what other methods do (Handler prints a "sending message to dead thread" warning).
This commit is contained in:
parent
da125bb5cc
commit
fc230733ae
1 changed files with 15 additions and 10 deletions
|
|
@ -158,6 +158,10 @@ import java.util.List;
|
|||
|
||||
public synchronized void blockingSendMessage(ExoPlayerComponent target, int messageType,
|
||||
Object message) {
|
||||
if (released) {
|
||||
Log.w(TAG, "Sent message(" + messageType + ") after release. Message ignored.");
|
||||
return;
|
||||
}
|
||||
int messageNumber = customMessagesSent++;
|
||||
handler.obtainMessage(MSG_CUSTOM, messageType, 0, Pair.create(target, message)).sendToTarget();
|
||||
while (customMessagesProcessed <= messageNumber) {
|
||||
|
|
@ -170,17 +174,18 @@ import java.util.List;
|
|||
}
|
||||
|
||||
public synchronized void release() {
|
||||
if (!released) {
|
||||
handler.sendEmptyMessage(MSG_RELEASE);
|
||||
while (!released) {
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
internalPlaybackThread.quit();
|
||||
if (released) {
|
||||
return;
|
||||
}
|
||||
handler.sendEmptyMessage(MSG_RELEASE);
|
||||
while (!released) {
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
internalPlaybackThread.quit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in a new issue