[MPlayer-cvslog] r37255 - in trunk: access_mpcontext.h gui/dialog/menu.c mplayer.c

ib subversion at mplayerhq.hu
Sun Aug 17 20:06:56 CEST 2014


Author: ib
Date: Sun Aug 17 20:06:56 2014
New Revision: 37255

Log:
Ensure up-to-dateness of global_sub information upon request.

Some demuxers (like mpg) can detect subtitles only while playing,
which is the reason why MPlayer always - indirectly - calls
update_global_sub_size() prior to dealing with subtitles.

Functions mpctx_get_global_sub_size() and mpctx_get_global_sub_pos(),
however, merely return last determined values, thus missing information
that may have been arisen after MPlayer has checked last for subtitles
(when playback started).

Merge the two mpctx_get_global_sub_*() functions into one for easier
handling.

Retrieve global_sub pos by a mp_property_do("sub") command which
performs the necessary update of both global_sub variables, pos and
size.

Reported by Lode Leroy, lode.leroy gmail com.

Modified:
   trunk/access_mpcontext.h
   trunk/gui/dialog/menu.c
   trunk/mplayer.c

Modified: trunk/access_mpcontext.h
==============================================================================
--- trunk/access_mpcontext.h	Sat Aug 16 00:27:52 2014	(r37254)
+++ trunk/access_mpcontext.h	Sun Aug 17 20:06:56 2014	(r37255)
@@ -25,8 +25,7 @@ const void *mpctx_get_audio_out(struct M
 void *mpctx_get_demuxer(struct MPContext *mpctx);
 void *mpctx_get_playtree_iter(struct MPContext *mpctx);
 void *mpctx_get_mixer(struct MPContext *mpctx);
-int mpctx_get_global_sub_size(struct MPContext *mpctx);
-int mpctx_get_global_sub_pos(struct MPContext *mpctx);
+void mpctx_get_global_sub_info(struct MPContext *mpctx, int *size, int *pos);
 int mpctx_get_osd_function(struct MPContext *mpctx);
 void *mpctx_get_stream(struct MPContext *mpctx);
 void *mpctx_get_afilter(struct MPContext *mpctx);

Modified: trunk/gui/dialog/menu.c
==============================================================================
--- trunk/gui/dialog/menu.c	Sat Aug 16 00:27:52 2014	(r37254)
+++ trunk/gui/dialog/menu.c	Sun Aug 17 20:06:56 2014	(r37255)
@@ -462,7 +462,7 @@ GtkWidget * CreatePopUpMenu( void )
  GtkWidget * H, * N, * D, * F;
  demuxer_t *demuxer = mpctx_get_demuxer(guiInfo.mpcontext);
  mixer_t *mixer = mpctx_get_mixer(guiInfo.mpcontext);
- int global_sub_size = mpctx_get_global_sub_size(guiInfo.mpcontext);
+ int subs = 0, sub_pos;
 
  Menu=gtk_menu_new();
  gtk_widget_realize (Menu);
@@ -733,13 +733,15 @@ GtkWidget * CreatePopUpMenu( void )
    }
 
   /* cheap subtitle switching for non-DVD streams */
-  if ( global_sub_size && guiInfo.StreamType != STREAMTYPE_DVD )
+
+  mpctx_get_global_sub_info(guiInfo.mpcontext, &subs, &sub_pos);
+
+  if ( subs && guiInfo.StreamType != STREAMTYPE_DVD )
    {
-    int pos, i, j, subs0 = guiInfo.mpcontext->sub_counts[SUB_SOURCE_SUBS], subs1 = guiInfo.mpcontext->sub_counts[SUB_SOURCE_VOBSUB];
-    pos = mpctx_get_global_sub_pos(guiInfo.mpcontext);
+    int i, j, subs0 = guiInfo.mpcontext->sub_counts[SUB_SOURCE_SUBS], subs1 = guiInfo.mpcontext->sub_counts[SUB_SOURCE_VOBSUB];
     SubMenu=AddSubMenu( window1, (const char*)subtitle_xpm, Menu, MSGTR_GUI_Subtitles );
-    AddMenuCheckItem( window1, (const char*)empty1px_xpm, SubMenu, MSGTR_GUI__none_, pos == -1, (-1 << 16) + ivSetSubtitle );
-    for ( i=0;i < global_sub_size;i++ )
+    AddMenuCheckItem( window1, (const char*)empty1px_xpm, SubMenu, MSGTR_GUI__none_, sub_pos == -1, (-1 << 16) + ivSetSubtitle );
+    for ( i=0;i < subs;i++ )
      {
       int ret = -1;
       char lng[32], tmp[64], *lang = NULL;
@@ -782,7 +784,7 @@ GtkWidget * CreatePopUpMenu( void )
        }
       if ( ret == 0 ) snprintf( tmp, sizeof(tmp), MSGTR_GUI_TrackN" - %s", i, GetLanguage( lng, GET_LANG_CHR ) );
       else snprintf( tmp, sizeof(tmp), MSGTR_GUI_TrackN, i );
-      AddMenuCheckItem( window1,(const char*)empty1px_xpm,SubMenu,tmp,pos == i,( i << 16 ) + ivSetSubtitle );
+      AddMenuCheckItem( window1,(const char*)empty1px_xpm,SubMenu,tmp,sub_pos == i,( i << 16 ) + ivSetSubtitle );
      }
    }
 

Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c	Sat Aug 16 00:27:52 2014	(r37254)
+++ trunk/mplayer.c	Sun Aug 17 20:06:56 2014	(r37255)
@@ -360,14 +360,11 @@ void *mpctx_get_mixer(MPContext *mpctx)
     return &mpctx->mixer;
 }
 
-int mpctx_get_global_sub_size(MPContext *mpctx)
+void mpctx_get_global_sub_info(MPContext *mpctx, int *size, int *pos)
 {
-    return mpctx->global_sub_size;
-}
+    mp_property_do("sub", M_PROPERTY_GET, pos, mpctx);
 
-int mpctx_get_global_sub_pos(MPContext *mpctx)
-{
-    return mpctx->global_sub_pos;
+    if (size) *size = mpctx->global_sub_size;
 }
 
 int mpctx_get_osd_function(MPContext *mpctx)


More information about the MPlayer-cvslog mailing list