[MPlayer-users] [BUG] mplayer crashes when switching audio channel

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Thu Aug 31 20:18:47 CEST 2006


Hello,
On Wed, Aug 30, 2006 at 01:04:07AM +0200, Holger Reinmann wrote:
> On Wed, 30 Aug 2006 00:07:16 +0200
> Nico Sabbi <nicola_sabbi at fastwebnet.it> wrote:
> > indeed demux_mkv from svn (and only that) crashes when changing audio
> > track. (maybe release r19546 introduced this regression? )
> 
> Yes! thats it r19545 works r19546 crashes.

Please try attached patch, it works for me so far.

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpdemux/demux_mkv.c
===================================================================
--- libmpdemux/demux_mkv.c	(revision 19595)
+++ libmpdemux/demux_mkv.c	(working copy)
@@ -3713,32 +3713,21 @@
 
     case DEMUXER_CTRL_SWITCH_AUDIO:
       if (demuxer->audio && demuxer->audio->sh) {
-        int i;
-        demux_stream_t *d_audio = demuxer->audio;
-        int idx = d_audio->id - 1; // track ids are 1 based
-        mkv_track_t *otrack = mkv_d->tracks[idx];
-        mkv_track_t *track = 0;
-        if (*((int*)arg) < 0)
-        for(i = 0; i < mkv_d->last_aid; i++) {
-          if(mkv_d->audio_tracks[i] == d_audio->id) {
-            idx = mkv_d->audio_tracks[(i+1) % mkv_d->last_aid] - 1;
-            track = mkv_d->tracks[idx];
-            if(! track)
-              continue;
-            if (track->type == MATROSKA_TRACK_AUDIO) break;
-	  }
-	}
-        else {
-          track = demux_mkv_find_track_by_num (mkv_d, *((int*)arg), MATROSKA_TRACK_AUDIO);
-          if (track == NULL)
-            track = otrack;
+        sh_audio_t *sh = demuxer->a_streams[demuxer->audio->id];
+        int aid = *(int*)arg;
+        if (aid < 0)
+          aid = (sh->aid + 1) % mkv_d->last_aid;
+        if (aid != sh->aid) {
+          mkv_track_t *track = demux_mkv_find_track_by_num (mkv_d, aid, MATROSKA_TRACK_AUDIO);
+          if (track) {
+            demuxer->audio->id = track->tnum;
+            sh = demuxer->a_streams[demuxer->audio->id];
+            ds_free_packs(demuxer->audio);
+          }
         }
-        if (track != otrack) {
-          d_audio->id = track->tnum;
-          ds_free_packs(d_audio);
-        }
-      }
-      *((int*)arg) = demuxer->audio->id;
+        *(int*)arg = sh->aid;
+      } else
+        *(int*)arg = -2;
       return DEMUXER_CTRL_OK;
 
     default:


More information about the MPlayer-users mailing list