mirror of
https://github.com/samsonjs/media.git
synced 2026-04-05 11:15:46 +00:00
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
1 changed files with 4 additions and 2 deletions
|
|
@ -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…
Reference in a new issue