tight: Keep reference to encoder while encoding
parent
8f2d137046
commit
727b2f727e
14
src/tight.c
14
src/tight.c
|
@ -439,13 +439,19 @@ static void on_tight_zs_work_done(void* obj)
|
||||||
nvnc_fb_unref(self->fb);
|
nvnc_fb_unref(self->fb);
|
||||||
schedule_tight_finish(self);
|
schedule_tight_finish(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
encoder_unref(&self->encoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tight_schedule_zs_work(struct tight_encoder* self, int index)
|
static int tight_schedule_zs_work(struct tight_encoder* self, int index)
|
||||||
{
|
{
|
||||||
|
encoder_ref(&self->encoder);
|
||||||
|
|
||||||
int rc = aml_start(aml_get_default(), self->zs_worker[index]);
|
int rc = aml_start(aml_get_default(), self->zs_worker[index]);
|
||||||
if (rc >= 0)
|
if (rc >= 0)
|
||||||
++self->n_jobs;
|
++self->n_jobs;
|
||||||
|
else
|
||||||
|
encoder_unref(&self->encoder);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -493,7 +499,6 @@ static void tight_finish(struct tight_encoder* self)
|
||||||
|
|
||||||
static void do_tight_finish(void* obj)
|
static void do_tight_finish(void* obj)
|
||||||
{
|
{
|
||||||
// TODO: Make sure there's no use-after-free here
|
|
||||||
struct tight_encoder* self = aml_get_userdata(obj);
|
struct tight_encoder* self = aml_get_userdata(obj);
|
||||||
tight_finish(self);
|
tight_finish(self);
|
||||||
}
|
}
|
||||||
|
@ -511,14 +516,19 @@ static void on_tight_finished(void* obj)
|
||||||
|
|
||||||
self->pts = NVNC_NO_PTS;
|
self->pts = NVNC_NO_PTS;
|
||||||
rcbuf_unref(result);
|
rcbuf_unref(result);
|
||||||
|
encoder_unref(&self->encoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int schedule_tight_finish(struct tight_encoder* self)
|
static int schedule_tight_finish(struct tight_encoder* self)
|
||||||
{
|
{
|
||||||
|
encoder_ref(&self->encoder);
|
||||||
|
|
||||||
struct aml_work* work = aml_work_new(do_tight_finish, on_tight_finished,
|
struct aml_work* work = aml_work_new(do_tight_finish, on_tight_finished,
|
||||||
self, NULL);
|
self, NULL);
|
||||||
if (!work)
|
if (!work) {
|
||||||
|
encoder_unref(&self->encoder);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int rc = aml_start(aml_get_default(), work);
|
int rc = aml_start(aml_get_default(), work);
|
||||||
aml_unref(work);
|
aml_unref(work);
|
||||||
|
|
Loading…
Reference in New Issue