[MPlayer-dev-eng] [PATCH] GUI: add cheap subtitle switching for non-DVD

Stanislav Maslovski stanislav.maslovski at gmail.com
Sat Apr 22 13:28:53 CEST 2006


On Sun, Apr 16, 2006 at 06:58:46PM +0200, Guillaume POIRIER wrote:
> > > This patch adds "cheap" subtitle switching for non-DVD playouts
> > > (for ex. OGG or MKV). This patch should apply okay even without my
> > > previos patches that correct audio/video switching in gtk/menu.c
> >
> > Seems good enough for me. I'll apply it unless someone disagrees.
> 
> Applied. Thanks!

Well, there was a better and simpler way of doing things:
using mp_property_do(). I have corrected the code to use this.
It makes possible switching of the subtitles without restarting
the play and works correctly for external subs too.
The patch is attached.

Similar change should be done to audio/video switching (will try to do next).

--
Stanislav
-------------- next part --------------
Index: Gui/mplayer/mw.c
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/mplayer/mw.c,v
retrieving revision 1.119
diff -u -r1.119 mw.c
--- Gui/mplayer/mw.c	16 Apr 2006 16:58:36 -0000	1.119
+++ Gui/mplayer/mw.c	22 Apr 2006 11:18:40 -0000
@@ -25,6 +25,8 @@
 #include "../libmpdemux/demuxer.h"
 #include "../libmpdemux/stheader.h"
 #include "../codec-cfg.h"
+#include "../m_option.h"
+#include "../m_property.h"
 
 #define GUI_REDRAW_WAIT 375
 
@@ -32,12 +34,6 @@
 #include "widgets.h"
 
 extern mixer_t mixer; // mixer from mplayer.c
-extern int global_sub_size;
-extern int global_sub_pos;
-extern int global_sub_indices[];
-extern int sub_source(void);
-#define SUB_SOURCE_VOBSUB 1
-#define SUB_SOURCE_DEMUX  2
 
 extern unsigned int GetTimerMS( void );
 
@@ -117,22 +113,8 @@
 	goto play;
 
    case evSetSubtitle:
-	if ( !guiIntfStruct.demuxer || global_sub_pos == iparam ) break;
-	global_sub_pos = iparam;
-	if ( global_sub_pos >= 0 )
-	 switch ( sub_source() )
-	  {
-	   case SUB_SOURCE_VOBSUB:
-		vobsub_id = global_sub_pos - global_sub_indices[SUB_SOURCE_VOBSUB];
-		goto play;
-	   case SUB_SOURCE_DEMUX:
-		vobsub_id = -1;
-		dvdsub_id = global_sub_pos - global_sub_indices[SUB_SOURCE_DEMUX];
-		goto play;
-	  }
-	vobsub_id = -1;
-	dvdsub_id = -2;
-	goto play;
+	mp_property_do("sub",M_PROPERTY_SET,&iparam); 
+	break;
 
 #ifdef HAVE_VCD
    case evSetVCDTrack:


More information about the MPlayer-dev-eng mailing list