X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=libhb%2Ffifo.c;h=3aeeea2734cbcc7598de8464710d2d3afca3e4ff;hb=4f0019f03c2e85e8634150ff0c9a31bee6d35ce5;hp=781c9400b93c72ffea1342f473587ec226083a4b;hpb=a7f8bd6842d316d2a19cf63355b1d343a244b42d;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/libhb/fifo.c b/libhb/fifo.c index 781c9400..3aeeea27 100644 --- a/libhb/fifo.c +++ b/libhb/fifo.c @@ -235,6 +235,23 @@ hb_fifo_t * hb_fifo_init( int capacity, int thresh ) return f; } +int hb_fifo_size_bytes( hb_fifo_t * f ) +{ + int ret = 0; + hb_buffer_t * link; + + hb_lock( f->lock ); + link = f->first; + while ( link ) + { + ret += link->size; + link = link->next; + } + hb_unlock( f->lock ); + + return ret; +} + int hb_fifo_size( hb_fifo_t * f ) { int ret; @@ -374,6 +391,21 @@ hb_buffer_t * hb_fifo_see2( hb_fifo_t * f ) return b; } +int hb_fifo_full_wait( hb_fifo_t * f ) +{ + int result; + + hb_lock( f->lock ); + if( f->size >= f->capacity ) + { + f->wait_full = 1; + hb_cond_timedwait( f->cond_full, f->lock, FIFO_TIMEOUT ); + } + result = ( f->size < f->capacity ); + hb_unlock( f->lock ); + return result; +} + void hb_fifo_push_wait( hb_fifo_t * f, hb_buffer_t * b ) { if( !b )