* @warning This can only be called when it is known that all pending
* references to the picture pool are stale, e.g. a decoder failed to
* release pictures properly when it terminated.
+ /
+ * @return the number of picture references that were freed
*/
-void picture_pool_Reset( picture_pool_t * );
+unsigned picture_pool_Reset( picture_pool_t * );
/**
* It forces the next picture_pool_Get to return a picture even if no
return NULL;
}
-void picture_pool_Reset(picture_pool_t *pool)
+unsigned picture_pool_Reset(picture_pool_t *pool)
{
+ unsigned ret = 0;
retry:
vlc_mutex_lock(&pool->lock);
assert(pool->refs > 0);
if (sys->in_use) {
vlc_mutex_unlock(&pool->lock);
picture_Release(picture);
-
+ ret++;
goto retry;
}
}
vlc_mutex_unlock(&pool->lock);
+
+ return ret;
}
void picture_pool_NonEmpty(picture_pool_t *pool)
{
ThreadFlush(vout, true, INT64_MAX);
if (vout->p->decoder_pool) {
- unsigned count;
+ unsigned count, leaks;
if (vout->p->private_pool != NULL) {
count = picture_pool_GetSize(vout->p->private_pool);
picture_pool_Delete(vout->p->private_pool);
}
- picture_pool_Reset(vout->p->decoder_pool);
+
+ leaks = picture_pool_Reset(vout->p->decoder_pool);
+ if (leaks > 0)
+ msg_Err(vout, "%u picture(s) leaked by decoder", leaks);
+
if (vout->p->private_pool != NULL) {
vout->p->private_pool = picture_pool_Reserve(vout->p->decoder_pool,
count);