MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / thread_func

Function thread_func

libhb/hb.c:2250–2326  ·  view source on GitHub ↗

* Monitors the state of the update, scan, and work threads. * Sets scan done state when scan thread exits. * Sets work done state when work thread exits. * @param _h Handle to hb_handle_t */

Source from the content-addressed store, hash-verified

2248 * @param _h Handle to hb_handle_t
2249 */
2250static void thread_func( void * _h )
2251{
2252 hb_handle_t * h = (hb_handle_t *) _h;
2253 const char * dirname;
2254
2255 h->pid = getpid();
2256
2257 /* Create folder for temporary files */
2258 dirname = hb_get_temporary_directory();
2259
2260 hb_mkdir( dirname );
2261
2262 while( !h->die )
2263 {
2264 /* Check if the scan thread is done */
2265 if( h->scan_thread &&
2266 hb_thread_has_exited( h->scan_thread ) )
2267 {
2268 hb_thread_close( &h->scan_thread );
2269
2270 if ( h->scan_die )
2271 {
2272 hb_title_t * title;
2273
2274 hb_remove_previews( h );
2275 while( ( title = hb_list_item( h->title_set.list_title, 0 ) ) )
2276 {
2277 hb_list_rem( h->title_set.list_title, title );
2278 hb_title_close( &title );
2279 }
2280
2281 hb_log( "hb_scan: canceled" );
2282 }
2283 else
2284 {
2285 hb_log( "libhb: scan thread found %d valid title(s)",
2286 hb_list_count( h->title_set.list_title ) );
2287 }
2288 hb_lock( h->state_lock );
2289 h->state.state = HB_STATE_SCANDONE;
2290 hb_unlock( h->state_lock );
2291 }
2292
2293 /* Check if the work thread is done */
2294 if( h->work_thread &&
2295 hb_thread_has_exited( h->work_thread ) )
2296 {
2297 hb_thread_close( &h->work_thread );
2298
2299 hb_log( "libhb: work result = %d", h->work_error );
2300 hb_lock( h->state_lock );
2301 h->state.state = HB_STATE_WORKDONE;
2302 h->state.param.working.error = h->work_error;
2303
2304 hb_unlock( h->state_lock );
2305 }
2306
2307 if (h->paused)

Callers

nothing calls this directly

Calls 15

hb_mkdirFunction · 0.85
hb_thread_has_exitedFunction · 0.85
hb_thread_closeFunction · 0.85
hb_remove_previewsFunction · 0.85
hb_list_itemFunction · 0.85
hb_list_remFunction · 0.85
hb_title_closeFunction · 0.85
hb_logFunction · 0.85
hb_list_countFunction · 0.85
hb_lockFunction · 0.85
hb_unlockFunction · 0.85

Tested by

no test coverage detected