xine-libs OSD stack is event driven and some memory blocks are not copied
but responsibility to free the memory moves to different layers of the
When argb_layer was introduced, this behavior was not taken into account
and as such it is likely that for example osd_free_object() frees the
argb_layer while vdpau_overlay_* functions still access the memory.
Passing responsibility for the argb_layer is not that easy as it seems as
the design goal of the argb_layer was to not duplicate any memory of the
argb_buffer which all other OSD functions usually do.
To solve this issue, argb_layer_t will be turned into a managed data
structure by introducing a ref_count member. ref_count increases as more
layers of the OSD stack hold a reference to that memory block, and it
decreases when they are no longer interested in it. When ref_count reaches
zero the memory block is freed automatically. To deal with ref counting,
set_argb_layer_ptr() has been introduced.
Some functions of the OSD layers had to be modified to deal with reference
tracking. For convinience, osd_free_object() should clear the argb_buffer
pointer so that the buffer may be freed safely after returning.
include/xine/osd.h | 2 +-
include/xine/video_out.h | 2 +
src/xine-engine/osd.c | 93 ++++++++++++++++++++++++++++++++--------
src/xine-engine/video_overlay.c | 6 ++
4 files changed, 82 insertions(+), 21 deletions(-)