[MPlayer-dev-eng] [PATCH] demuxer-independent sub and audio track selection

Evgeniy Stepanov eugeni.stepanov at gmail.com
Mon Feb 25 16:49:23 CET 2008


On Sunday 24 February 2008 18:31:29 Reimar Döffinger wrote:
> On Sun, Feb 24, 2008 at 06:12:39PM +0300, Evgeniy Stepanov wrote:
> > -	    if (mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA)
> > -		demux_mkv_get_audio_lang(mpctx->demuxer, audio_id, lang, 9);
> > +            sh_audio_t* sh = mpctx->sh_audio;
> > +            if (sh && sh->lang) {
> > +                strncpy(lang, sh->lang, 39);
> > +                lang[39] = 0;
> > +            }
>
> strncpy should be considered forbidden for new code, use av_strlcpy.
> Otherwise: very nice (though I did not check the implementation
> details).

Updated version.

- Using av_strlcpy instead of strncpy.
- Function select_audio() was wrong in many ways, fixed. 
- Some demuxers (actually, a lot of them) don't set audio->sh when switching 
tracks. This breaks switching to/from no sound. Therefore, I'm updating *->sh 
in demuxer_switch_*.
- There was a bug lavf demuxer, it can access memory before the start of an 
array. To reproduce, run with -nosound and try switching audio tracks. In 
line 710, pstreams[i] is executed with i == -1. Instead of fixing it, I 
rewrote this function to support switching to/from no sound:
nosound -> audio1 -> audio2 -> nosound. The same could (and, IMO, should) be 
done for other demuxers.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 03-sub-lang
Type: text/x-diff
Size: 7261 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20080225/069d8f9f/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 04-stupid-free
Type: text/x-diff
Size: 3283 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20080225/069d8f9f/attachment-0001.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 02-audio-lang
Type: text/x-diff
Size: 3745 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20080225/069d8f9f/attachment-0002.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 06-sub-select
Type: text/x-diff
Size: 1286 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20080225/069d8f9f/attachment-0003.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 07-sub-select2
Type: text/x-diff
Size: 2711 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20080225/069d8f9f/attachment-0004.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 08-demuxer-switch-sh
Type: text/x-diff
Size: 1024 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20080225/069d8f9f/attachment-0005.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 09-audio-select
Type: text/x-diff
Size: 2193 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20080225/069d8f9f/attachment-0006.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 10-audio-select2
Type: text/x-diff
Size: 2221 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20080225/069d8f9f/attachment-0007.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 11-reindent
Type: text/x-diff
Size: 1725 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20080225/069d8f9f/attachment-0008.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 12-cleanup
Type: text/x-diff
Size: 996 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20080225/069d8f9f/attachment-0009.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 01-sh-lang
Type: text/x-diff
Size: 1279 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20080225/069d8f9f/attachment-0010.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 13-lavf-audio-switch
Type: text/x-diff
Size: 1590 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20080225/069d8f9f/attachment-0011.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 05-demuxer-track-by-lang
Type: text/x-diff
Size: 1803 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20080225/069d8f9f/attachment-0012.diff>


More information about the MPlayer-dev-eng mailing list