diff -urN main/help/help_mp-en.h main_osdaudio3b/help/help_mp-en.h --- main/help/help_mp-en.h 2005-11-05 02:27:36.599993904 +0100 +++ main_osdaudio3b/help/help_mp-en.h 2005-11-06 02:40:10.280532000 +0100 @@ -207,6 +207,7 @@ #define MSGTR_OSDnone "none" #define MSGTR_OSDunknown "unknown" #define MSGTR_OSDDVDNAV "DVDNAV: %s" +#define MSGTR_OSDAudioLanguage "Audio: (%d) %s" #define MSGTR_OSDChannel "Channel: %s" #define MSGTR_OSDSubtitles "Subtitles: %s" #define MSGTR_OSDSubtitlesOff "Subtitles: off" diff -urN main/libmpdemux/demux_mkv.c main_osdaudio3b/libmpdemux/demux_mkv.c --- main/libmpdemux/demux_mkv.c 2005-11-06 01:30:29.532102976 +0100 +++ main_osdaudio3b/libmpdemux/demux_mkv.c 2005-11-06 02:40:10.294530000 +0100 @@ -3444,6 +3444,40 @@ } } +/** \brief Get the language code for an audio track. + + Retrieves the language code for an audio track if it is known. + If the language code is "und" then do not copy it ("und" = "undefined"). + + \param demuxer The demuxer to work on + \param track_num The n'th audio track to get the language from + \param lang Store the language here + \param maxlen The maximum number of characters to copy into lang +*/ +void +demux_mkv_get_audio_lang(demuxer_t *demuxer, int track_num, char *lang, + int maxlen) +{ + mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv; + mkv_track_t *track; + int i, num; + + num = 0; + for (i = 0; i < mkv_d->num_tracks; i++) + { + track = mkv_d->tracks[i]; + if (track->type == MATROSKA_TRACK_AUDIO) + num++; + if (num == (track_num + 1)) + { + if ((track->language != NULL) && + strcmp(track->language, "und")) + strncpy(lang, track->language, maxlen); + return; + } + } +} + demuxer_desc_t demuxer_desc_matroska = { "Matroska demuxer", diff -urN main/libmpdemux/matroska.h main_osdaudio3b/libmpdemux/matroska.h --- main/libmpdemux/matroska.h 2005-10-22 12:19:11.789732016 +0200 +++ main_osdaudio3b/libmpdemux/matroska.h 2005-11-06 02:40:10.295530000 +0100 @@ -70,6 +70,8 @@ int demux_mkv_num_subs(demuxer_t *demuxer); int demux_mkv_change_subs(demuxer_t *demuxer, int new_num); +void demux_mkv_get_audio_lang(demuxer_t *demuxer, int track_num, char *lang, + int maxlen); void demux_mkv_get_sub_lang(demuxer_t *demuxer, int track_num, char *lang, int maxlen); diff -urN main/libmpdemux/stream_dvd.c main_osdaudio3b/libmpdemux/stream_dvd.c --- main/libmpdemux/stream_dvd.c 2005-10-18 17:00:24.228345072 +0200 +++ main_osdaudio3b/libmpdemux/stream_dvd.c 2005-11-06 02:40:10.297530000 +0100 @@ -136,6 +136,19 @@ return chapter; } +int dvd_lang_from_aid(stream_t *stream, int id) { + dvd_priv_t *d; + if (!stream) return 0; + d = stream->priv; + if (!d) return 0; + int i; + for(i=0;inr_of_channels;i++) { + if(d->audio_streams[i].id==id) + return d->audio_streams[i].language; + } + return 0; +} + int dvd_aid_from_lang(stream_t *stream, unsigned char* lang) { dvd_priv_t *d=stream->priv; int code,i; diff -urN main/libmpdemux/stream.h main_osdaudio3b/libmpdemux/stream.h --- main/libmpdemux/stream.h 2005-07-11 09:54:03.519667880 +0200 +++ main_osdaudio3b/libmpdemux/stream.h 2005-11-06 02:40:10.343523000 +0100 @@ -325,6 +325,7 @@ } dvd_priv_t; int dvd_number_of_subs(stream_t *stream); +int dvd_lang_from_aid(stream_t *stream, int id); int dvd_lang_from_sid(stream_t *stream, int id); int dvd_aid_from_lang(stream_t *stream, unsigned char* lang); int dvd_sid_from_lang(stream_t *stream, unsigned char* lang); diff -urN main/mplayer.c main_osdaudio3b/mplayer.c --- main/mplayer.c 2005-11-06 01:28:25.852905072 +0100 +++ main_osdaudio3b/mplayer.c 2005-11-06 03:24:14.302580160 +0100 @@ -1052,6 +1052,7 @@ int osd_show_av_delay = 0; int osd_show_text = 0; int osd_show_speed = 0; +int osd_show_audio_changed = 0; int osd_show_sub_delay = 0; int osd_show_sub_pos = 0; int osd_show_sub_visibility = 0; @@ -3710,9 +3711,10 @@ mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_TIME_POSITION=%.1f\n", pos); } break; case MP_CMD_SWITCH_AUDIO : { - int v = demuxer_switch_audio(demuxer, cmd->args[0].v.i); + audio_id = demuxer_switch_audio(demuxer, cmd->args[0].v.i); if (identify) - mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_TRACK=%d\n", v); + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_TRACK=%d\n", audio_id); + osd_show_audio_changed = 9; } break; case MP_CMD_RUN : { #ifndef __MINGW32__ @@ -4124,6 +4126,32 @@ snprintf(osd_text_tmp, 63, "%s", osd_show_text_buffer); osd_show_text--; } else + if (osd_show_audio_changed) { + char lang[10] = MSGTR_OSDunknown; +#ifdef USE_DVDREAD + if (sh_audio && (demuxer->type != DEMUXER_TYPE_MATROSKA)) { + if (audio_id >= 0) { + int code = 0; + code = dvd_lang_from_aid(stream, audio_id); + if (code) { + lang[0] = code >> 8; + lang[1] = code; + lang[2] = 0; + } + } + } +#endif +#ifdef HAVE_MATROSKA + if (demuxer->type == DEMUXER_TYPE_MATROSKA) { + if (audio_id >= 0) { + demux_mkv_get_audio_lang(demuxer, audio_id, lang, 9); + lang[9] = 0; + } + } +#endif + snprintf(osd_text_tmp, 63, MSGTR_OSDAudioLanguage, audio_id, lang); + osd_show_audio_changed--; + } else if (osd_show_sub_visibility) { snprintf(osd_text_tmp, 63, MSGTR_OSDSubtitles, sub_visibility? MSGTR_OSDenabled : MSGTR_OSDdisabled); osd_show_sub_visibility--;