Commit 2ea9a981 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

vdpau/chroma: fix corner case of corner case when changing device

To ensure the vdp_t instance pointers comparison is valid, the old and
new instances must be contemporary. Otherwise, the heap could put both
instances at the same memory address. So keep a reference to the old
device until after the comparison.
parent 17dd86ef
...@@ -289,20 +289,19 @@ static picture_t *OutputAllocate(filter_t *filter) ...@@ -289,20 +289,19 @@ static picture_t *OutputAllocate(filter_t *filter)
picture_sys_t *psys = pic->p_sys; picture_sys_t *psys = pic->p_sys;
assert(psys->vdp != NULL); assert(psys->vdp != NULL);
if (unlikely(sys->vdp != psys->vdp))
if (unlikely(sys->vdp != psys->vdp) && (sys->mixer != VDP_INVALID_HANDLE))
{ {
if (sys->mixer != VDP_INVALID_HANDLE) Flush(filter); /* release surfaces from the old device */
{ vdp_video_mixer_destroy(sys->vdp, sys->mixer);
Flush(filter); vdp_release_x11(sys->vdp);
vdp_video_mixer_destroy(sys->vdp, sys->mixer); sys->mixer = VDP_INVALID_HANDLE;
sys->mixer = VDP_INVALID_HANDLE;
}
sys->vdp = psys->vdp;
sys->device = psys->device;
} }
if (unlikely(sys->mixer == VDP_INVALID_HANDLE)) if (unlikely(sys->mixer == VDP_INVALID_HANDLE))
{ {
sys->vdp = vdp_hold_x11(psys->vdp, NULL);
sys->device = psys->device;
sys->mixer = MixerCreate(filter); sys->mixer = MixerCreate(filter);
if (sys->mixer == VDP_INVALID_HANDLE) if (sys->mixer == VDP_INVALID_HANDLE)
goto error; goto error;
...@@ -659,8 +658,10 @@ static void OutputClose(vlc_object_t *obj) ...@@ -659,8 +658,10 @@ static void OutputClose(vlc_object_t *obj)
Flush(filter); Flush(filter);
if (sys->mixer != VDP_INVALID_HANDLE) if (sys->mixer != VDP_INVALID_HANDLE)
{
vdp_video_mixer_destroy(sys->vdp, sys->mixer); vdp_video_mixer_destroy(sys->vdp, sys->mixer);
vdp_release_x11(sys->vdp);
}
free(sys); free(sys);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment