diff options
Diffstat (limited to 'gtk/src')
-rw-r--r-- | gtk/src/audiohandler.c | 203 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 120 | ||||
-rw-r--r-- | gtk/src/main.c | 8 | ||||
-rw-r--r-- | gtk/src/queuehandler.c | 42 |
4 files changed, 179 insertions, 194 deletions
diff --git a/gtk/src/audiohandler.c b/gtk/src/audiohandler.c index 3179c9359..35f982ba4 100644 --- a/gtk/src/audiohandler.c +++ b/gtk/src/audiohandler.c @@ -20,6 +20,8 @@ #include "preview.h" #include "audiohandler.h" +static void ghb_add_audio(signal_user_data_t *ud, GValue *settings); + void ghb_adjust_audio_rate_combos(signal_user_data_t *ud) { @@ -83,6 +85,7 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud) ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(384)); ghb_ui_update(ud, "AudioSamplerate", ghb_int64_value(0)); ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(0)); + acodec = HB_ACODEC_AC3; } ghb_ui_update(ud, "AudioTrackDRCSlider", ghb_double_value(0)); } @@ -221,21 +224,19 @@ ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud) acodec = 0; if (acodec != 0) { - // Add to audio list - g_signal_emit_by_name(button, "clicked", ud); - list_count++; - ghb_ui_update(ud, "AudioTrack", ghb_int64_value(track)); - ghb_ui_update(ud, "AudioEncoder", ghb_int64_value(acodec)); - if (!ghb_audio_is_passthru (acodec)) - { - // This gets set autimatically if the codec is passthru - ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(bitrate)); - ghb_ui_update(ud, "AudioSamplerate", ghb_double_value(rate)); - mix = ghb_get_best_mix( titleindex, track, acodec, mix); - ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(mix)); - } + GValue *settings = ghb_dict_value_new(); + ghb_settings_set_int(settings, "AudioTrack", track); + ghb_settings_set_int(settings, "AudioEncoder", acodec); + ghb_settings_set_value(settings, "AudioEncoderActual", + ghb_settings_get_value(ud->settings, "AudioEncoderActual")); + // This gets set autimatically if the codec is passthru + ghb_settings_set_int(settings, "AudioBitrate", bitrate); + ghb_settings_set_double(settings, "AudioSamplerate", rate); + mix = ghb_get_best_mix( titleindex, track, acodec, mix); + ghb_settings_set_int(settings, "AudioMixdown", mix); + ghb_settings_set_value(settings, "AudioTrackDRCSlider", drc); + ghb_add_audio(ud, settings); ghb_adjust_audio_rate_combos(ud); - ghb_ui_update(ud, "AudioTrackDRCSlider", drc); } } g_free(source_lang); @@ -294,7 +295,7 @@ ghb_audio_list_refresh_selected(signal_user_data_t *ud) if (gtk_tree_selection_get_selected(selection, &store, &iter)) { const gchar *track, *codec, *br, *sr, *mix; - gchar *actual_codec, *s_drc, *s_track, *s_codec, *s_br, *s_sr, *s_mix; + gchar *s_drc; gint itrack, icodec; gdouble drc; // Get the row number @@ -317,12 +318,6 @@ ghb_audio_list_refresh_selected(signal_user_data_t *ud) sr = ghb_settings_combo_option(asettings, "AudioSamplerate"); mix = ghb_settings_combo_option(asettings, "AudioMixdown"); - s_track = ghb_settings_get_string(asettings, "AudioTrack"); - s_codec = ghb_settings_get_string(asettings, "AudioEncoder"); - actual_codec = ghb_settings_get_string(asettings, "AudioEncoderActual"); - s_br = ghb_settings_get_string(asettings, "AudioBitrate"); - s_sr = ghb_settings_get_string(asettings, "AudioSamplerate"); - s_mix = ghb_settings_get_string(asettings, "AudioMixdown"); drc = ghb_settings_get_double(asettings, "AudioTrackDRCSlider"); if (drc < 1.0) s_drc = g_strdup("Off"); @@ -340,22 +335,8 @@ ghb_audio_list_refresh_selected(signal_user_data_t *ud) 3, sr, 4, mix, 5, s_drc, - // These are used to set combo values when a list item is selected - 6, s_track, - 7, s_codec, - 8, s_br, - 9, s_sr, - 10, s_mix, - 11, drc, - 12, actual_codec, -1); g_free(s_drc); - g_free(s_track); - g_free(s_codec); - g_free(actual_codec); - g_free(s_br); - g_free(s_sr); - g_free(s_mix); } } @@ -395,6 +376,7 @@ audio_codec_changed_cb(GtkWidget *widget, signal_user_data_t *ud) if (asettings != NULL) { ghb_widget_to_setting(asettings, widget); + ghb_settings_set_value(asettings, "AudioEncoderActual", ghb_settings_get_value(ud->settings, "AudioEncoderActual")); ghb_audio_list_refresh_selected(ud); } ghb_update_destination_extension(ud); @@ -482,20 +464,6 @@ drc_widget_changed_cb(GtkWidget *widget, gdouble val, signal_user_data_t *ud) ghb_live_reset(ud); } -// subtitles differ from other settings in that -// the selection is updated automaitcally when the title -// changes. I don't want the preset selection changed as -// would happen for regular settings. -G_MODULE_EXPORT void -subtitle_changed_cb(GtkWidget *widget, signal_user_data_t *ud) -{ - const gchar *name = ghb_get_setting_key(widget); - g_debug("subtitle_changed_cb () %s", name); - ghb_widget_to_setting(ud->settings, widget); - ghb_check_dependency(ud, widget, NULL); - ghb_live_reset(ud); -} - void ghb_clear_audio_list(signal_user_data_t *ud) { @@ -525,7 +493,7 @@ add_to_audio_list(signal_user_data_t *ud, GValue *settings) GtkListStore *store; GtkTreeSelection *selection; const gchar *track, *codec, *br, *sr, *mix; - gchar *s_drc, *s_track, *s_codec, *s_br, *s_sr, *s_mix, *actual_codec; + gchar *s_drc; gint icodec, itrack; gdouble drc; @@ -542,12 +510,6 @@ add_to_audio_list(signal_user_data_t *ud, GValue *settings) sr = ghb_settings_combo_option(settings, "AudioSamplerate"); mix = ghb_settings_combo_option(settings, "AudioMixdown"); - s_track = ghb_settings_get_string(settings, "AudioTrack"); - s_codec = ghb_settings_get_string(settings, "AudioEncoder"); - actual_codec = ghb_settings_get_string(settings, "AudioEncoderActual"); - s_br = ghb_settings_get_string(settings, "AudioBitrate"); - s_sr = ghb_settings_get_string(settings, "AudioSamplerate"); - s_mix = ghb_settings_get_string(settings, "AudioMixdown"); drc = ghb_settings_get_double(settings, "AudioTrackDRCSlider"); if (drc < 1.0) s_drc = g_strdup("Off"); @@ -568,23 +530,9 @@ add_to_audio_list(signal_user_data_t *ud, GValue *settings) 3, sr, 4, mix, 5, s_drc, - // These are used to set combo box values when a list item is selected - 6, s_track, - 7, s_codec, - 8, s_br, - 9, s_sr, - 10, s_mix, - 11, drc, - 12, actual_codec, -1); gtk_tree_selection_select_iter(selection, &iter); g_free(s_drc); - g_free(s_track); - g_free(s_codec); - g_free(actual_codec); - g_free(s_br); - g_free(s_sr); - g_free(s_mix); } G_MODULE_EXPORT void @@ -594,29 +542,38 @@ audio_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_t GtkTreeIter iter; GtkWidget *widget; + GtkTreePath *treepath; + gint *indices; + gint row; + GValue *asettings = NULL; + + const GValue *audio_list; g_debug("audio_list_selection_changed_cb ()"); if (gtk_tree_selection_get_selected(selection, &store, &iter)) { - const gchar *actual_codec, *track, *codec, *bitrate, *sample_rate, *mix; - gdouble drc; + //const gchar *actual_codec, *track, *codec, *bitrate, *sample_rate, *mix; + //gdouble drc; + + // Get the row number + treepath = gtk_tree_model_get_path (store, &iter); + indices = gtk_tree_path_get_indices (treepath); + row = indices[0]; + gtk_tree_path_free(treepath); + // find audio settings + if (row < 0) return; + audio_list = ghb_settings_get_value(ud->settings, "audio_list"); + if (row >= ghb_array_len(audio_list)) + return; + asettings = ghb_array_get_nth(audio_list, row); - gtk_tree_model_get(store, &iter, - 6, &track, - 7, &codec, - 8, &bitrate, - 9, &sample_rate, - 10, &mix, - 11, &drc, - 12, &actual_codec, - -1); - ghb_ui_update(ud, "AudioTrack", ghb_string_value(track)); - ghb_ui_update(ud, "AudioEncoder", ghb_string_value(codec)); - ghb_settings_set_string(ud->settings, "AudioEncoderActual", actual_codec); + ghb_ui_update(ud, "AudioTrack", ghb_settings_get_value(asettings, "AudioTrack")); + ghb_ui_update(ud, "AudioEncoder", ghb_settings_get_value(asettings, "AudioEncoder")); + ghb_settings_set_value(ud->settings, "AudioEncoderActual", ghb_settings_get_value(asettings, "AudioEncoderActual")); ghb_check_dependency(ud, NULL, "AudioEncoderActual"); - ghb_ui_update(ud, "AudioBitrate", ghb_string_value(bitrate)); - ghb_ui_update(ud, "AudioSamplerate", ghb_string_value(sample_rate)); - ghb_ui_update(ud, "AudioMixdown", ghb_string_value(mix)); - ghb_ui_update(ud, "AudioTrackDRCSlider", ghb_double_value(drc)); + ghb_ui_update(ud, "AudioBitrate", ghb_settings_get_value(asettings, "AudioBitrate")); + ghb_ui_update(ud, "AudioSamplerate", ghb_settings_get_value(asettings, "AudioSamplerate")); + ghb_ui_update(ud, "AudioMixdown", ghb_settings_get_value(asettings, "AudioMixdown")); + ghb_ui_update(ud, "AudioTrackDRCSlider", ghb_settings_get_value(asettings, "AudioTrackDRCSlider")); widget = GHB_WIDGET (ud->builder, "audio_remove"); gtk_widget_set_sensitive(widget, TRUE); } @@ -627,15 +584,39 @@ audio_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_t } } +static void +ghb_add_audio(signal_user_data_t *ud, GValue *settings) +{ + GValue *audio_list; + int count; + const gchar * track; + + track = ghb_settings_combo_option(settings, "AudioTrack"); + ghb_settings_set_string(settings, "AudioTrackDescription", track); + + audio_list = ghb_settings_get_value(ud->settings, "audio_list"); + if (audio_list == NULL) + { + audio_list = ghb_array_value_new(8); + ghb_settings_set_value(ud->settings, "audio_list", audio_list); + } + ghb_array_append(audio_list, settings); + add_to_audio_list(ud, settings); + count = ghb_array_len(audio_list); + if (count >= 99) + { + GtkWidget * widget = GHB_WIDGET(ud->builder, "audio_add"); + gtk_widget_set_sensitive(widget, FALSE); + } + ghb_update_destination_extension(ud); +} + G_MODULE_EXPORT void audio_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) { // Add the current audio settings to the list. GValue *asettings; GtkWidget *widget; - gint count; - GValue *audio_list; - const gchar *track; g_debug("audio_add_clicked_cb ()"); asettings = ghb_dict_value_new(); @@ -654,23 +635,8 @@ audio_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) ghb_settings_take_value(asettings, "AudioMixdown", ghb_widget_value(widget)); widget = GHB_WIDGET(ud->builder, "AudioTrackDRCSlider"); ghb_settings_take_value(asettings, "AudioTrackDRCSlider", ghb_widget_value(widget)); - track = ghb_settings_combo_option(asettings, "AudioTrack"); - ghb_settings_set_string(asettings, "AudioTrackDescription", track); - audio_list = ghb_settings_get_value(ud->settings, "audio_list"); - if (audio_list == NULL) - { - audio_list = ghb_array_value_new(8); - ghb_settings_set_value(ud->settings, "audio_list", audio_list); - } - ghb_array_append(audio_list, asettings); - add_to_audio_list(ud, asettings); - count = ghb_array_len(audio_list); - if (count >= 99) - { - gtk_widget_set_sensitive(xwidget, FALSE); - } - ghb_update_destination_extension(ud); + ghb_add_audio(ud, asettings); } G_MODULE_EXPORT void @@ -753,18 +719,17 @@ ghb_set_audio(signal_user_data_t *ud, GValue *settings) if (acodec_code != 0) { - // Add to audio list - g_signal_emit_by_name(button, "clicked", ud); - ghb_ui_update(ud, "AudioTrack", track); - ghb_ui_update(ud, "AudioEncoder", acodec); - if (!ghb_audio_is_passthru (acodec_code)) - { - // This gets set autimatically if the codec is passthru - ghb_ui_update(ud, "AudioBitrate", bitrate); - ghb_ui_update(ud, "AudioSamplerate", rate); - ghb_ui_update(ud, "AudioMixdown", mix); - } - ghb_ui_update(ud, "AudioTrackDRCSlider", drc); + GValue *settings = ghb_dict_value_new(); + ghb_settings_set_value(settings, "AudioTrack", track); + ghb_settings_set_value(settings, "AudioEncoder", acodec); + ghb_settings_set_value(settings, "AudioEncoderActual", + ghb_settings_get_value(ud->settings, "AudioEncoderActual")); + // This gets set autimatically if the codec is passthru + ghb_settings_set_value(settings, "AudioBitrate", bitrate); + ghb_settings_set_value(settings, "AudioSamplerate", rate); + ghb_settings_set_value(settings, "AudioMixdown", mix); + ghb_settings_set_value(settings, "AudioTrackDRCSlider", drc); + ghb_add_audio(ud, settings); ghb_adjust_audio_rate_combos(ud); } } diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 2868df372..517f105c1 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -731,23 +731,67 @@ ghb_vquality_range( } } +gint +find_combo_entry(combo_opts_t *opts, const GValue *gval) +{ + gint ii; + + if (G_VALUE_TYPE(gval) == G_TYPE_STRING) + { + gchar *str; + str = ghb_value_string(gval); + for (ii = 0; ii < opts->count; ii++) + { + if (strcmp(opts->map[ii].shortOpt, str) == 0) + { + break; + } + } + g_free(str); + return ii; + } + else if (G_VALUE_TYPE(gval) == G_TYPE_DOUBLE) + { + gdouble val; + val = ghb_value_double(gval); + for (ii = 0; ii < opts->count; ii++) + { + if (opts->map[ii].ivalue == val) + { + break; + } + } + return ii; + } + else if (G_VALUE_TYPE(gval) == G_TYPE_INT || + G_VALUE_TYPE(gval) == G_TYPE_BOOLEAN || + G_VALUE_TYPE(gval) == G_TYPE_INT64) + { + gint64 val; + val = ghb_value_int64(gval); + for (ii = 0; ii < opts->count; ii++) + { + if ((gint64)opts->map[ii].ivalue == val) + { + break; + } + } + return ii; + } + return opts->count; +} + static const gchar* lookup_generic_string(combo_opts_t *opts, const GValue *gval) { gint ii; - gchar *str; const gchar *result = ""; - str = ghb_value_string(gval); - for (ii = 0; ii < opts->count; ii++) + ii = find_combo_entry(opts, gval); + if (ii < opts->count) { - if (strcmp(opts->map[ii].shortOpt, str) == 0) - { - result = opts->map[ii].svalue; - break; - } + result = opts->map[ii].svalue; } - g_free(str); return result; } @@ -755,19 +799,13 @@ static gint lookup_generic_int(combo_opts_t *opts, const GValue *gval) { gint ii; - gchar *str; gint result = -1; - str = ghb_value_string(gval); - for (ii = 0; ii < opts->count; ii++) + ii = find_combo_entry(opts, gval); + if (ii < opts->count) { - if (strcmp(opts->map[ii].shortOpt, str) == 0) - { - result = opts->map[ii].ivalue; - break; - } + result = opts->map[ii].ivalue; } - g_free(str); return result; } @@ -775,19 +813,13 @@ static gdouble lookup_generic_double(combo_opts_t *opts, const GValue *gval) { gint ii; - gchar *str; gdouble result = -1; - str = ghb_value_string(gval); - for (ii = 0; ii < opts->count; ii++) + ii = find_combo_entry(opts, gval); + if (ii < opts->count) { - if (strcmp(opts->map[ii].shortOpt, str) == 0) - { - result = opts->map[ii].ivalue; - break; - } + result = opts->map[ii].ivalue; } - g_free(str); return result; } @@ -795,19 +827,13 @@ static const gchar* lookup_generic_option(combo_opts_t *opts, const GValue *gval) { gint ii; - gchar *str; const gchar *result = ""; - str = ghb_value_string(gval); - for (ii = 0; ii < opts->count; ii++) + ii = find_combo_entry(opts, gval); + if (ii < opts->count) { - if (strcmp(opts->map[ii].shortOpt, str) == 0) - { - result = opts->map[ii].option; - break; - } + result = opts->map[ii].option; } - g_free(str); return result; } @@ -2132,6 +2158,7 @@ ghb_find_audio_track( gint try_acodec; gint passthru_acodec; gboolean passthru; + gint channels; g_debug("find_audio_track ()\n"); if (h_scan == NULL) return -1; @@ -2149,8 +2176,6 @@ ghb_find_audio_track( { for (ii = 0; ii < count; ii++) { - gint channels; - audio = (hb_audio_config_t*)hb_list_audio_config_item( title->list_audio, ii ); passthru_acodec = (HB_ACODEC_AC3 | HB_ACODEC_DCA) & audio->in.codec; @@ -2189,6 +2214,7 @@ ghb_find_audio_track( return track; } // Try to find an item that matches the preferred language + max_chan = 0; used = get_track_used(try_acodec, track_indices, count); for (ii = 0; ii < count; ii++) { @@ -2205,13 +2231,18 @@ ghb_find_audio_track( if (passthru_used[ii]) continue; } + channels = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT( + audio->in.channel_layout); // Find a track that is not visually impaired or dirctor's commentary if ((audio->lang.type < 2) && ((strcmp(lang, audio->lang.iso639_2) == 0) || (strcmp(lang, "und") == 0))) { - track = ii; - break; + if (channels > max_chan) + { + track = ii; + max_chan = channels; + } } } if (track > -1) @@ -2221,6 +2252,7 @@ ghb_find_audio_track( } // Try to fine an item that does not match the preferred language and // matches the passthru codec type + max_chan = 0; if (passthru) { for (ii = 0; ii < count; ii++) @@ -2263,6 +2295,7 @@ ghb_find_audio_track( return track; } // Try to fine an item that does not match the preferred language + max_chan = 0; used = get_track_used(try_acodec, track_indices, count); for (ii = 0; ii < count; ii++) { @@ -2282,8 +2315,11 @@ ghb_find_audio_track( // Find a track that is not visually impaired or dirctor's commentary if (audio->lang.type < 2) { - track = ii; - break; + if (channels > max_chan) + { + track = ii; + max_chan = channels; + } } } if (track > -1) diff --git a/gtk/src/main.c b/gtk/src/main.c index 2a8e4524b..7e62d6099 100644 --- a/gtk/src/main.c +++ b/gtk/src/main.c @@ -330,13 +330,9 @@ bind_audio_tree_model (signal_user_data_t *ud) selection = gtk_tree_view_get_selection (treeview); // 12 columns in model. 6 are visible, the other 6 are for storing // values that I need - treestore = gtk_list_store_new(13, G_TYPE_STRING, G_TYPE_STRING, + treestore = gtk_list_store_new(6, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_DOUBLE, - G_TYPE_STRING); + G_TYPE_STRING, G_TYPE_STRING); gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(treestore)); cell = gtk_cell_renderer_text_new(); diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c index 7be812b70..0680a88fc 100644 --- a/gtk/src/queuehandler.c +++ b/gtk/src/queuehandler.c @@ -405,17 +405,22 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) gchar *bitrate, *samplerate, *track; const gchar *acodec, *mix; GValue *asettings; + gdouble sr; asettings = ghb_array_get_nth(audio_list, ii); acodec = ghb_settings_combo_option(asettings, "AudioEncoder"); bitrate = ghb_settings_get_string(asettings, "AudioBitrate"); + sr = ghb_settings_get_double(asettings, "AudioSamplerate"); samplerate = ghb_settings_get_string(asettings, "AudioSamplerate"); - if (strcmp("source", samplerate) == 0) + if ((int)sr == 0) { - g_free(samplerate); samplerate = g_strdup("Same As Source"); } + else + { + samplerate = g_strdup_printf("%.4g", sr); + } track = ghb_settings_get_string(asettings, "AudioTrackDescription"); mix = ghb_settings_combo_option(asettings, "AudioMixdown"); if (count == 1) @@ -520,9 +525,9 @@ audio_list_refresh(signal_user_data_t *ud) do { const gchar *track, *codec, *br, *sr, *mix; - gchar *drc, *s_track, *s_codec, *s_br, *s_sr, *s_mix; + gchar *s_drc; gint itrack, icodec; - gdouble s_drc; + gdouble drc; GValue *asettings; audio_list = ghb_settings_get_value(ud->settings, "audio_list"); @@ -538,16 +543,11 @@ audio_list_refresh(signal_user_data_t *ud) sr = ghb_settings_combo_option(asettings, "AudioSamplerate"); mix = ghb_settings_combo_option(asettings, "AudioMixdown"); - s_track = ghb_settings_get_string(asettings, "AudioTrack"); - s_codec = ghb_settings_get_string(asettings, "AudioEncoder"); - s_br = ghb_settings_get_string(asettings, "AudioBitrate"); - s_sr = ghb_settings_get_string(asettings, "AudioSamplerate"); - s_mix = ghb_settings_get_string(asettings, "AudioMixdown"); - s_drc = ghb_settings_get_double(asettings, "AudioTrackDRCSlider"); - if (s_drc < 1.0) - drc = g_strdup("Off"); + drc = ghb_settings_get_double(asettings, "AudioTrackDRCSlider"); + if (drc < 1.0) + s_drc = g_strdup("Off"); else - drc = g_strdup_printf("%.1f", s_drc); + s_drc = g_strdup_printf("%.1f", drc); if (icodec == HB_ACODEC_MASK) codec = ghb_select_audio_codec_str(ud, itrack); @@ -559,21 +559,9 @@ audio_list_refresh(signal_user_data_t *ud) 2, br, 3, sr, 4, mix, - 5, drc, - // These are used to set combo values when an item is selected - 6, s_track, - 7, s_codec, - 8, s_br, - 9, s_sr, - 10, s_mix, - 11, s_drc, + 5, s_drc, -1); - g_free(drc); - g_free(s_track); - g_free(s_codec); - g_free(s_br); - g_free(s_sr); - g_free(s_mix); + g_free(s_drc); done = !gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); row++; } while (!done); |