[MPlayer-dev-eng] [PATCH] GUI: fix audio/video id in gtk/menu.c

Stanislav Maslovski stanislav.maslovski at gmail.com
Tue Apr 11 10:36:54 CEST 2006


Hello,

When playing an ogg file in gmplayer I noticed that changing audio streams
from the menu was buggy. An investigation showed that in gtk/menu.c the
audio and video streams' IDs were assumed to be equal to the indexes of
the corresponding demuxer->a_streams[i] and demuxer->v_streams[i] members.
However, from reading demux_ogg.c and demux_mkv.c codes I see that those
IDs are simply continuously counted from 0. Please, correct me if I am wrong
or if there are other cases I have not noticed.

The patch is attached.

--
Stanislav
-------------- next part --------------
Index: Gui/mplayer/gtk/menu.c
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/mplayer/gtk/menu.c,v
retrieving revision 1.36
diff -u -r1.36 menu.c
--- Gui/mplayer/gtk/menu.c	15 Dec 2005 20:39:59 -0000	1.36
+++ Gui/mplayer/gtk/menu.c	11 Apr 2006 08:12:32 -0000
@@ -537,7 +537,7 @@
 
   if ( guiIntfStruct.Playing && guiIntfStruct.demuxer && guiIntfStruct.StreamType != STREAMTYPE_DVD )
    {
-    int i,c = 0;
+    int i,id,c = 0;
 
     for ( i=0;i < MAX_A_STREAMS;i++ )
      if ( ((demuxer_t *)guiIntfStruct.demuxer)->a_streams[i] ) c++;
@@ -545,12 +545,14 @@
     if ( c > 1 )
      {
       SubMenu=AddSubMenu( window1, (const char*)empty_xpm, Menu,MSGTR_MENU_AudioTrack );
+      id = 0;
       for ( i=0;i < MAX_A_STREAMS;i++ )
        if ( ((demuxer_t *)guiIntfStruct.demuxer)->a_streams[i] )
         {
          char tmp[32];
-         snprintf( tmp,32,MSGTR_MENU_Track,i );
-         AddMenuItem( window1, (const char*)empty_xpm, SubMenu,tmp,( i << 16 ) + evSetAudio );
+         snprintf( tmp,32,MSGTR_MENU_Track,id );
+         AddMenuItem( window1, (const char*)empty_xpm, SubMenu,tmp,( id << 16 ) + evSetAudio );
+         id++;
         }
      }
 
@@ -560,12 +562,14 @@
     if ( c > 1 )
      {
       SubMenu=AddSubMenu( window1, (const char*)empty_xpm, Menu,MSGTR_MENU_VideoTrack );
+      id = 0;
       for ( i=0;i < MAX_V_STREAMS;i++ )
        if ( ((demuxer_t *)guiIntfStruct.demuxer)->v_streams[i] )
         {
          char tmp[32];
-         snprintf( tmp,32,MSGTR_MENU_Track,i );
-         AddMenuItem( window1, (const char*)empty_xpm, SubMenu,tmp,( i << 16 ) + evSetVideo );
+         snprintf( tmp,32,MSGTR_MENU_Track,id );
+         AddMenuItem( window1, (const char*)empty_xpm, SubMenu,tmp,( id << 16 ) + evSetVideo );
+         id++;
         }
      }
    }


More information about the MPlayer-dev-eng mailing list