summaryrefslogtreecommitdiffstats
path: root/libhb/work.c
diff options
context:
space:
mode:
authorsr55 <[email protected]>2013-02-04 19:44:40 +0000
committersr55 <[email protected]>2013-02-04 19:44:40 +0000
commit4ea1e568a7ad2e8ae4068d76e00f30dd77e280bd (patch)
tree68346349bc30a460a601df550235dad3c0d7674f /libhb/work.c
parenta735c9046533954e1bba5cf8996d98e15b2e86cc (diff)
Prevent OSX ML sleep during encoding, thanks to Jerome Lacube
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5238 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/work.c')
-rw-r--r--libhb/work.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/libhb/work.c b/libhb/work.c
index 19389bf11..9ee2b0593 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -13,9 +13,10 @@
typedef struct
{
- hb_list_t * jobs;
- hb_job_t ** current_job;
- int * error;
+ hb_handle_t * handle;
+ hb_list_t * jobs;
+ hb_job_t ** current_job;
+ int * error;
volatile int * die;
} hb_work_t;
@@ -40,14 +41,15 @@ static void filter_loop( void * );
* @param die Handle to user inititated exit indicator.
* @param error Handle to error indicator.
*/
-hb_thread_t * hb_work_init( hb_list_t * jobs, volatile int * die, int * error, hb_job_t ** job )
+hb_thread_t * hb_work_init( hb_handle_t * handle, hb_list_t * jobs, volatile int * die, int * error, hb_job_t ** job )
{
hb_work_t * work = calloc( sizeof( hb_work_t ), 1 );
- work->jobs = jobs;
+ work->handle = handle;
+ work->jobs = jobs;
work->current_job = job;
- work->die = die;
- work->error = error;
+ work->die = die;
+ work->error = error;
return hb_thread_init( "work", work_func, work, HB_LOW_PRIORITY );
}
@@ -81,16 +83,22 @@ static void work_func( void * _work )
hb_log( "%d job(s) to process", hb_list_count( work->jobs ) );
+ hb_prevent_sleep( work->handle );
+
while( !*work->die && ( job = hb_list_item( work->jobs, 0 ) ) )
{
hb_list_rem( work->jobs, job );
job->die = work->die;
*(work->current_job) = job;
+
InitWorkState( job->h );
do_job( job );
+
*(work->current_job) = NULL;
}
+ hb_allow_sleep( work->handle );
+
*(work->error) = HB_ERROR_NONE;
free( work );