diff options
author | jbrjake <[email protected]> | 2007-07-20 15:41:22 +0000 |
---|---|---|
committer | jbrjake <[email protected]> | 2007-07-20 15:41:22 +0000 |
commit | 1b873a4f2586046a00c00bd74058e56efa0993bc (patch) | |
tree | c20804044dbb1e4a777c08e5324b8ba37f029131 | |
parent | d8ae155206156c7310d2153ba06fe1aeeccb122b (diff) |
These hopefully-innocuous changes to hb.c should help with the active queuing in the MacGui. Adds a new counter variable, h->job_count_permanent, so the task list readout ("Encoding job x of y") stays correct even if the user adds or removes items on the jobs list during an encode. Seems to work ok for me and Dynaflash, but who knows? This might need to be reverted, and/or maybe someone can come up with a less hackish way of doing it.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@719 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/hb.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/libhb/hb.c b/libhb/hb.c index f78700941..a956e957a 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -23,6 +23,7 @@ struct hb_handle_s from this one (see work.c) */ hb_list_t * jobs; int job_count; + int job_count_permanent; volatile int work_die; int work_error; hb_thread_t * work_thread; @@ -655,6 +656,8 @@ void hb_add( hb_handle_t * h, hb_job_t * job ) /* Add the job to the list */ hb_list_add( h->jobs, job_copy ); + h->job_count = hb_count(h); + h->job_count_permanent++; } /** @@ -665,6 +668,10 @@ void hb_add( hb_handle_t * h, hb_job_t * job ) void hb_rem( hb_handle_t * h, hb_job_t * job ) { hb_list_rem( h->jobs, job ); + + h->job_count = hb_count(h); + if (h->job_count_permanent) + h->job_count_permanent--; /* XXX free everything XXX */ } @@ -739,6 +746,9 @@ void hb_stop( hb_handle_t * h ) { h->work_die = 1; + h->job_count = hb_count(h); + h->job_count_permanent = 0; + hb_resume( h ); } @@ -851,6 +861,10 @@ static void thread_func( void * _h ) hb_lock( h->state_lock ); h->state.state = HB_STATE_WORKDONE; h->state.param.workdone.error = h->work_error; + + h->job_count = hb_count(h); + if (h->job_count < 1) + h->job_count_permanent = 0; hb_unlock( h->state_lock ); } @@ -902,9 +916,12 @@ void hb_set_state( hb_handle_t * h, hb_state_t * s ) if( h->state.state == HB_STATE_WORKING ) { /* XXX Hack */ + if (h->job_count < 1) + h->job_count_permanent = 1; + h->state.param.working.job_cur = - h->job_count - hb_list_count( h->jobs ); - h->state.param.working.job_count = h->job_count; + h->job_count_permanent - hb_list_count( h->jobs ); + h->state.param.working.job_count = h->job_count_permanent; } hb_unlock( h->state_lock ); hb_unlock( h->pause_lock ); |