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