diff options
author | Rodeo <[email protected]> | 2015-07-04 23:16:50 +0000 |
---|---|---|
committer | Rodeo <[email protected]> | 2015-07-04 23:16:50 +0000 |
commit | 7f3b6067a78298fdb39102eb0a659baac3dda259 (patch) | |
tree | 2a263d00548c408e34fc554e14b487b88bf0bfb6 /libhb | |
parent | da4f2f21d162f540570f139c2b2b60f10c258a65 (diff) |
[merge] libhb: re-work OpenCL cleanup a bit.
git-svn-id: svn://svn.handbrake.fr/HandBrake/branches/0.10.x@7344 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/hb.c | 3 | ||||
-rw-r--r-- | libhb/work.c | 21 |
2 files changed, 16 insertions, 8 deletions
diff --git a/libhb/hb.c b/libhb/hb.c index dd2aa7867..bc289dbb7 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -1744,6 +1744,9 @@ void hb_global_close() char dirname[1024]; DIR * dir; struct dirent * entry; + + /* OpenCL library (dynamically loaded) */ + hb_ocl_close(); /* Find and remove temp folder */ memset( dirname, 0, 1024 ); diff --git a/libhb/work.c b/libhb/work.c index 596912feb..c889f14ad 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -564,12 +564,23 @@ static void do_job(hb_job_t *job) job->list_work = hb_list_init(); - /* OpenCL */ + /* + * OpenCL + * + * Note: we delay hb_ocl_init until here, since they're no point it loading + * the library if we aren't going to use it. But we only call hb_ocl_close + * in hb_global_close, since un/reloading the library each run is wasteful. + */ if (job->use_opencl && (hb_ocl_init() || hb_init_opencl_run_env(0, NULL, "-I."))) { hb_log("work: failed to initialize OpenCL environment, using fallback"); + hb_release_opencl_run_env(); job->use_opencl = 0; - hb_ocl_close(); + } + else + { + // we're not (re-)using OpenCL here, we can release the environment + hb_release_opencl_run_env(); } hb_log( "starting job" ); @@ -1652,12 +1663,6 @@ cleanup: } hb_buffer_pool_free(); - - /* OpenCL: must be closed *after* freeing the buffer pool */ - if (job->use_opencl) - { - hb_ocl_close(); - } hb_job_close( &job ); } |