Repository navigation
fix: release resources on failed setup, rejected tasks and oversized sends - #506
Merged
Merged
Conversation
The reader and both media sources are made inside the guarded block, so a failure before the player exists, such as a source whose native library cannot be loaded, no longer leaves the file open. MediaPlayer reads the source handles before it detaches the reader, which the caller then still closes.
I420Buffer::toJava checks each direct buffer and the wrapper as it is made, holds them in JavaLocalRefs and sets the handle last. The video sink and the desktop capture callback take the frame's reference only once the wrapper exists, and give it back when the frame cannot be made.
The dispatcher submits its task with a fallback that releases what waits, counts it as dropped and clears the scheduled flag, so the next item offered tries the executor again.
Arrays and buffers take their size out of the limit before they are copied, and give it back when the copy fails, so a message too large for the limit is refused without the memory of a copy. Text longer than the limit is refused before it is encoded.
Wrappers that compare native handles hash by the handle they had when first hashed, kept for their whole life, so a disposed wrapper is still found in the set it was added to. Equality is unchanged: same live native object, or the same instance.
The timer and the audio pacer are ScheduledThreadPoolExecutors with the remove-on-cancel policy, so a timeout cancelled by a completed operation leaves the queue at once instead of when it would have been due.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MediaFileSourcefails before the player exists;MediaPlayerreads the source handles before it takes the reader over.I420Buffer::toJavaand hand over the native reference only once the wrapper exists, also in the video sink and desktop capture callback.