OSDN Git Service

LinGui: fix loading of multiple subtitles from a preset
authorjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Tue, 29 Sep 2009 19:16:03 +0000 (19:16 +0000)
committerjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Tue, 29 Sep 2009 19:16:03 +0000 (19:16 +0000)
under some circumstances the "default" and "forced" flags would end up
on the incorrect entry in the list.

git-svn-id: svn://localhost/HandBrake/trunk@2850 b64f7644-9d1e-0410-96f1-a4d463321fa5

gtk/src/hb-backend.c
gtk/src/hb-backend.h
gtk/src/internal_defaults.xml
gtk/src/subtitlehandler.c

index 09023f6..5d19466 100644 (file)
@@ -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++)
                {
index 86fd2e0..9c1359f 100644 (file)
@@ -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);
index 1e3d6f3..9102582 100644 (file)
                                <string>und</string>
                                <key>SubtitleForced</key>
                                <true />
+                               <key>SubtitleSource</key>
+                               <integer>0</integer>
                                <key>SubtitleBurned</key>
                                <true />
                                <key>SubtitleDefaultTrack</key>
index b9f0152..f263039 100644 (file)
@@ -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);