mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Verify a thread is alive before sending a message to it.
PiperOrigin-RevId: 568515736
This commit is contained in:
parent
69ffac28bb
commit
0b62d37425
1 changed files with 10 additions and 0 deletions
|
|
@ -209,6 +209,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
|
verifyInternalThreadAlive();
|
||||||
internalHandler.sendEmptyMessage(MSG_START);
|
internalHandler.sendEmptyMessage(MSG_START);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -216,6 +217,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
if (released) {
|
if (released) {
|
||||||
return PROGRESS_STATE_NOT_STARTED;
|
return PROGRESS_STATE_NOT_STARTED;
|
||||||
}
|
}
|
||||||
|
verifyInternalThreadAlive();
|
||||||
internalHandler.obtainMessage(MSG_UPDATE_PROGRESS, progressHolder).sendToTarget();
|
internalHandler.obtainMessage(MSG_UPDATE_PROGRESS, progressHolder).sendToTarget();
|
||||||
// TODO: figure out why calling clock.onThreadBlocked() here makes the tests fail.
|
// TODO: figure out why calling clock.onThreadBlocked() here makes the tests fail.
|
||||||
transformerConditionVariable.blockUninterruptible();
|
transformerConditionVariable.blockUninterruptible();
|
||||||
|
|
@ -227,6 +229,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
if (released) {
|
if (released) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
verifyInternalThreadAlive();
|
||||||
internalHandler
|
internalHandler
|
||||||
.obtainMessage(MSG_END, END_REASON_CANCELLED, /* unused */ 0, /* exportException */ null)
|
.obtainMessage(MSG_END, END_REASON_CANCELLED, /* unused */ 0, /* exportException */ null)
|
||||||
.sendToTarget();
|
.sendToTarget();
|
||||||
|
|
@ -239,12 +242,14 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endWithCompletion() {
|
public void endWithCompletion() {
|
||||||
|
verifyInternalThreadAlive();
|
||||||
internalHandler
|
internalHandler
|
||||||
.obtainMessage(MSG_END, END_REASON_COMPLETED, /* unused */ 0, /* exportException */ null)
|
.obtainMessage(MSG_END, END_REASON_COMPLETED, /* unused */ 0, /* exportException */ null)
|
||||||
.sendToTarget();
|
.sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endWithException(ExportException exportException) {
|
public void endWithException(ExportException exportException) {
|
||||||
|
verifyInternalThreadAlive();
|
||||||
internalHandler
|
internalHandler
|
||||||
.obtainMessage(MSG_END, END_REASON_ERROR, /* unused */ 0, exportException)
|
.obtainMessage(MSG_END, END_REASON_ERROR, /* unused */ 0, exportException)
|
||||||
.sendToTarget();
|
.sendToTarget();
|
||||||
|
|
@ -252,6 +257,10 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
|
|
||||||
// Private methods.
|
// Private methods.
|
||||||
|
|
||||||
|
private void verifyInternalThreadAlive() {
|
||||||
|
checkState(internalHandlerThread.isAlive(), "Internal thread is dead.");
|
||||||
|
}
|
||||||
|
|
||||||
private boolean handleMessage(Message msg) {
|
private boolean handleMessage(Message msg) {
|
||||||
// Some messages cannot be ignored when resources have been released. End messages must be
|
// Some messages cannot be ignored when resources have been released. End messages must be
|
||||||
// handled to report release timeouts and to unblock the transformer condition variable in case
|
// handled to report release timeouts and to unblock the transformer condition variable in case
|
||||||
|
|
@ -540,6 +549,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
// which the AssetLoader are allowed to send data. This way SampleExporter understands all
|
// which the AssetLoader are allowed to send data. This way SampleExporter understands all
|
||||||
// the inputs are registered when AssetLoader sends data.
|
// the inputs are registered when AssetLoader sends data.
|
||||||
if (assetLoaderInputTracker.hasAssociatedAllTracksWithGraphInput(trackType)) {
|
if (assetLoaderInputTracker.hasAssociatedAllTracksWithGraphInput(trackType)) {
|
||||||
|
verifyInternalThreadAlive();
|
||||||
internalHandler
|
internalHandler
|
||||||
.obtainMessage(MSG_REGISTER_SAMPLE_EXPORTER, sampleExporter)
|
.obtainMessage(MSG_REGISTER_SAMPLE_EXPORTER, sampleExporter)
|
||||||
.sendToTarget();
|
.sendToTarget();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue