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
@ -158,6 +158,10 @@ import java.util.List;
|
|||||||
|
|
||||||
public synchronized void blockingSendMessage(ExoPlayerComponent target, int messageType,
|
public synchronized void blockingSendMessage(ExoPlayerComponent target, int messageType,
|
||||||
Object message) {
|
Object message) {
|
||||||
|
if (released) {
|
||||||
|
Log.w(TAG, "Sent message(" + messageType + ") after release. Message ignored.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
int messageNumber = customMessagesSent++;
|
int messageNumber = customMessagesSent++;
|
||||||
handler.obtainMessage(MSG_CUSTOM, messageType, 0, Pair.create(target, message)).sendToTarget();
|
handler.obtainMessage(MSG_CUSTOM, messageType, 0, Pair.create(target, message)).sendToTarget();
|
||||||
while (customMessagesProcessed <= messageNumber) {
|
while (customMessagesProcessed <= messageNumber) {
|
||||||
@ -170,7 +174,9 @@ import java.util.List;
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void release() {
|
public synchronized void release() {
|
||||||
if (!released) {
|
if (released) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
handler.sendEmptyMessage(MSG_RELEASE);
|
handler.sendEmptyMessage(MSG_RELEASE);
|
||||||
while (!released) {
|
while (!released) {
|
||||||
try {
|
try {
|
||||||
@ -181,7 +187,6 @@ import java.util.List;
|
|||||||
}
|
}
|
||||||
internalPlaybackThread.quit();
|
internalPlaybackThread.quit();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleMessage(Message msg) {
|
public boolean handleMessage(Message msg) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user