summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-04-14 20:49:14 +0200
committerwm4 <wm4@nowhere>2014-04-14 20:51:27 +0200
commite1f1b0c275401c96c5ce776d74aff144359e6495 (patch)
treea0ddfa3d1c428b0e891eb50128b297233c79b06b /video
parent059d989bf6c9689cf13cbf3ba069210bf715814d (diff)
downloadmpv-e1f1b0c275401c96c5ce776d74aff144359e6495.tar.bz2
mpv-e1f1b0c275401c96c5ce776d74aff144359e6495.tar.xz
vf_vapoursynth: handle destruction more gracefully
We were relying on vsscript_freeScript() to take care of proper termination. But it doesn't do that: it doesn't wait for the filters to finish and exit at all. Instead, it just destroys all objects, which causes the worker threads to crash sometimes. Also, we're supposed to wait for the frame callback to finish before freeing the associated node. Handle this by explicitly waiting as far as we can. Probably fixes crashes on seeking, although VapourSynth itself might also need some work to make this case completely stable.
Diffstat (limited to 'video')
-rw-r--r--video/filter/vf_vapoursynth.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/video/filter/vf_vapoursynth.c b/video/filter/vf_vapoursynth.c
index bb3faed28a..4acea8e056 100644
--- a/video/filter/vf_vapoursynth.c
+++ b/video/filter/vf_vapoursynth.c
@@ -307,18 +307,20 @@ static void destroy_vs(struct vf_instance *vf)
{
struct vf_priv_s *p = vf->priv;
+ // Wait until our frame callback returns.
+ pthread_mutex_lock(&p->lock);
+ p->shutdown = true;
+ pthread_cond_broadcast(&p->wakeup);
+ while (p->getting_frame)
+ pthread_cond_wait(&p->wakeup, &p->lock);
+ pthread_mutex_unlock(&p->lock);
+
if (p->in_node)
p->vsapi->freeNode(p->in_node);
if (p->out_node)
p->vsapi->freeNode(p->out_node);
p->in_node = p->out_node = NULL;
- pthread_mutex_lock(&p->lock);
- p->shutdown = true;
- pthread_cond_broadcast(&p->wakeup);
- pthread_mutex_unlock(&p->lock);
-
- // Expect that this properly waits until all filters return etc.
if (p->se)
vsscript_freeScript(p->se);
@@ -326,7 +328,6 @@ static void destroy_vs(struct vf_instance *vf)
p->vsapi = NULL;
p->vscore = NULL;
- assert(!p->getting_frame);
assert(!p->in_node_active);
p->shutdown = false;