buffer: Free memory before meta.

Followup to "Add GstParentBufferMeta to copied buffer sharing memory",
which is a workaround to design issues in NXP's vpudec. There are
cases where vpudec will still see new buffers coming out of its buffer
pool while it's running, which causes it to error out. One such
case is

vpudec ! glupload ! tee name=t
  t. ! queue leaky=downstream ! ...
  t. ! sink

When the queue leaks a buffer it makes the next buffer writable to
mark it DISCONT. If the buffer is also in use elsewhere in the tee
a copy of the buffer will be made and the original memories attached.
When original returns to the pool and copy is still alive pool will
discard the buffer as memory isn't considered writable. Pool instead
allocates a new buffer for vpudec mid operation, which it's not
designed to handle and it falls over. Fixing vpudec is non-trivial,
instead make sure that any buffer copies outlives the original
and that we free memories before the metas that keeps the original
alive.

This is a NXP specific workaround and is not suitable for upstream.

Change-Id: I6bfbc5cc45342b79c1deddb2f416f823090806d1
1 file changed