[vlc-commits] commit: Fix render picture out-of-memory handling ( =?UTF-8?Q?R=C3=A9mi=20Denis=2DCourmont=20?=)

git at videolan.org git at videolan.org
Wed Jan 5 18:33:54 CET 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jan  5 19:32:47 2011 +0200| [8acffd0c9b4f5cd08e1ff306f204c1f2a864a583] | committer: Rémi Denis-Courmont 

Fix render picture out-of-memory handling

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8acffd0c9b4f5cd08e1ff306f204c1f2a864a583
---

 src/video_output/video_output.c |   29 ++++++++++++++++++-----------
 1 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index b8d7ced..9c1150c 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -912,6 +912,7 @@ static int ThreadDisplayRenderPicture(vout_thread_t *vout, bool is_forced)
     if (filtered &&
         (vout->p->decoder_pool != vout->p->display_pool || subpic)) {
         picture_t *render;
+
         if (vout->p->is_decoder_pool_slow)
             render = picture_NewFromFormat(&vd->source);
         else if (vout->p->decoder_pool != vout->p->display_pool)
@@ -919,17 +920,24 @@ static int ThreadDisplayRenderPicture(vout_thread_t *vout, bool is_forced)
         else
             render = picture_pool_Get(vout->p->private_pool);
 
-        if (render) {
-            picture_Copy(render, filtered);
-
-            spu_RenderSubpictures(vout->p->spu,
-                                  render, &vd->source,
-                                  subpic, &vd->source, spu_render_time);
+        if (unlikely(render == NULL)) {
+            picture_Release(filtered);
+            return VLC_EGENERIC;
         }
+
+        picture_Copy(render, filtered);
+        spu_RenderSubpictures(vout->p->spu,
+                              render, &vd->source,
+                              subpic, &vd->source, spu_render_time);
+
         if (vout->p->is_decoder_pool_slow) {
             direct = picture_pool_Get(vout->p->display_pool);
-            if (direct)
-                picture_Copy(direct, render);
+            if (unlikely(direct == NULL)) {
+                picture_Release(render);
+                picture_Release(filtered);
+                return VLC_EGENERIC;
+            }
+            picture_Copy(direct, render);
             picture_Release(render);
 
         } else {
@@ -937,13 +945,12 @@ static int ThreadDisplayRenderPicture(vout_thread_t *vout, bool is_forced)
         }
         VideoFormatCopyCropAr(&direct->format, &filtered->format);
         picture_Release(filtered);
-        filtered = NULL;
+
     } else {
         direct = filtered;
     }
 
-    if (!direct)
-        return VLC_EGENERIC;
+    assert (direct != NULL);
 
     /*
      * Take a snapshot if requested



More information about the vlc-commits mailing list