[xiph-cvs] cvs commit: vorbis-tools/ogg123 ogg123.c
Michael Smith
msmith at xiph.org
Tue Dec 12 06:06:50 PST 2000
msmith 00/12/12 06:06:50
Modified: ogg123 ogg123.c
Log:
Patch for random play in ogg123. There's been some debate on the list as to
whether this is correct or not. It's better than what's there at the moment,
so it's going in anyway.
Revision Changes Path
1.12 +14 -6 vorbis-tools/ogg123/ogg123.c
Index: ogg123.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ogg123.c 2000/12/04 14:16:30 1.11
+++ ogg123.c 2000/12/12 14:06:49 1.12
@@ -14,7 +14,7 @@
* *
********************************************************************
- last mod: $Id: ogg123.c,v 1.11 2000/12/04 14:16:30 msmith Exp $
+ last mod: $Id: ogg123.c,v 1.12 2000/12/12 14:06:49 msmith Exp $
********************************************************************/
@@ -324,12 +324,20 @@
if (param.shuffle)
{
- int i=optind, j=0;
- for (i = optind; i < argc; i++)
+ int i;
+ int nb = argc - optind;
+ int *p = alloca(sizeof(int) * nb);
+ for (i = 0; i < nb; i++) p[i] = i;
+
+ srand (time (NULL));
+ for (i = 1; i < nb; i++)
+ {
+ int j = i * ((float) rand() / RAND_MAX);
+ int temp = p[j]; p[j] = p[i]; p[i] = temp;
+ }
+ for (i = 0; i < nb; i++)
{
- srand (time (NULL));
- j = (int) ((float) (argc - optind) * rand () / (RAND_MAX + 1.0));
- param.read_file = argv[j+optind];
+ param.read_file = argv[p[i]+optind];
play_file ();
}
}
--- >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 'cvs-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 commits
mailing list