Commit 50d8a585 authored by Jean-Paul Saman's avatar Jean-Paul Saman

codec/avcodec/vaapi*: Remove surface mutex.

The surface mutex is no longer needed now that VASubpictures remember
to which VASurfaceID they were attached. The subpictures are now remembered
inside picture_sys_t directly iso at the vlc_va_surface_t structure.
parent 0de3ae71
......@@ -171,7 +171,6 @@ static void DestroySurfaces( vlc_va_vaapi_t *p_va )
for( int i = 0; i < p_va->i_surface_count && p_va->p_surface; i++ )
{
vlc_va_surface_t *p_surface = &p_va->p_surface[i];
vlc_mutex_destroy(&p_surface->lock);
if( p_surface->i_id != VA_INVALID_SURFACE )
vaDestroySurfaces( p_va->conn->p_display, &p_surface->i_id, 1 );
}
......@@ -213,7 +212,6 @@ static int CreateSurfaces( vlc_va_vaapi_t *p_va, void **pp_hw_ctx, vlc_fourcc_t
p_surface->i_id = pi_surface_id[i];
p_surface->i_refcount = 0;
p_surface->i_order = 0;
vlc_mutex_init(&p_surface->lock);
}
/* Create a context */
......@@ -393,7 +391,6 @@ static vlc_va_surface_t *FindSurface( vlc_va_t *p_external, const VASurfaceID i_
for( int i = 0; i < p_va->i_surface_count; i++ )
{
vlc_va_surface_t *p_tmp = &p_va->p_surface[i];
vlc_mutex_lock(&p_tmp->lock);
if( p_tmp->i_id == i_surface_id )
{
/* NOTE: p_tmp->i_refcount can be greater then 1, when surfaces are being reclaimed
......@@ -401,10 +398,8 @@ static vlc_va_surface_t *FindSurface( vlc_va_t *p_external, const VASurfaceID i_
*/
p_tmp->i_refcount++;
p_surface = p_tmp;
vlc_mutex_unlock(&p_tmp->lock);
break;
}
vlc_mutex_unlock(&p_tmp->lock);
}
return p_surface;
}
......@@ -460,7 +455,6 @@ static int Get( vlc_va_t *p_external, AVFrame *p_ff )
i = i_old;
vlc_va_surface_t *p_surface = &p_va->p_surface[i];
vlc_mutex_lock(&p_surface->lock);
/* NOTE: when the surface is in use and not consumed by vout vaapi-x11,
* then p_surface->i_refcount can be greater then 0. Thus always increment.
*/
......@@ -476,7 +470,6 @@ static int Get( vlc_va_t *p_external, AVFrame *p_ff )
if( i == 0 || i == 3 )
p_ff->data[i] = (void*)(uintptr_t)p_surface->i_id;/* Yummie */
}
vlc_mutex_unlock(&p_surface->lock);
return VLC_SUCCESS;
}
static void Release( vlc_va_t *p_external, AVFrame *p_ff )
......@@ -489,10 +482,8 @@ static void Release( vlc_va_t *p_external, AVFrame *p_ff )
{
vlc_va_surface_t *p_surface = &p_va->p_surface[i];
vlc_mutex_lock(&p_surface->lock);
if( p_surface->i_id == i_surface_id )
p_surface->i_refcount--;
vlc_mutex_unlock(&p_surface->lock);
}
}
......
......@@ -39,8 +39,6 @@ typedef struct
VASurfaceID i_id;
int i_refcount;
unsigned int i_order;
vlc_mutex_t lock;
} vlc_va_surface_t;
struct picture_sys_t
......
......@@ -628,7 +628,6 @@ static picture_sys_t *RenderImportPicture(vout_display_t *vd, picture_t *picture
vaDestroyImage(sys->conn->p_display, image.image_id);
pic_sys->surface->i_refcount = 1;
vlc_mutex_init(&pic_sys->surface->lock);
return pic_sys;
}
......@@ -748,7 +747,6 @@ static void PictureReleaseVoutOwned(picture_t *picture)
if (surface->i_id != VA_INVALID_SURFACE)
vaDestroySurfaces(sys->conn->p_display, &surface->i_id, 1);
#endif
vlc_mutex_destroy(&surface->lock);
free(surface);
free(picture->p_sys);
picture->p_sys = NULL;
......@@ -786,8 +784,6 @@ static void Render(vout_display_t *vd, picture_t *picture, subpicture_t *subpict
if (!picture->p_sys->surface)
return;
vlc_mutex_lock(&picture->p_sys->surface->lock);
/* count RGBA subpicture regions */
int i_region = 0;
......@@ -804,15 +800,12 @@ static void Render(vout_display_t *vd, picture_t *picture, subpicture_t *subpict
if ((i_region > 0) &&
(RenderDirectSubpicture(vd, picture, subpicture, i_region) != VLC_SUCCESS))
msg_Err(vd, "failed rendering subtitles");
vlc_mutex_unlock(&picture->p_sys->surface->lock);
}
static void ReleaseSurfaceLocked(vlc_va_surface_t *surface)
static void ReleaseSurface(vlc_va_surface_t *surface)
{
if (surface->i_refcount > 0)
surface->i_refcount--;
assert(surface->i_refcount >= 0);
}
static void DisplayVASurface(vout_display_t *vd, VASurfaceID surface, picture_t *picture)
......@@ -863,8 +856,6 @@ static void DisplayPicture(vout_display_t *vd, picture_t *pic, subpicture_t *sub
return;
}
vlc_mutex_lock(&pic->p_sys->surface->lock);
unsigned int i_order = (sys->i_display_order > 0) ?
sys->i_display_order++ : pic->p_sys->surface->i_order;
if ((i_order != pic->p_sys->surface->i_order) &&
......@@ -895,8 +886,7 @@ cleanup:
vaDestroySurfaces(sys->conn->p_display, &pic->p_sys->surface->i_id, 1);
}
ReleaseSurfaceLocked(pic->p_sys->surface);
vlc_mutex_unlock(&pic->p_sys->surface->lock);
ReleaseSurface(pic->p_sys->surface);
if (!pic->p_sys->b_own_vout)
pic->p_sys->surface = NULL;
......
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