va: allocator: free allocator when a mem is held
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Tue, 17 Nov 2020 12:17:03 +0000 (13:17 +0100)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Tue, 24 Nov 2020 11:44:24 +0000 (12:44 +0100)
commit72ab56c3769ed1de06f39e3d9c776a8675821bab
tree8cfeb34c46446965b25599193f1fdb782ccc438f
parentba4442a29d1416c36fa6edcc5c2c3451bf8aaf6a
va: allocator: free allocator when a mem is held

An application, using for example appsink, can hold buffers from any
va allocator after setting the pipeline to NULL. We need to destroy
the allocator when that memory is unrefed.

This patch juggles a bit with the allocator reference count in
memories in order to achieve this:

1. When memory is created no alloc ref is modified
2. When memory is released, alloc ref is decreased
3. When memory is reassiged to a buffer, alloc ref is increased
4. When memory is flushed, alloc ref is increased becase it is going
   to be decreased in gst_memory_unref()

Also this patch moves the deallocation of member variables to
finalize() rather than dispose()

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1815>
sys/va/gstvaallocator.c