Commit f5b05c6b authored by Jean-Paul Saman's avatar Jean-Paul Saman

VAAPI-X11: subpicture_cache_t::i_id has no libva type.

Treat subpicture_cache_t::i_id as unsigned int as it should have been. Use 0 as the special value indicating an invalid subpicture_cache_t definition.
parent 0b384dd1
......@@ -132,9 +132,8 @@ static subpicture_cache_t *cache_new(void)
if (cache == NULL)
return NULL;
cache->i_id = cache_counter++;
if (cache_counter == VA_INVALID_ID)
cache_counter = 0;
cache->i_id = ++cache_counter;
assert(cache_counter > 0);
vlc_array_init(&cache->subpictures);
return cache;
}
......@@ -180,7 +179,7 @@ static inline void cache_unref(subpicture_cache_t *cache)
static vasubpicture_cache_t *subpicture_cache_new( void )
{
vasubpicture_cache_t *cache = malloc(sizeof(vasubpicture_cache_t));
vasubpicture_cache_t *cache = calloc(1, sizeof(vasubpicture_cache_t));
if (cache == NULL)
return NULL;
......@@ -448,7 +447,7 @@ int OpenVaapiX11(vlc_object_t *obj)
vlc_mutex_init(&sys->cache_lock);
sys->render.prev_subpicture = NULL;
sys->render.i_cache = VA_INVALID_ID;
sys->render.i_cache = 0;
sys->embed = MakeWindow(vd);
if (unlikely(sys->embed == NULL))
......@@ -760,7 +759,7 @@ static int SubpictureRegionsLink(vout_display_t *vd, const picture_t *picture)
if (cache == NULL)
goto error;
assert(cache->i_id != VA_INVALID_ID);
assert(cache->i_id > 0);
const int count = vlc_array_count(&cache->subpictures);
#ifdef VAAPI_DEBUG
......@@ -857,7 +856,7 @@ static void SubpictureRegionsUnlink(vout_display_t *vd, picture_t *picture)
if (cache == NULL)
goto error;
assert(cache->i_id != VA_INVALID_ID);
assert(cache->i_id > 0);
#ifdef VAAPI_DEBUG
msg_Dbg(vd, "unlink surface %d cache %d", surface->i_id, surface->i_cache);
......@@ -898,6 +897,8 @@ static void SubpictureRegionsUnlink(vout_display_t *vd, picture_t *picture)
cache = NULL;
}
surface->i_cache = 0;
error:
vlc_mutex_unlock(&sys->cache_lock);
}
......@@ -1137,10 +1138,10 @@ static int RenderCachedSubpictures(vout_display_t *vd, picture_t *picture,
if (cache == NULL)
{
msg_Dbg(vd, "did not find cached subpictures, resetting");
sys->render.i_cache = VA_INVALID_ID;
sys->render.i_cache = 0;
goto cleanup;
}
assert(cache->i_id != VA_INVALID_ID);
assert(cache->i_id > 0);
if ((cache->i_start != subpicture->i_start) &&
(cache->i_stop != subpicture->i_stop))
......@@ -1195,7 +1196,7 @@ static int RenderCachedSubpictures(vout_display_t *vd, picture_t *picture,
cleanup:
/* Cannot reuse this cached subpicture */
sys->render.i_cache = VA_INVALID_ID;
sys->render.i_cache = 0;
sys->render.prev_subpicture = NULL;
vlc_mutex_unlock(&sys->cache_lock);
return VLC_EGENERIC;
......@@ -1232,11 +1233,11 @@ static void Render(vout_display_t *vd, picture_t *picture, subpicture_t *subpict
again:
/* same as previous subpicture? */
if ((sys->render.prev_subpicture == subpicture) &&
(sys->render.i_cache != VA_INVALID_ID) &&
(sys->render.i_cache > 0) &&
(sys->render.i_start == subpicture->i_start) &&
(sys->render.i_stop == subpicture->i_stop))
{
assert(sys->render.i_cache != VA_INVALID_ID);
assert(sys->render.i_cache > 0);
if (RenderCachedSubpictures(vd, picture, subpicture) != VLC_SUCCESS)
goto again;
}
......@@ -1268,8 +1269,9 @@ static void PictureRelease(picture_t *picture)
vout_display_t *vd = (vout_display_t *)picture->p_sys->obj;
picture_sys_t *surface = picture->p_sys;
if (surface && (surface->i_cache != VA_INVALID_ID))
if (surface && (surface->i_cache > 0))
{
assert(0);
vlc_mutex_lock(&vd->sys->cache_lock);
#ifdef VAAPI_DEBUG
msg_Dbg(vd, "unlink surface %d cache %d", surface->i_id, surface->i_cache);
......@@ -1290,7 +1292,7 @@ static void PictureRelease(picture_t *picture)
vlc_mutex_unlock(&vd->sys->cache_lock);
}
surface->i_cache = VA_INVALID_ID;
surface->i_cache = 0;
}
free(picture->p_sys);
......@@ -1381,7 +1383,7 @@ static void PictureUnlock(picture_t *picture)
return;
#if 0
if (surface->i_cache != VA_INVALID_ID)
if (surface->i_cache > 0)
{
vout_display_t *vd = (vout_display_t*) picture->p_sys->obj;
vout_display_sys_t *sys = (vout_display_sys_t *) vd->sys;
......@@ -1414,7 +1416,7 @@ static void PictureUnlock(picture_t *picture)
if (surface->i_refcount > 0)
surface->i_refcount--;
surface->i_cache = VA_INVALID_ID;
surface->i_cache = 0;
}
/**
......@@ -1449,7 +1451,7 @@ static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count)
pic_sys->i_id = VA_INVALID_SURFACE;
pic_sys->i_refcount = 0;
pic_sys->i_cache = VA_INVALID_ID;
pic_sys->i_cache = 0;
pic_sys->obj = VLC_OBJECT(vd);
pic_array[count] = pic;
......
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