diff options
author | jstebbins <[email protected]> | 2009-12-15 01:28:55 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2009-12-15 01:28:55 +0000 |
commit | eecac51cfcbc412f5d2f7510a1dd4179fbb406f4 (patch) | |
tree | 995b82b3c6d0e022d6f5bca9865f0f3ce32d3a5b /libhb/reader.c | |
parent | b4487bf6de437d77ebdd2cc137f54631b22fc9c8 (diff) |
fix potential runaway buffer usage
pthread_cond_timedwait can wake early. under certain system load conditions, this
happens often. I was going ahead and adding buffers whenever it woke, regardless
of whether the condition had actually been met. so the fifo depth would
increase until memory ran out.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3030 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/reader.c')
-rw-r--r-- | libhb/reader.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libhb/reader.c b/libhb/reader.c index 6b7d4cd80..928d8696b 100644 --- a/libhb/reader.c +++ b/libhb/reader.c @@ -69,7 +69,14 @@ hb_thread_t * hb_reader_init( hb_job_t * job ) static void push_buf( const hb_reader_t *r, hb_fifo_t *fifo, hb_buffer_t *buf ) { - hb_fifo_push_wait( fifo, buf ); + while ( !*r->die ) + { + if ( hb_fifo_full_wait( fifo ) ) + { + hb_fifo_push( fifo, buf ); + break; + } + } } static int is_audio( hb_reader_t *r, int id ) |