MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / work_func

Function work_func

libhb/work.c:107–185  ·  view source on GitHub ↗

* Iterates through job list and calls do_job for each job. * @param _work Handle work object. */

Source from the content-addressed store, hash-verified

105 * @param _work Handle work object.
106 */
107static void work_func( void * _work )
108{
109 hb_work_t * work = _work;
110 hb_job_t * job;
111
112 time_t t = time(NULL);
113 hb_log("Starting work at: %s", asctime(localtime(&t)));
114 hb_log( "%d job(s) to process", hb_list_count( work->jobs ) );
115
116 while( !*work->die && ( job = hb_list_item( work->jobs, 0 ) ) )
117 {
118 hb_handle_t * h = job->h;
119
120 hb_list_rem( work->jobs, job );
121 hb_list_t * passes = hb_list_init();
122
123 // JSON jobs get special treatment. We want to perform the title
124 // scan for the JSON job automatically. This requires that we delay
125 // filling the job struct till we have performed the title scan
126 // because the default values for the job come from the title.
127 if (job->json != NULL)
128 {
129 hb_deep_log(1, "json job:\n%s", job->json);
130
131 // Initialize state sequence_id
132 InitWorkState(job, 0, 0);
133 // Perform title scan for json job
134 hb_json_job_scan(job->h, job->json);
135
136 // Expand json string to full job struct
137 hb_job_t *new_job = hb_json_to_job(job->h, job->json);
138 if (new_job == NULL)
139 {
140 hb_job_close(&job);
141 hb_list_close(&passes);
142 *work->error = HB_ERROR_INIT;
143 *work->die = 1;
144 break;
145 }
146 new_job->h = job->h;
147 new_job->sequence_id = job->sequence_id;
148 hb_job_close(&job);
149 job = new_job;
150 }
151
152 hb_job_setup_passes(job->h, job, passes);
153 hb_job_close(&job);
154
155 int pass_count, pass;
156 pass_count = hb_list_count(passes);
157 for (pass = 0; pass < pass_count && !*work->die; pass++)
158 {
159 job = hb_list_item(passes, pass);
160 job->die = work->die;
161 job->done_error = work->error;
162 *(work->current_job) = job;
163 InitWorkState(job, pass + 1, pass_count);
164 do_job( job );

Callers

nothing calls this directly

Calls 15

hb_logFunction · 0.85
hb_list_countFunction · 0.85
hb_list_itemFunction · 0.85
hb_list_remFunction · 0.85
hb_list_initFunction · 0.85
hb_deep_logFunction · 0.85
InitWorkStateFunction · 0.85
hb_json_job_scanFunction · 0.85
hb_json_to_jobFunction · 0.85
hb_job_closeFunction · 0.85
hb_list_closeFunction · 0.85
hb_job_setup_passesFunction · 0.85

Tested by

no test coverage detected