]> git.sesse.net Git - vlc/commitdiff
vout: print error if the decoder leaked pictures
authorRémi Denis-Courmont <remi@remlab.net>
Wed, 29 Oct 2014 14:46:02 +0000 (16:46 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Sat, 1 Nov 2014 12:40:46 +0000 (14:40 +0200)
include/vlc_picture_pool.h
src/misc/picture_pool.c
src/video_output/video_output.c

index 4b520e1bbfa905f74dd4c086ff8ca60ead8fc939..7d373240c1a75d66ad876a4978ed433bb4b5172c 100644 (file)
@@ -101,8 +101,10 @@ VLC_API picture_t * picture_pool_Get( picture_pool_t * ) VLC_USED;
  * @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
index 135b5d6d90f3dd7900cfd4fea911fef2397e8a36..ce25461d48da5a7e781e1d1bfc7b84026e1386e1 100644 (file)
@@ -274,8 +274,9 @@ picture_t *picture_pool_Get(picture_pool_t *pool)
     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);
@@ -287,11 +288,13 @@ retry:
         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)
index 66625b6c5ae32b1b8ca5edeab23178b9a52edb27..411b66f8ac244637070a226dc7a825972a2e62cb 100644 (file)
@@ -1181,13 +1181,17 @@ static void ThreadReset(vout_thread_t *vout)
 {
     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);