changeset 31975:3602e9bfdde5

Factorize some initialisation code. This also fixes a possible invalid memory access present since r29052, reported by Dan Oscarsson.
author cehoyos
date Tue, 07 Sep 2010 22:03:29 +0000
parents 1d01a7529269
children b2dc821f16a0
files libvo/vo_vdpau.c
diffstat 1 files changed, 15 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_vdpau.c	Tue Sep 07 20:26:37 2010 +0000
+++ b/libvo/vo_vdpau.c	Tue Sep 07 22:03:29 2010 +0000
@@ -521,16 +521,12 @@
     return 0;
 }
 
-// Free everything specific to a certain video file
-static void free_video_specific(void)
+static void mark_invalid(void)
 {
     int i;
-    VdpStatus vdp_st;
 
-    if (decoder != VDP_INVALID_HANDLE)
-        vdp_decoder_destroy(decoder);
     decoder = VDP_INVALID_HANDLE;
-    decoder_max_refs = -1;
+    video_mixer = VDP_INVALID_HANDLE;
 
     for (i = 0; i < 3; i++)
         deint_surfaces[i] = VDP_INVALID_HANDLE;
@@ -540,6 +536,17 @@
             deint_mpi[i]->usage_count--;
             deint_mpi[i] = NULL;
         }
+}
+
+// Free everything specific to a certain video file
+static void free_video_specific(void)
+{
+    int i;
+    VdpStatus vdp_st;
+
+    if (decoder != VDP_INVALID_HANDLE)
+        vdp_decoder_destroy(decoder);
+    decoder_max_refs = -1;
 
     for (i = 0; i < MAX_VIDEO_SURFACES; i++) {
         if (surface_render[i].surface != VDP_INVALID_HANDLE) {
@@ -553,7 +560,7 @@
         vdp_st = vdp_video_mixer_destroy(video_mixer);
         CHECK_ST_WARNING("Error when calling vdp_video_mixer_destroy")
     }
-    video_mixer = VDP_INVALID_HANDLE;
+    mark_invalid();
 }
 
 static int create_vdp_decoder(uint32_t format, uint32_t width, uint32_t height,
@@ -603,16 +610,8 @@
 {
     int i;
 
-    decoder = VDP_INVALID_HANDLE;
     for (i = 0; i < MAX_VIDEO_SURFACES; i++)
         surface_render[i].surface = VDP_INVALID_HANDLE;
-    for (i = 0; i < 3; i++) {
-        deint_surfaces[i] = VDP_INVALID_HANDLE;
-        if (i < 2 && deint_mpi[i])
-            deint_mpi[i]->usage_count--;
-        deint_mpi[i] = NULL;
-    }
-    video_mixer     = VDP_INVALID_HANDLE;
     vdp_flip_queue  = VDP_INVALID_HANDLE;
     vdp_flip_target = VDP_INVALID_HANDLE;
     for (i = 0; i <= NUM_OUTPUT_SURFACES; i++)
@@ -623,6 +622,7 @@
     output_surface_width = output_surface_height = -1;
     eosd_render_count = 0;
     visible_buf = 0;
+    mark_invalid();
 }
 
 static int handle_preemption(void)