Commit 57c5e16c authored by Jean-Paul Saman's avatar Jean-Paul Saman

codec/avcodec/vaapi_x11.c: Potential picture leaks.

- do picture refcounting from pf_release() functions.
parent 707d7b50
...@@ -691,6 +691,8 @@ static int RenderDirectSubpicture(vout_display_t *vd, picture_t *picture, subpic ...@@ -691,6 +691,8 @@ static int RenderDirectSubpicture(vout_display_t *vd, picture_t *picture, subpic
static void PictureRelease(picture_t *picture) static void PictureRelease(picture_t *picture)
{ {
if (picture->i_refcount > 0)
picture->i_refcount--;
free(picture->p_sys); free(picture->p_sys);
picture->p_sys = NULL; picture->p_sys = NULL;
} }
...@@ -700,6 +702,9 @@ static void PictureReleaseVoutOwned(picture_t *picture) ...@@ -700,6 +702,9 @@ static void PictureReleaseVoutOwned(picture_t *picture)
if (!picture->p_sys->b_own_vout) if (!picture->p_sys->b_own_vout)
abort(); abort();
if (picture->i_refcount > 0)
picture->i_refcount--;
vlc_va_surface_t *surface = picture->p_sys->surface; vlc_va_surface_t *surface = picture->p_sys->surface;
#if 0 #if 0
/* FIXME: pictures discarded by core will leak VASurfaces */ /* FIXME: pictures discarded by core will leak VASurfaces */
...@@ -726,12 +731,13 @@ static void Render(vout_display_t *vd, picture_t *picture, subpicture_t *subpict ...@@ -726,12 +731,13 @@ static void Render(vout_display_t *vd, picture_t *picture, subpicture_t *subpict
picture->p_sys = RenderImportPicture(vd, picture); picture->p_sys = RenderImportPicture(vd, picture);
if (!picture->p_sys) if (!picture->p_sys)
return; return;
assert(picture->p_sys->surface);
assert(picture->pf_release); assert(picture->pf_release);
picture->pf_release = PictureReleaseVoutOwned; picture->pf_release = PictureReleaseVoutOwned;
} }
if (picture->p_sys->surface == NULL) if (picture->p_sys->surface == NULL)
abort(); return;
vlc_mutex_lock(&picture->p_sys->surface->lock); vlc_mutex_lock(&picture->p_sys->surface->lock);
...@@ -757,6 +763,7 @@ static void Render(vout_display_t *vd, picture_t *picture, subpicture_t *subpict ...@@ -757,6 +763,7 @@ static void Render(vout_display_t *vd, picture_t *picture, subpicture_t *subpict
static void ReleaseSurfaceLocked(vlc_va_surface_t *surface) static void ReleaseSurfaceLocked(vlc_va_surface_t *surface)
{ {
if (surface->i_refcount > 0)
surface->i_refcount--; surface->i_refcount--;
assert(surface->i_refcount >= 0); assert(surface->i_refcount >= 0);
} }
...@@ -797,6 +804,7 @@ static void DisplayPicture(vout_display_t *vd, picture_t *pic, subpicture_t *sub ...@@ -797,6 +804,7 @@ static void DisplayPicture(vout_display_t *vd, picture_t *pic, subpicture_t *sub
if (pic->p_sys->surface == NULL) if (pic->p_sys->surface == NULL)
{ {
assert(!pic->p_sys->b_own_vout);
msg_Err(vd, "Discarding picture without surface information"); msg_Err(vd, "Discarding picture without surface information");
if (subpicture) if (subpicture)
subpicture_Delete(subpicture); subpicture_Delete(subpicture);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment