[SDL] Crappy CD performance SDL/win32

Phoenix Kokido kokido at postmark.net
Sat Dec 16 10:35:14 PST 2000


This is essentially what I tested with.  I did it with and without a 4
second delay.  If I'm still doing something wrong then when I get
everything working I'm gonna write a tutorial on it for the SDL doc
project.


#include <stdio.h>
#include "SDL.h"
 
 int main(int argc, char *argv[]) {
 	Uint8 *keys; 
 	SDL_Event event;
 	SDL_CD *cd;
 	
 	if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_CDROM) < 0 ){
 		fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
 		exit(1);
 	}
 	atexit(SDL_Quit);
 
 	if( (screen = SDL_SetVideoMode( WIDTH, HEIGHT, 0, 0)) == NULL ) {
 		fprintf(stderr, "Couldn't set mode: %s\n", SDL_GetError());
 		exit(1);
 	}
 	
 	cd = SDL_CDOpen(0);
 	SDL_CDStatus(cd);
	SDL_CDPlayTracks(cd, rand()%cd->numtracks, 0, 1, 0);
 
 	/* main loop */
 	while(!done) {
 		keys = SDL_GetKeyState(NULL); 
 		buttons=SDL_GetRelativeMouseState(&x, &y);  
 
 		if(keys[SDLK_ESCAPE] == SDL_PRESSED ) {
 			done=1;
 
 		SDL_CDStatus(cd);
 		fprintf(stdout, "/n*%i %i*/n", cd->status, CD_PLAYING) {
 		}
 		// Do graphics stuff and flip buffer here
 	}
 	
 	SDL_CDStop(cd);
 	SDL_Quit();
 	return 0;
 }
 



More information about the SDL mailing list