char dirname[1024];
DIR * dir;
struct dirent * entry;
+
+ /* OpenCL library (dynamically loaded) */
+ hb_ocl_close();
/* Find and remove temp folder */
memset( dirname, 0, 1024 );
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" );
}
hb_buffer_pool_free();
-
- /* OpenCL: must be closed *after* freeing the buffer pool */
- if (job->use_opencl)
- {
- hb_ocl_close();
- }
hb_job_close( &job );
}