diff libmpdemux/demux_mpg.c @ 15285:39eb8a327ea9

adds a parameter to the switch_audio command to directly select a track. Patch by kiriuja mplayer-patches at en-directo net
author reimar
date Thu, 28 Apr 2005 14:43:19 +0000
parents b7aa70b05d76
children 081bee8052cf
line wrap: on
line diff
--- a/libmpdemux/demux_mpg.c	Wed Apr 27 21:59:38 2005 +0000
+++ b/libmpdemux/demux_mpg.c	Thu Apr 28 14:43:19 2005 +0000
@@ -643,6 +643,8 @@
               sh_audio_t *sh_audio = d_audio->sh;
               sh_audio_t *sh_a;
               int i;
+              if (*((int*)arg) < 0)
+              {
               for (i = 0; i < mpg_d->num_a_streams; i++) {
                 if (d_audio->id == mpg_d->a_stream_ids[i]) break;
               }
@@ -650,13 +652,22 @@
                 i = (i+1) % mpg_d->num_a_streams;
                 sh_a = (sh_audio_t*)demuxer->a_streams[mpg_d->a_stream_ids[i]];
               } while (sh_a->format != sh_audio->format);
-              if (d_audio->id != mpg_d->a_stream_ids[i]) {
+              }
+              else {
+                for (i = 0; i < mpg_d->num_a_streams; i++)
+                  if (*((int*)arg) == mpg_d->a_stream_ids[i]) break;
+                if (i < mpg_d->num_a_streams)
+                  sh_a = (sh_audio_t*)demuxer->a_streams[*((int*)arg)];
+                if (sh_a->format != sh_audio->format)
+                  i = mpg_d->num_a_streams;
+              }
+              if (i < mpg_d->num_a_streams && d_audio->id != mpg_d->a_stream_ids[i]) {
                 d_audio->id = mpg_d->a_stream_ids[i];
                 d_audio->sh = sh_a;
                 ds_free_packs(d_audio);
               }
-              *((int *)arg)=(int)d_audio->id;
             }
+            *((int*)arg) = demuxer->audio->id;
             return DEMUXER_CTRL_OK;
 
 	default: