Skip to content
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
merged 11 commits into from
May 9, 2015

Conversation

popcornmix
Copy link
Member

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.

@popcornmix
Copy link
Member Author

jenkins build this please

@popcornmix
Copy link
Member Author

@FernetMenta any objections?

@FernetMenta
Copy link
Contributor

go ahead

popcornmix added a commit that referenced this pull request May 9, 2015
[mmal] Fix issues related to mmal buffer reference counts
@popcornmix popcornmix merged commit 6a15253 into xbmc:master May 9, 2015
@popcornmix popcornmix deleted the mmal_refcounts branch May 9, 2015 16:43
@hudokkow hudokkow added this to the Isengard 15.0-beta2 milestone May 9, 2015
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants