Skip to content

Break circular references among dma surfaces and GstMemory

He Junyan requested to merge He_Junyan/gstreamer-vaapi:dma_buffer into master

I just want to improve the code of the DMA/Surface and buffer pool for allocating it.

There are 2 major changes in this MR:

  1. Make the DMA buffer belong to surface. Let the surface own the buffer proxy, this avoid the circular ref which is mentioned in !296 (closed).
  2. Also clear the mem refed by the proxy buffer. The mem already contains the vmeta/surface, and if surface/proxy_buf ref the mem again, it is easy to make code logic confused. So I change the buffer pool's allocation manner for DMA surfaces, using a table to cache the created mem, replacing the old tricky logic.

For DMA buffer pool allocation, there are 2 manner:

  1. Do not provide surface, which is VPP's manner. We just create the surface, make the surface extend to DMA, creating a mem to the according FD, and then bind that surface to buffer->meta. men does not need to hold the surface. We do nothing when _reset, leave the buffer/meta/mem all untouched when cached in buffer_pool.
  2. The user provides the surface when acquire buffer, which is the decoder's manner. If the surface has been exported to DMA before, find the according mem and binding it to the buffer. If not, export the surface, creating the mem, binding it to the buffer, and the same time creating a mapping slot in the cache table. When _reset, we unset the binding of surface from buffer->meta to let it be freed to decoder's surface_pool.
Edited by Víctor Manuel Jáquez Leal

Merge request reports