[vorbis-dev] ogg123 -k 1:59 patch.ogg # minutes and seconds
Hans Schou
chlor at schou.dk
Fri Feb 28 03:02:19 PST 2003
Hi
I have helped a user with a little patch for ogg123. He uses ogg123
for very big files, often more than an hour (blind books). When he
breaks the book and later on want to go back to the same chapter, it
is a little troublesome to calculate the seconds. Minutes is much more
convenient as it is what is written on the screen.
I guess my patch is a little buggy and would like to improve it upon
request (guidelines are welcome). Anyway, here it is:
diff -Naur vorbis-tools-1.0.orig/ogg123/cmdline_options.c vorbis-tools-1.0/ogg123/cmdline_options.c
--- vorbis-tools-1.0.orig/ogg123/cmdline_options.c Thu Jul 11 04:44:39 2002
+++ vorbis-tools-1.0/ogg123/cmdline_options.c Thu Feb 27 13:37:46 2003
@@ -50,6 +50,24 @@
{0, 0, 0, 0}
};
+double minsec_atof(const char *nptr)
+{
+ const char *p = nptr;
+ double min = 0.0;
+ double sec = 0.0;
+
+ while (*p && *p != '.') {
+ if (*p >= '0' && *p <='9')
+ sec = sec * 10 + (*p-'0');
+ else
+ if (*p == ':') {
+ min = sec;
+ sec = 0.0;
+ }
+ p++;
+ }
+ return (min*60+sec+atof(p));
+}
int parse_cmdline_options (int argc, char **argv,
ogg123_options_t *ogg123_opts,
@@ -137,7 +155,7 @@
break;
case 'k':
- ogg123_opts->seekpos = atof(optarg);
+ ogg123_opts->seekpos = minsec_atof(optarg);
break;
case 'l':
PS: Is there a library function for this kind of stuff?
best regards/hans
--
Hamletsgade 4 - 201, DK-2200 København N, Phone: +45 3582 9079
Schou Industries ApS http://schou.dk/ CVR: 26 13 44 39
--------------------------------------------------------------
You didn't answer my question.
-- John McClane, Die Hard
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the Vorbis-dev
mailing list