changeset 31787:a60157df1f1f

Update global_sub_pos if we auto-selected a subtitle. This avoid strange behaviour with subtitle selection in that case, because the subtitle selection code thinks no subtitle was displayed while we actually did display one.
author reimar
date Thu, 29 Jul 2010 17:05:23 +0000
parents e5ce8f0c0633
children 2961296ee903
files command.c
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/command.c	Thu Jul 29 17:03:14 2010 +0000
+++ b/command.c	Thu Jul 29 17:05:23 2010 +0000
@@ -98,6 +98,8 @@
            vo_dheight, vo_fs);
 }
 
+static int sub_pos_by_source(MPContext *mpctx, int src);
+
 static void update_global_sub_size(MPContext *mpctx)
 {
     int i;
@@ -110,12 +112,16 @@
     if (cnt > mpctx->sub_counts[SUB_SOURCE_DEMUX])
         mpctx->sub_counts[SUB_SOURCE_DEMUX] = cnt;
 
-    // TODO: possibly adjust global_sub_pos
-
     // update global size
     mpctx->global_sub_size = 0;
     for (i = 0; i < SUB_SOURCES; i++)
         mpctx->global_sub_size += mpctx->sub_counts[i];
+
+    // update global_sub_pos if we auto-detected a demuxer sub
+    if (mpctx->global_sub_pos == -1 &&
+        mpctx->demuxer->sub && mpctx->demuxer->sub->id >= 0)
+        mpctx->global_sub_pos = sub_pos_by_source(mpctx, SUB_SOURCE_DEMUX) +
+                                mpctx->demuxer->sub->id;
 }
 
 static int sub_pos_by_source(MPContext *mpctx, int src)