mirror of
https://github.com/samsonjs/media.git
synced 2026-04-05 11:15:46 +00:00
Fix threading issueis in SequenceAssetLoaderListener
Callbacks onTrackCount and onTrackAdded can be called simultaneously from different threads. Before this fix, it was possible for the MuxerWrapper and FallbackListener track count to never be set, or to be set with incorrect values. PiperOrigin-RevId: 514779719
This commit is contained in:
parent
62c0352416
commit
67d15ec575
1 changed files with 2 additions and 3 deletions
|
|
@ -440,8 +440,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||
ERROR_CODE_FAILED_RUNTIME_CHECK));
|
||||
return;
|
||||
}
|
||||
trackCountsToReport.decrementAndGet();
|
||||
tracksToAdd.addAndGet(trackCount);
|
||||
trackCountsToReport.decrementAndGet();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -465,12 +465,11 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||
} else {
|
||||
outputHasVideo.set(true);
|
||||
}
|
||||
if (trackCountsToReport.get() == 0 && tracksToAdd.get() == 1) {
|
||||
if (trackCountsToReport.get() == 0 && tracksToAdd.decrementAndGet() == 0) {
|
||||
int outputTrackCount = (outputHasAudio.get() ? 1 : 0) + (outputHasVideo.get() ? 1 : 0);
|
||||
muxerWrapper.setTrackCount(outputTrackCount);
|
||||
fallbackListener.setTrackCount(outputTrackCount);
|
||||
}
|
||||
tracksToAdd.decrementAndGet();
|
||||
|
||||
return trackInfo.shouldTranscode;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue