Make sure that onTransformationError is called once
The second error is probably a consequence of the first one. #minor-release PiperOrigin-RevId: 424619944
This commit is contained in:
parent
8ec18086f2
commit
98a997295e
@ -933,26 +933,24 @@ public final class Transformer {
|
|||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
resourceReleaseException = TransformationException.createForUnexpected(e);
|
resourceReleaseException = TransformationException.createForUnexpected(e);
|
||||||
}
|
}
|
||||||
|
if (exception == null) {
|
||||||
if (exception == null && resourceReleaseException == null) {
|
// We only report the exception caused by releasing the resources if there is no other
|
||||||
// TODO(b/213341814): Add event flags for Transformer events.
|
// exception. It is more intuitive to call the error callback only once and reporting the
|
||||||
listeners.queueEvent(
|
// exception caused by releasing the resources can be confusing if it is a consequence of
|
||||||
/* eventFlag= */ C.INDEX_UNSET,
|
// the first exception.
|
||||||
listener -> listener.onTransformationCompleted(mediaItem));
|
exception = resourceReleaseException;
|
||||||
listeners.flushEvents();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exception != null) {
|
if (exception != null) {
|
||||||
|
TransformationException finalException = exception;
|
||||||
|
// TODO(b/213341814): Add event flags for Transformer events.
|
||||||
listeners.queueEvent(
|
listeners.queueEvent(
|
||||||
/* eventFlag= */ C.INDEX_UNSET,
|
/* eventFlag= */ C.INDEX_UNSET,
|
||||||
listener -> listener.onTransformationError(mediaItem, exception));
|
listener -> listener.onTransformationError(mediaItem, finalException));
|
||||||
}
|
} else {
|
||||||
if (resourceReleaseException != null) {
|
|
||||||
TransformationException finalResourceReleaseException = resourceReleaseException;
|
|
||||||
listeners.queueEvent(
|
listeners.queueEvent(
|
||||||
/* eventFlag= */ C.INDEX_UNSET,
|
/* eventFlag= */ C.INDEX_UNSET,
|
||||||
listener -> listener.onTransformationError(mediaItem, finalResourceReleaseException));
|
listener -> listener.onTransformationCompleted(mediaItem));
|
||||||
}
|
}
|
||||||
listeners.flushEvents();
|
listeners.flushEvents();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user