* Performs the filter object's specific work function. * Loops calling work function for associated filter object. * Sleeps when fifo is full. * Monitors work done indicator. * Exits loop when work indicator is set. * @param _w Handle to work object. */
| 2353 | * @param _w Handle to work object. |
| 2354 | */ |
| 2355 | static void filter_loop( void * _f ) |
| 2356 | { |
| 2357 | hb_filter_object_t * f = _f; |
| 2358 | hb_buffer_t * buf_in, * buf_out = NULL; |
| 2359 | |
| 2360 | while( !*f->done && f->status != HB_FILTER_DONE ) |
| 2361 | { |
| 2362 | buf_in = hb_fifo_get_wait( f->fifo_in ); |
| 2363 | if ( buf_in == NULL ) |
| 2364 | continue; |
| 2365 | |
| 2366 | // Filters can drop buffers. Remember chapter information |
| 2367 | // so that it can be propagated to the next buffer |
| 2368 | if ( buf_in->s.new_chap ) |
| 2369 | { |
| 2370 | f->chapter_time = buf_in->s.start; |
| 2371 | f->chapter_val = buf_in->s.new_chap; |
| 2372 | // don't let 'filter_loop' put a chapter mark on the wrong buffer |
| 2373 | buf_in->s.new_chap = 0; |
| 2374 | } |
| 2375 | if ( *f->done ) |
| 2376 | { |
| 2377 | if( buf_in ) |
| 2378 | { |
| 2379 | hb_buffer_close( &buf_in ); |
| 2380 | } |
| 2381 | break; |
| 2382 | } |
| 2383 | |
| 2384 | buf_out = NULL; |
| 2385 | |
| 2386 | f->status = f->work( f, &buf_in, &buf_out ); |
| 2387 | |
| 2388 | if ( buf_out && f->chapter_val && f->chapter_time <= buf_out->s.start ) |
| 2389 | { |
| 2390 | buf_out->s.new_chap = f->chapter_val; |
| 2391 | f->chapter_val = 0; |
| 2392 | } |
| 2393 | |
| 2394 | if( buf_in ) |
| 2395 | { |
| 2396 | hb_buffer_close( &buf_in ); |
| 2397 | } |
| 2398 | if ( buf_out && f->fifo_out == NULL ) |
| 2399 | { |
| 2400 | hb_buffer_close( &buf_out ); |
| 2401 | } |
| 2402 | if( buf_out ) |
| 2403 | { |
| 2404 | while ( !*f->done ) |
| 2405 | { |
| 2406 | if ( hb_fifo_full_wait( f->fifo_out ) ) |
| 2407 | { |
| 2408 | hb_fifo_push( f->fifo_out, buf_out ); |
| 2409 | buf_out = NULL; |
| 2410 | break; |
| 2411 | } |
| 2412 | } |
nothing calls this directly
no test coverage detected