Effect: Fix concurrent access null pointer exception
A list was being accessed from one thread when it wasn't guaranteed to be empty. PiperOrigin-RevId: 529102141
This commit is contained in:
parent
bba760f6e5
commit
93e3fe418e
@ -263,7 +263,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
||||
// A queue of input streams that have not been fully processed identified by their input types.
|
||||
private final Queue<@InputType Integer> unprocessedInputStreams;
|
||||
|
||||
@Nullable private volatile CountDownLatch latch;
|
||||
private volatile @MonotonicNonNull CountDownLatch latch;
|
||||
|
||||
private volatile @MonotonicNonNull FrameInfo nextInputFrameInfo;
|
||||
private volatile boolean inputStreamEnded;
|
||||
@ -355,16 +355,18 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
||||
@Override
|
||||
public void registerInputStream(@InputType int inputType) {
|
||||
if (!unprocessedInputStreams.isEmpty()) {
|
||||
textureManager.signalEndOfCurrentInputStream();
|
||||
// Wait until the current video is processed before continuing to the next input.
|
||||
if (checkNotNull(unprocessedInputStreams.peek()) == INPUT_TYPE_SURFACE) {
|
||||
latch = new CountDownLatch(1);
|
||||
textureManager.signalEndOfCurrentInputStream();
|
||||
try {
|
||||
latch.await();
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
Log.e(TAG, "Error waiting for end of stream " + e);
|
||||
}
|
||||
} else {
|
||||
textureManager.signalEndOfCurrentInputStream();
|
||||
}
|
||||
}
|
||||
unprocessedInputStreams.add(inputType);
|
||||
|
Loading…
x
Reference in New Issue
Block a user