Commit 5042a545 authored by Jean-Paul Saman's avatar Jean-Paul Saman

VAAPI-X11: cleanup and properly lock refcounting

- remove debugging
- add locking around refcounting where it was missing
parent a3108740
......@@ -520,6 +520,9 @@ void CloseVaapiX11(vlc_object_t *obj)
vlc_array_remove(&sys->cache, i);
if (cache->i_refcount > 0)
cache_unref(cache);
msg_Info(vd, "cache id %d refcount %d", cache->i_id, cache->i_refcount);
cache_SubpictureDestroy(vd, sys->conn, cache);
cache_destroy(cache);
cache = NULL;
......@@ -971,7 +974,9 @@ static int SubpictureRegionsLink(vout_display_t *vd, const picture_t *picture)
cleanup:
/* Cleanup linked subpictures */
#ifdef VAAPI_DEBUG
msg_Err(vd, "unlink surface %d cache %d", surface->i_id, cache->i_id);
#endif
for (int i = 0; i < i_sub; i++)
{
vasubpicture_cache_t *sub = vlc_array_item_at_index(&cache->subpictures, i);
......@@ -1103,9 +1108,6 @@ static int RenderDirectSubpicture(vout_display_t *vd, picture_t *picture, subpic
cache->i_start = subpicture->i_start;
cache->i_stop = subpicture->i_stop;
msg_Info(vd, "Subpicture cache count %d (%d/%d)",
vlc_array_count(&sys->cache), sys->render.i_cache, cache->i_id);
#ifdef VAAPI_DEBUG
msg_Dbg(vd, "new subpicture %p prev %p cache %d surface %d",
subpicture, sys->render.prev_subpicture, cache->i_id, surface->i_id);
......@@ -1177,11 +1179,11 @@ static int RenderCachedSubpictures(vout_display_t *vd, picture_t *picture,
goto cleanup;
assert(cache->i_id > 0);
#if 0
if ((cache->i_start != subpicture->i_start) &&
(cache->i_stop != subpicture->i_stop))
goto cleanup;
#endif
/* Check if all subpictures region pictures match */
const int count = vlc_array_count(&cache->subpictures);
int i_sub = 0;
......@@ -1223,8 +1225,8 @@ static int RenderCachedSubpictures(vout_display_t *vd, picture_t *picture,
cleanup:
/* Cannot reuse this cached subpicture */
msg_Err(vd, "cannot reuse cached subpicture %d for surface %d -- resetting",
cache->i_id, surface->i_id);
msg_Warn(vd, "cannot reuse cached subpicture %d for surface %d -- resetting",
cache->i_id, surface->i_id);
sys->render.prev_subpicture = NULL;
vlc_mutex_unlock(&sys->cache_lock);
return VLC_EGENERIC;
......@@ -1268,7 +1270,11 @@ again:
{
/* Release exra reference */
if (sys->render.i_cache > 0)
{
vlc_mutex_lock(&sys->cache_lock);
cache_SubpictureRelease(vd, sys->render.i_cache);
vlc_mutex_unlock(&sys->cache_lock);
}
/* render new subpicture */
if (RenderDirectSubpicture(vd, picture, subpicture) != VLC_SUCCESS)
......@@ -1278,7 +1284,9 @@ again:
sys->render.i_stop = subpicture->i_stop;
/* Hold extra reference */
vlc_mutex_lock(&sys->cache_lock);
cache_SubpictureHold(vd, sys->render.i_cache);
vlc_mutex_unlock(&sys->cache_lock);
}
}
......
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