From d9beced7e677d7c394bb9d30f3f2803309ba04c6 Mon Sep 17 00:00:00 2001 From: mosu Date: Fri, 23 May 2003 15:01:25 +0000 Subject: Support for selecting the audio track in Matroska files via -alang. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10168 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpdemux/demux_mkv.cpp | 21 ++++++++++++++------- mencoder.c | 2 +- mplayer.c | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/libmpdemux/demux_mkv.cpp b/libmpdemux/demux_mkv.cpp index bf00269c66..2b53965732 100644 --- a/libmpdemux/demux_mkv.cpp +++ b/libmpdemux/demux_mkv.cpp @@ -55,6 +55,7 @@ using namespace std; // for e.g. "-slang ger" extern char *dvdsub_lang; +extern char *audio_lang; // default values for Matroska elements #define MKVD_TIMECODESCALE 1000000 // 1000000 = 1ms @@ -1503,13 +1504,19 @@ extern "C" int demux_mkv_open(demuxer_t *demuxer) { track = NULL; if (demuxer->audio->id == -1) { // Automatically select an audio track. - // Search for an audio track that has the 'default' flag set. - for (i = 0; i < mkv_d->num_tracks; i++) - if ((mkv_d->tracks[i]->type == 'a') && mkv_d->tracks[i]->ok && - mkv_d->tracks[i]->default_track) { - track = mkv_d->tracks[i]; - break; - } + // check if the user specified an audio language + if (audio_lang != NULL) { + track = find_track_by_language(mkv_d, audio_lang, NULL, 'a'); + } + if (track == NULL) + // no audio language specified, or language not found + // Search for an audio track that has the 'default' flag set. + for (i = 0; i < mkv_d->num_tracks; i++) + if ((mkv_d->tracks[i]->type == 'a') && mkv_d->tracks[i]->ok && + mkv_d->tracks[i]->default_track) { + track = mkv_d->tracks[i]; + break; + } if (track == NULL) // No track has the 'default' flag set - let's take the first audio diff --git a/mencoder.c b/mencoder.c index 49776c1485..bec2f6d362 100644 --- a/mencoder.c +++ b/mencoder.c @@ -99,7 +99,7 @@ int audio_id=-1; int video_id=-1; int dvdsub_id=-1; int vobsub_id=-1; -static char* audio_lang=NULL; +char* audio_lang=NULL; char* dvdsub_lang=NULL; static char* spudec_ifo=NULL; diff --git a/mplayer.c b/mplayer.c index b7aca15777..9aec1be889 100644 --- a/mplayer.c +++ b/mplayer.c @@ -230,7 +230,7 @@ int audio_id=-1; int video_id=-1; int dvdsub_id=-1; int vobsub_id=-1; -static char* audio_lang=NULL; +char* audio_lang=NULL; char* dvdsub_lang=NULL; static char* spudec_ifo=NULL; char* filename=NULL; //"MI2-Trailer.avi"; -- cgit v1.2.3