changeset 36444:45e6b96cb2e1

Make handling of query_format more robust.
author reimar
date Sun, 08 Dec 2013 18:29:09 +0000
parents 0d52d44ad7b6
children 9bda4bc47a46
files libvo/vo_vdpau.c
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_vdpau.c	Sun Dec 08 17:53:59 2013 +0000
+++ b/libvo/vo_vdpau.c	Sun Dec 08 18:29:09 2013 +0000
@@ -690,6 +690,12 @@
 #endif
     flip = flags & VOFLAG_FLIPPING;
 
+    if (IMGFMT_IS_VDPAU(image_format) && decoder == VDP_INVALID_HANDLE) {
+        mp_msg(MSGT_VO, MSGL_WARN, "[vdpau] Unexpected reinit, query_format called too often?\n");
+        // force a full reinit, otherwise we might run into issues with
+        // some implementations
+        image_format = 0;
+    }
     if (image_format == format &&
         vid_width    == width  &&
         vid_height   == height) {
@@ -1147,8 +1153,15 @@
     case IMGFMT_VDPAU_WMV3:
     case IMGFMT_VDPAU_VC1:
     case IMGFMT_VDPAU_MPEG4:
-        if (create_vdp_decoder(format, 48, 48, 2))
+        // Note: this will break the current decoder
+        // Not all implementations support safely instantiating
+        // a second decoder, so this is the "lesser evil"
+        if (create_vdp_decoder(format, 48, 48, 2)) {
+            vdp_decoder_destroy(decoder);
+            decoder = VDP_INVALID_HANDLE;
+            decoder_max_refs = -1;
             return default_flags;
+        }
     }
     return 0;
 }