-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mmal] Fix issues related to mmal buffer reference counts #7092
Merged
Conversation
This file contains 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
This is a bit subtle, but the reference counting of pictures is only shared between arm side and gpu side when in zero copy mode.
jenkins build this please |
@FernetMenta any objections? |
go ahead |
popcornmix
added a commit
that referenced
this pull request
May 9, 2015
[mmal] Fix issues related to mmal buffer reference counts
MartijnKaijser
pushed a commit
to MartijnKaijser/xbmc
that referenced
this pull request
May 10, 2015
[mmal] Fix issues related to mmal buffer reference counts
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.
There is an occasional unreliability with mmal which can result in a hang or crash when reconfiguring components. It's most apparent when deinterlace is being enabled/disabled or when codec is being closed/opened. DVDs with deinterlace enabled, when switching between different intro scenes can trigger it.
The problem is visible as the GPU freeing a buffer that subsequently gets submitted to renderer. This is undefined and can result in bad behaviour.
Talking with the mmal experts, there were two issues with how we are using mmal. One is the reference counting of buffers doesn't include the arm side ownership. The arm and gpu sides have separate reference counts so holding an opaque buffer doesn't protect it from being freed. Enabling zero copy means there is only a single reference count and the arm side holding a buffer will stop it being freed.
The other issue is that opaque pointers belong to a pool that is attached to a mmal component's port. This is designed so memory can be automatically freed when a component is destroyed. We were attaching the pool to the video decode component's output port. However when enabling/disabling deinterlace we need to disable this port (to tunnel it to deinterlace component) and disabling a port frees the buffers attached to it. Unfortunately there are usually a few buffers queued in renderer, and submitting one of those results in the undefined behaviour.
The correct solution to this is to attach the buffers to the mmal renderer's input port. Then we can enable/disable deinterlace, and even destroy video codec without losing the buffers queued for rendering. However that requires a flow of information (the pool) from renderer to decoder, hence the need for #7087.
This change also means the lazy destroying of the video codec is no longer required, so some ugly code can be removed.
Note: first three commits of this PR are other PR's which should be merged first.