diff options
author | John Stebbins <[email protected]> | 2015-11-03 09:46:28 -0800 |
---|---|---|
committer | John Stebbins <[email protected]> | 2015-11-09 11:06:59 -0800 |
commit | a986f54a4109bb8c3b2fb57849b4b0ea01e3c522 (patch) | |
tree | 7add9d007dc8bdd72114637c8f3f7361621ad4a5 /gtk | |
parent | 63b340ebc33d57aeda22e340dab48b1df2106541 (diff) |
libhb: make muxer, sync, and reader behave like other work objects
simplify job initialization sequence, clean up code, and document
dependencies in the sequence better.
Make hb_add set job->sequence_id. It is no longer necessary for the
frontend to do this. If the frontend needs the sequence_id, it is
returned by hb_add().
Clean up use of interjob. do_job() now uses sequence_id to detect when
a new sequence of related jobs is running and automatically clears
interjob.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/src/callbacks.c | 7 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 17 | ||||
-rw-r--r-- | gtk/src/hb-backend.h | 2 | ||||
-rw-r--r-- | gtk/src/preview.c | 3 |
4 files changed, 13 insertions, 16 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 897a64985..003bb23a9 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -2946,7 +2946,6 @@ start_new_log(signal_user_data_t *ud, GhbValue *js) static void submit_job(signal_user_data_t *ud, GhbValue *settings) { - static gint unique_id = 1; gchar *type, *modified; const char *name; GhbValue *js; @@ -2960,10 +2959,10 @@ submit_job(signal_user_data_t *ud, GhbValue *settings) modified = preset_modified ? "Modified " : ""; ghb_log("%s%sPreset: %s", modified, type, name); - ghb_dict_set_int(settings, "job_unique_id", unique_id); ghb_dict_set_int(settings, "job_status", GHB_QUEUE_RUNNING); start_new_log(ud, settings); - ghb_add_job(ghb_queue_handle(), settings, unique_id); + int unique_id = ghb_add_job(ghb_queue_handle(), settings); + ghb_dict_set_int(settings, "job_unique_id", unique_id); ghb_start_queue(); // Start queue activity spinner @@ -2983,8 +2982,6 @@ submit_job(signal_user_data_t *ud, GhbValue *settings) } g_free(path); } - - unique_id++; } static void diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 88e7a89a1..d6e16d537 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -3375,7 +3375,7 @@ update_status(hb_state_t *state, ghb_instance_status_t *status) status->hours = p.hours; status->minutes = p.minutes; status->seconds = p.seconds; - status->unique_id = p.sequence_id & 0xFFFFFF; + status->unique_id = p.sequence_id; } else { @@ -3395,7 +3395,7 @@ update_status(hb_state_t *state, ghb_instance_status_t *status) status->hours = p.hours; status->minutes = p.minutes; status->seconds = p.seconds; - status->unique_id = p.sequence_id & 0xFFFFFF; + status->unique_id = p.sequence_id; } else { @@ -4316,18 +4316,19 @@ ghb_validate_audio(GhbValue *settings, GtkWindow *parent) return TRUE; } -void -ghb_add_job(hb_handle_t *h, GhbValue *js, gint unique_id) +int +ghb_add_job(hb_handle_t *h, GhbValue *js) { GhbValue *job; char *json_job; + int sequence_id; job = ghb_dict_get(js, "Job"); - ghb_dict_set_int(job, "SequenceID", unique_id); json_job = hb_value_get_json(job); - - hb_add_json(h, json_job); + sequence_id = hb_add_json(h, json_job); free(json_job); + + return sequence_id; } void @@ -4342,7 +4343,7 @@ ghb_remove_job(gint unique_id) ii = hb_count(h_queue) - 1; while ((job = hb_job(h_queue, ii--)) != NULL) { - if ((job->sequence_id & 0xFFFFFF) == unique_id) + if (job->sequence_id == unique_id) hb_rem(h_queue, job); } } diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h index 4f2ea310f..b743865cf 100644 --- a/gtk/src/hb-backend.h +++ b/gtk/src/hb-backend.h @@ -91,7 +91,7 @@ void ghb_combo_init(signal_user_data_t *ud); void ghb_backend_init(gint debug); void ghb_log_level_set(int level); void ghb_backend_close(void); -void ghb_add_job(hb_handle_t *h, GhbValue *js, gint unique_id); +int ghb_add_job(hb_handle_t *h, GhbValue *js); void ghb_remove_job(gint unique_id); void ghb_start_queue(void); void ghb_stop_queue(void); diff --git a/gtk/src/preview.c b/gtk/src/preview.c index e567b7af0..e3336b076 100644 --- a/gtk/src/preview.c +++ b/gtk/src/preview.c @@ -799,8 +799,7 @@ live_preview_start_cb(GtkWidget *xwidget, signal_user_data_t *ud) ghb_dict_set_int(range, "SeekPoints", ghb_dict_get_int(ud->prefs, "preview_count")); - ud->preview->live_id = 0; - ghb_add_job(ghb_live_handle(), js, ud->preview->live_id); + ud->preview->live_id = ghb_add_job(ghb_live_handle(), js); ghb_start_live_encode(); ghb_value_free(&js); } |