From 59fff90d94e01ae7cf5c3ff3a274020f4d4b2785 Mon Sep 17 00:00:00 2001 From: Clément Bœsch Date: Fri, 18 Feb 2011 15:32:40 +0100 Subject: options: change -alang and -slang to use string list type There is no reason to use manual language list splitting when an automatic split function is already available. Some types change from "unsigned char" to "char", but this shouldn't cause issues since [as]lang settings are unlikely to have characters above 127. --- stream/stream_dvd.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'stream/stream_dvd.c') diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c index a302da81f1..f257ab78bd 100644 --- a/stream/stream_dvd.c +++ b/stream/stream_dvd.c @@ -125,24 +125,21 @@ int dvd_lang_from_aid(stream_t *stream, int id) { return 0; } -int dvd_aid_from_lang(stream_t *stream, const unsigned char* lang) { +int dvd_aid_from_lang(stream_t *stream, char **lang) { dvd_priv_t *d=stream->priv; int code,i; - if(lang) { - while(strlen(lang)>=2) { - code=lang[1]|(lang[0]<<8); + for (int n = 0; lang[n]; n++) { + code = lang[n][1] | (lang[n][0] << 8); for(i=0;inr_of_channels;i++) { if(d->audio_streams[i].language==code) { mp_tmsg(MSGT_OPEN,MSGL_INFO,"Selected DVD audio channel: %d language: %c%c\n", - d->audio_streams[i].id, lang[0],lang[1]); + d->audio_streams[i].id, lang[n][0], lang[n][1]); return d->audio_streams[i].id; } //printf("%X != %X (%c%c)\n",code,d->audio_streams[i].language,lang[0],lang[1]); } - lang+=2; while (lang[0]==',' || lang[0]==' ') ++lang; - } - mp_tmsg(MSGT_OPEN,MSGL_WARN,"No matching DVD audio language found!\n"); } + mp_tmsg(MSGT_OPEN,MSGL_WARN,"No matching DVD audio language found!\n"); return -1; } @@ -169,19 +166,17 @@ int dvd_lang_from_sid(stream_t *stream, int id) { return 0; } -int dvd_sid_from_lang(stream_t *stream, const unsigned char* lang) { +int dvd_sid_from_lang(stream_t *stream, char **lang) { dvd_priv_t *d=stream->priv; int code,i; - while(lang && strlen(lang)>=2) { - code=lang[1]|(lang[0]<<8); + for (int n = 0; lang[n]; n++) { + code = lang[n][1] | (lang[n][0] << 8); for(i=0;inr_of_subtitles;i++) { if(d->subtitles[i].language==code) { - mp_tmsg(MSGT_OPEN,MSGL_INFO,"Selected DVD subtitle channel: %d language: %c%c\n", i, lang[0],lang[1]); + mp_tmsg(MSGT_OPEN,MSGL_INFO,"Selected DVD subtitle channel: %d language: %c%c\n", i, lang[n][0], lang[n][1]); return d->subtitles[i].id; } } - lang+=2; - while (lang[0]==',' || lang[0]==' ') ++lang; } mp_tmsg(MSGT_OPEN,MSGL_WARN,"No matching DVD subtitle language found!\n"); return -1; -- cgit v1.2.3