diff options
-rw-r--r-- | gtk/src/hb-backend.c | 16 | ||||
-rw-r--r-- | gtk/src/hb-backend.h | 2 | ||||
-rw-r--r-- | gtk/src/internal_defaults.xml | 2 | ||||
-rw-r--r-- | gtk/src/subtitlehandler.c | 8 |
4 files changed, 24 insertions, 4 deletions
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 09023f69f..5d1946678 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -2195,6 +2195,7 @@ gint ghb_find_subtitle_track( gint titleindex, const gchar *lang, + gint source, GHashTable *track_indices) { hb_list_t * list; @@ -2218,6 +2219,21 @@ ghb_find_subtitle_track( used = g_malloc0(count * sizeof(gboolean)); g_hash_table_insert(track_indices, g_strdup(lang), used); } + // Try to find an item that matches the preferred language and source + for (ii = 0; ii < count; ii++) + { + if (used[ii]) + continue; + + subtitle = (hb_subtitle_t*)hb_list_item( title->list_subtitle, ii ); + if (source == subtitle->source && + ((strcmp(lang, subtitle->iso639_2) == 0) || + (strcmp(lang, "und") == 0))) + { + used[ii] = TRUE; + return ii; + } + } // Try to find an item that matches the preferred language for (ii = 0; ii < count; ii++) { diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h index 86fd2e0aa..9c1359f65 100644 --- a/gtk/src/hb-backend.h +++ b/gtk/src/hb-backend.h @@ -143,7 +143,7 @@ gint ghb_find_audio_track( void ghb_add_all_subtitles(signal_user_data_t *ud, gint titleindex); gint ghb_find_pref_subtitle_track(const gchar *lang); gint ghb_find_subtitle_track( - gint titleindex, const gchar *lang, GHashTable *track_indices); + gint titleindex, const gchar *lang, gint source, GHashTable *track_indices); gint ghb_pick_subtitle_track(signal_user_data_t *ud); gint ghb_find_cc_track(gint titleindex); gint ghb_longest_title(void); diff --git a/gtk/src/internal_defaults.xml b/gtk/src/internal_defaults.xml index 1e3d6f3e1..91025828c 100644 --- a/gtk/src/internal_defaults.xml +++ b/gtk/src/internal_defaults.xml @@ -303,6 +303,8 @@ <string>und</string> <key>SubtitleForced</key> <true /> + <key>SubtitleSource</key> + <integer>0</integer> <key>SubtitleBurned</key> <true /> <key>SubtitleDefaultTrack</key> diff --git a/gtk/src/subtitlehandler.c b/gtk/src/subtitlehandler.c index b9f015230..f26303925 100644 --- a/gtk/src/subtitlehandler.c +++ b/gtk/src/subtitlehandler.c @@ -328,16 +328,18 @@ ghb_set_pref_subtitle(gint titleindex, signal_user_data_t *ud) jj = 0; for (ii = 0; ii < count; ii++) { + gint source; + subtitle = ghb_array_get_nth(pref_subtitle, ii); lang = ghb_settings_get_string(subtitle, "SubtitleLanguage"); + source = ghb_settings_get_int(subtitle, "SubtitleSource"); // If there are multiple subtitles using the same language, then // select sequential tracks for each. The hash keeps track // of the tracks used for each language. - track = ghb_find_subtitle_track(titleindex, lang, track_indices); + track = ghb_find_subtitle_track(titleindex, lang, source, track_indices); g_free(lang); if (track >= -1) { - gint source; GValue *dup = ghb_value_dup(subtitle); lang = ghb_subtitle_track_lang(ud, track); ghb_settings_set_int(dup, "SubtitleTrack", track); @@ -364,7 +366,7 @@ ghb_set_pref_subtitle(gint titleindex, signal_user_data_t *ud) GValue *settings; gboolean burn; - track = ghb_find_subtitle_track(titleindex, pref_lang, track_indices); + track = ghb_find_subtitle_track(titleindex, pref_lang, VOBSUB, track_indices); if (track >= -1) { burn = mustBurn(ud, track); |