提交 aaa95c57 编写于 作者: R raymondzheng

ijkplayer: ijkio fix cache crash and memory leak

上级 39b583e8
......@@ -66,7 +66,7 @@ static int ijkio_open(URLContext *h, const char *arg, int flags, AVDictionary **
ret = ijkio_manager_io_open(manager_ctx, arg, flags, &opts);
ijk_av_dict_free(&opts);
if (ret < 0) {
if (ret != 0) {
ijkio_manager_io_close(manager_ctx);
}
......
......@@ -725,7 +725,7 @@ static int ijkio_cache_open(IjkURLContext *h, const char *url, int flags, IjkAVD
if (c->inner && !ret) {
c->inner->ijkio_app_ctx = c->ijkio_app_ctx;
ret = c->inner->prot->url_open2(c->inner, url, flags, options);
if (ret < 0)
if (ret != 0)
goto url_fail;
else
c->logical_size = ijkio_cache_ffurl_size(h);
......@@ -755,8 +755,11 @@ static int ijkio_cache_open(IjkURLContext *h, const char *url, int flags, IjkAVD
goto cond_wakeup_exit_fail;
}
c->task_is_running = 1;
ret = ijk_threadpool_add(c->threadpool_ctx, ijkio_cache_task, h, NULL, 0);
if (ret) {
c->task_is_running = 0;
pthread_cond_signal(&c->cond_wakeup_exit);
goto thread_fail;
}
......@@ -946,14 +949,19 @@ static int ijkio_cache_resume(IjkURLContext *h) {
if (c->inner->prot->url_resume) {
ret = c->inner->prot->url_resume(c->inner);
if (ret < 0) {
if (ret != 0) {
return ret;
}
}
c->abort_request = 0;
c->task_is_running = 1;
ret = ijk_threadpool_add(c->threadpool_ctx, ijkio_cache_task, h, NULL, 0);
if (ret) {
c->task_is_running = 0;
pthread_cond_signal(&c->cond_wakeup_exit);
}
return ret;
}
......
......@@ -152,7 +152,7 @@ int ijkio_manager_io_open(IjkIOManagerContext *h, const char *url, int flags, Ij
ijk_map_put(h->ijk_ctx_map, (int64_t)(intptr_t)h->cur_ffmpeg_ctx, inner);
}
ret = inner->prot->url_open2(inner, url, flags, options);
if (ret < 0)
if (ret != 0)
goto fail;
return ret;
......@@ -182,7 +182,7 @@ int ijkio_manager_io_read(IjkIOManagerContext *h, unsigned char *buf, int size)
if (inner->state == IJKURL_PAUSED) {
if (inner->prot->url_resume) {
ret = inner->prot->url_resume(inner);
if (ret < 0) {
if (ret != 0) {
return ret;
}
}
......@@ -228,6 +228,7 @@ int ijkio_manager_io_close(IjkIOManagerContext *h) {
ret = inner->prot->url_close(inner);
}
ijk_map_remove(h->ijk_ctx_map, (int64_t)(intptr_t)h->cur_ffmpeg_ctx);
ijk_av_freep(&inner->priv_data);
ijk_av_freep(&inner);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册