From 59fff90d94e01ae7cf5c3ff3a274020f4d4b2785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= 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. --- sub/vobsub.c | 10 ++++++---- sub/vobsub.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'sub') diff --git a/sub/vobsub.c b/sub/vobsub.c index 08efa3acec..a2fc94fb17 100644 --- a/sub/vobsub.c +++ b/sub/vobsub.c @@ -1109,20 +1109,22 @@ int vobsub_get_index_by_id(void *vobhandle, int id) return j; } -int vobsub_set_from_lang(void *vobhandle, unsigned char * lang) +int vobsub_set_from_lang(void *vobhandle, char **lang) { int i; vobsub_t *vob= vobhandle; - while (lang && strlen(lang) >= 2) { + if (!lang) + goto end; + for (int n = 0; lang[n]; n++) { for (i = 0; i < vob->spu_streams_size; i++) if (vob->spu_streams[i].id) - if ((strncmp(vob->spu_streams[i].id, lang, 2) == 0)) { + if ((strncmp(vob->spu_streams[i].id, lang[n], 2) == 0)) { vobsub_id = i; mp_msg(MSGT_VOBSUB, MSGL_INFO, "Selected VOBSUB language: %d language: %s\n", i, vob->spu_streams[i].id); return 0; } - lang+=2;while (lang[0]==',' || lang[0]==' ') ++lang; } +end: mp_msg(MSGT_VOBSUB, MSGL_WARN, "No matching VOBSUB language found!\n"); return -1; } diff --git a/sub/vobsub.h b/sub/vobsub.h index b076e4b6bc..3cef1347e5 100644 --- a/sub/vobsub.h +++ b/sub/vobsub.h @@ -41,7 +41,7 @@ unsigned int vobsub_rgb_to_yuv(unsigned int rgb); void *vobsub_out_open(const char *basename, const unsigned int *palette, unsigned int orig_width, unsigned int orig_height, const char *id, unsigned int index); void vobsub_out_output(void *me, const unsigned char *packet, int len, double pts); void vobsub_out_close(void *me); -int vobsub_set_from_lang(void *vobhandle, unsigned char * lang); +int vobsub_set_from_lang(void *vobhandle, char **lang); void vobsub_seek(void * vobhandle, float pts); #endif /* MPLAYER_VOBSUB_H */ -- cgit v1.2.3