From 22465e56cc97476636edd72c7d23f0c5cc692277 Mon Sep 17 00:00:00 2001 From: eugeni Date: Fri, 29 Feb 2008 17:25:50 +0000 Subject: [PATCH] Select audio stream in mplayer and mencoder, overriding demuxer decision. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26122 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mencoder.c | 2 ++ mpcommon.c | 13 +++++++++++++ mpcommon.h | 1 + mplayer.c | 3 +++ 4 files changed, 19 insertions(+) diff --git a/mencoder.c b/mencoder.c index 5feb694936..dbd6f61e06 100644 --- a/mencoder.c +++ b/mencoder.c @@ -599,6 +599,8 @@ if(stream->type==STREAMTYPE_DVDNAV){ 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); diff --git a/mpcommon.c b/mpcommon.c index b9e9296d2a..332d8e1cf4 100644 --- a/mpcommon.c +++ b/mpcommon.c @@ -190,3 +190,16 @@ void update_teletext(sh_video_t *sh_video, demuxer_t *demuxer, int reset) 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; +} diff --git a/mpcommon.h b/mpcommon.h index 757f3216df..fbffeec386 100644 --- a/mpcommon.h +++ b/mpcommon.h @@ -6,5 +6,6 @@ extern struct ass_track_s *ass_track; 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 */ diff --git a/mplayer.c b/mplayer.c index 35943e3117..54f791c740 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3315,6 +3315,9 @@ mpctx->d_audio=mpctx->demuxer->audio; 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;