# HG changeset patch # User ib # Date 1408298816 0 # Node ID d4fbf2eb4a04e4b33c058367fdbc3b2b60f32505 # Parent 08bbd1e9036d7a00faa9fe29d5039867d405fbd1 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. diff -r 08bbd1e9036d -r d4fbf2eb4a04 access_mpcontext.h --- a/access_mpcontext.h Fri Aug 15 22:27:52 2014 +0000 +++ b/access_mpcontext.h Sun Aug 17 18:06:56 2014 +0000 @@ -25,8 +25,7 @@ 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); diff -r 08bbd1e9036d -r d4fbf2eb4a04 gui/dialog/menu.c --- a/gui/dialog/menu.c Fri Aug 15 22:27:52 2014 +0000 +++ b/gui/dialog/menu.c Sun Aug 17 18:06:56 2014 +0000 @@ -462,7 +462,7 @@ 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 @@ } /* 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 @@ } 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 ); } } diff -r 08bbd1e9036d -r d4fbf2eb4a04 mplayer.c --- a/mplayer.c Fri Aug 15 22:27:52 2014 +0000 +++ b/mplayer.c Sun Aug 17 18:06:56 2014 +0000 @@ -360,14 +360,11 @@ 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; -} - -int mpctx_get_global_sub_pos(MPContext *mpctx) -{ - return mpctx->global_sub_pos; + mp_property_do("sub", M_PROPERTY_GET, pos, mpctx); + + if (size) *size = mpctx->global_sub_size; } int mpctx_get_osd_function(MPContext *mpctx)