[MPlayer-dev-eng] Re: [PATCH] OSD: audio switching visualization

Tobias Diedrich ranma at tdiedrich.de
Sun Nov 6 16:05:07 CET 2005


Paul TT wrote:

> +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);
               ^^^^^^^
Since we now have a working strlcpy, we might as well use it here. :-)

>      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);
           ^^^^^^^^
Does this compile? I'd expect "int audio_id".

>          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;
                                    ^
This should depend on video fps, e.g. sh_video->fps/2.
For example some detelecined avis are 120fps, then this would be
very short.

> +      if (osd_show_audio_changed) {
> +          char lang[10] = MSGTR_OSDunknown;
                  ^^^^^^^^
Should be longer or not use a fixed size buffer.
Other languages and encodings might need more characters...

-- 
Tobias						PGP: http://9ac7e0bc.uguu.de




More information about the MPlayer-dev-eng mailing list