changeset 26090:c585e2ad8ebf

Select audio stream in mplayer and mencoder, overriding demuxer decision.
author eugeni
date Fri, 29 Feb 2008 17:25:50 +0000
parents e2f35d90ad39
children 8732f2107b56
files mencoder.c mpcommon.c mpcommon.h mplayer.c
diffstat 4 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mencoder.c	Fri Feb 29 17:25:48 2008 +0000
+++ b/mencoder.c	Fri Feb 29 17:25:50 2008 +0000
@@ -599,6 +599,8 @@
     mp_msg(MSGT_DEMUXER, MSGL_FATAL, MSGTR_CannotOpenDemuxer);
 	mencoder_exit(1,NULL);
   }
+
+  select_audio(demuxer, audio_id, audio_lang);
  
   if (dvdsub_id < 0 && dvdsub_lang)
     dvdsub_id = demuxer_sub_track_by_lang(demuxer, dvdsub_lang);
--- a/mpcommon.c	Fri Feb 29 17:25:48 2008 +0000
+++ b/mpcommon.c	Fri Feb 29 17:25:50 2008 +0000
@@ -190,3 +190,16 @@
     tvh->functions->control(tvh->priv,TV_VBI_CONTROL_MARK_UNCHANGED,NULL);
 #endif
 }
+
+int select_audio(demuxer_t* demuxer, int audio_id, char* audio_lang)
+{
+    if (audio_id == -1 && audio_lang)
+        audio_id = demuxer_audio_track_by_lang(demuxer, audio_lang);
+    if (audio_id != -1) // -1 (automatic) is the default behaviour of demuxers
+        demuxer_switch_audio(demuxer, audio_id);
+    if (audio_id == -2) { // some demuxers don't yet know how to switch to no sound
+        demuxer->audio->id = -2;
+        demuxer->audio->sh = NULL;
+    }
+    return demuxer->audio->id;
+}
--- a/mpcommon.h	Fri Feb 29 17:25:48 2008 +0000
+++ b/mpcommon.h	Fri Feb 29 17:25:50 2008 +0000
@@ -6,5 +6,6 @@
 extern subtitle *vo_sub_last;
 void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset);
 void update_teletext(sh_video_t *sh_video, demuxer_t *demuxer, int reset);
+int select_audio(demuxer_t* demuxer, int audio_id, char* audio_lang);
 
 #endif /* MPLAYER_MPCOMMON_H */
--- a/mplayer.c	Fri Feb 29 17:25:48 2008 +0000
+++ b/mplayer.c	Fri Feb 29 17:25:50 2008 +0000
@@ -3315,6 +3315,9 @@
 mpctx->d_video=mpctx->demuxer->video;
 mpctx->d_sub=mpctx->demuxer->sub;
 
+// select audio stream
+select_audio(mpctx->demuxer, audio_id, audio_lang);
+
 // DUMP STREAMS:
 if((stream_dump_type)&&(stream_dump_type<4)){
   FILE *f;