summaryrefslogtreecommitdiffstats
path: root/stream/stream_dvdnav.c
diff options
context:
space:
mode:
authorClément Bœsch <ubitux@gmail.com>2011-02-18 15:32:40 +0100
committerUoti Urpala <uau@mplayer2.org>2011-04-20 04:22:42 +0300
commit59fff90d94e01ae7cf5c3ff3a274020f4d4b2785 (patch)
treea6f161866ae6918c4d2a2aebd9327716f3b53ea2 /stream/stream_dvdnav.c
parent2a7c5a1365ad194a42e3f667f85828a152544857 (diff)
downloadmpv-59fff90d94e01ae7cf5c3ff3a274020f4d4b2785.tar.bz2
mpv-59fff90d94e01ae7cf5c3ff3a274020f4d4b2785.tar.xz
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.
Diffstat (limited to 'stream/stream_dvdnav.c')
-rw-r--r--stream/stream_dvdnav.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c
index 21522f8b6b..b1c51e68e9 100644
--- a/stream/stream_dvdnav.c
+++ b/stream/stream_dvdnav.c
@@ -733,14 +733,14 @@ static int mp_dvdnav_get_aid_from_format (stream_t *stream, int index, uint8_t l
* \param lang: 2-characters language code[s], eventually separated by spaces of commas
* \return -1 on error, current subtitle id if successful
*/
-int mp_dvdnav_aid_from_lang(stream_t *stream, const unsigned char *language) {
+int mp_dvdnav_aid_from_lang(stream_t *stream, char **language) {
dvdnav_priv_t * priv = stream->priv;
int k;
uint8_t lg;
uint16_t lang, lcode;
- while(language && strlen(language)>=2) {
- lcode = (language[0] << 8) | (language[1]);
+ for (int i = 0; language[i]; i++) {
+ lcode = (language[i][0] << 8) | (language[i][1]);
for(k=0; k<32; k++) {
lg = dvdnav_get_audio_logical_stream(priv->dvdnav, k);
if(lg == 0xff) continue;
@@ -748,8 +748,6 @@ int mp_dvdnav_aid_from_lang(stream_t *stream, const unsigned char *language) {
if(lang != 0xFFFF && lang == lcode)
return mp_dvdnav_get_aid_from_format (stream, k, lg);
}
- language += 2;
- while(language[0]==',' || language[0]==' ') ++language;
}
return -1;
}
@@ -785,13 +783,13 @@ int mp_dvdnav_lang_from_aid(stream_t *stream, int aid, unsigned char *buf) {
* \param lang: 2-characters language code[s], eventually separated by spaces of commas
* \return -1 on error, current subtitle id if successful
*/
-int mp_dvdnav_sid_from_lang(stream_t *stream, const unsigned char *language) {
+int mp_dvdnav_sid_from_lang(stream_t *stream, char **language) {
dvdnav_priv_t * priv = stream->priv;
uint8_t lg, k;
uint16_t lang, lcode;
- while(language && strlen(language)>=2) {
- lcode = (language[0] << 8) | (language[1]);
+ for (int i = 0; language[i]; i++) {
+ lcode = (language[i][0] << 8) | (language[i][1]);
for(k=0; k<32; k++) {
lg = dvdnav_get_spu_logical_stream(priv->dvdnav, k);
if(lg == 0xff) continue;
@@ -800,8 +798,6 @@ int mp_dvdnav_sid_from_lang(stream_t *stream, const unsigned char *language) {
return lg;
}
}
- language += 2;
- while(language[0]==',' || language[0]==' ') ++language;
}
return -1;
}