[MPlayer-dev-eng] bug in demux_mkv

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sun Jul 15 10:11:04 CEST 2007


Hello,
On Sun, Jul 15, 2007 at 10:02:52AM +0200, Reimar D?ffinger wrote:
> On Sat, Jul 14, 2007 at 02:26:56PM -0700, Sean D'Epagnier wrote:
> > On Sat, Jul 14, 2007 at 11:12:37PM +0200, Aurelien Jacobs wrote:
> > > 
> > > Could you please make the sample file available somewhere ?
> > > 
> > 
> > http://people.freedesktop.org/~geckosenator/test.mkv
> > 
> > The file was huge so I cut out just the start of it.  This should
> > be enough to see it crash, but not crash with -aid 0.
> 
> MPlayer SVN autodetects it just fine, it only crashes if you specify a
> stream that does not exist, like -aid 1 or -aid 99.
> The problem is that track is check for != NULL right after being used
> instead of before.
> IMO if no matching track is found, demuxer->audio->id should be set to
> -2.
> Is attached patch okay (it also remove the useless track == NULL check
> in the loop I mentioned above).
> I'll have another look, the video selection code might have the same
> issue.

That one does it correctly. Attached patch fixes it in a way that makes
the more similar, making it easier to factor out the common code some
day.
Probably the two ifs around that for loop should be removed as well,
that would allow to start with -nosound and later enable sound via the
audio stream switching.

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpdemux/demux_mkv.c
===================================================================
--- libmpdemux/demux_mkv.c	(revision 23784)
+++ libmpdemux/demux_mkv.c	(working copy)
@@ -2520,6 +2520,11 @@
   else if (demuxer->audio->id != -2)  /* -2 = no audio at all */
     track = demux_mkv_find_track_by_num (mkv_d, demuxer->audio->id,
                                          MATROSKA_TRACK_AUDIO);
+  if (track && demuxer->a_streams[track->tnum])
+    {
+      demuxer->audio->id = track->tnum;
+      demuxer->audio->sh = demuxer->a_streams[track->tnum];
+    }
   else
     {
       mp_msg (MSGT_DEMUX, MSGL_INFO, MSGTR_MPDEMUX_MKV_NoAudioTrackFound);
@@ -2534,11 +2539,6 @@
           continue;
       if(demuxer->a_streams[track->tnum])
         {
-          if(track && mkv_d->tracks[i] == track)
-            {
-              demuxer->audio->id = track->tnum;
-              demuxer->audio->sh = demuxer->a_streams[track->tnum];
-            }
           mkv_d->last_aid++;
           if(mkv_d->last_aid == MAX_A_STREAMS)
             break;


More information about the MPlayer-dev-eng mailing list