mirror of
https://github.com/samsonjs/media.git
synced 2026-03-30 10:15:48 +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
fe710871aa
commit
87d1c3e624
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