[MPlayer-cvslog] r33620 - trunk/playtreeparser.c

reimar subversion at mplayerhq.hu
Wed Jun 15 20:06:29 CEST 2011


Author: reimar
Date: Wed Jun 15 20:06:28 2011
New Revision: 33620

Log:
Support "Length" option is .pls playlist files.

Modified:
   trunk/playtreeparser.c

Modified: trunk/playtreeparser.c
==============================================================================
--- trunk/playtreeparser.c	Wed Jun 15 11:28:20 2011	(r33619)
+++ trunk/playtreeparser.c	Wed Jun 15 20:06:28 2011	(r33620)
@@ -334,8 +334,14 @@ parse_pls(play_tree_parser_t* p) {
       num = pls_read_entry(line+6,&entries,&max_entry,&v);
       if(num < 0)
 	mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line);
-      else
-	entries[num-1].length = strdup(v);
+      else {
+        char *end;
+        long val = strtol(v, &end, 10);
+        if (*end || (val <= 0 && val != -1))
+          mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Invalid length value in entry %s\n",line);
+        else if (val > 0)
+          entries[num-1].length = strdup(v);
+      }
     } else
       mp_msg(MSGT_PLAYTREE,MSGL_WARN,"Unknown entry type %s\n",line);
     line = play_tree_parser_get_line(p);
@@ -348,6 +354,8 @@ parse_pls(play_tree_parser_t* p) {
       mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding entry %s\n",entries[num].file);
       entry = play_tree_new();
       play_tree_add_file(entry,entries[num].file);
+      if (entries[num].length)
+        play_tree_set_param(entry, "endpos", entries[num].length);
       free(entries[num].file);
       if(list)
 	play_tree_append_entry(last_entry,entry);


More information about the MPlayer-cvslog mailing list