adapter: automatically unmap on clearing
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Tue, 15 Nov 2011 17:42:56 +0000 (17:42 +0000)
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Fri, 13 Jan 2012 13:21:27 +0000 (14:21 +0100)
commit12757e604a894533b8fcd80a128eee528a613851
tree8d3a0a9c3c0e3082b6a4b051f02188340d806768
parent247842eaa9d92aae15868afdf79ff89cbbead3a8
adapter: automatically unmap on clearing

When _clear gets called between _map and _unmap, buffers
will be unreffed. If the adapter was mapped, memory leaks
may occur.
While calling _clear between _map and _unmap does not seem
like such a great idea, this is possible in the audio
encoder base class, as _clear may be called in _finish_frame.
Since the audio encoder relies on flushing to keep track of
timestamps, delaying flushing till after handle_frame seems
dangerous.
So, we unmap on clear, as the next unmap will do nothing.
This makes _clear safe to call between _map and _unmap,
while avoiding leaking the mapped buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=664133
libs/gst/base/gstadapter.c