1 /* $Id: rbaudio.c,v 1.6 2003-03-19 19:21:34 btb Exp $ */
4 * SDL CD Audio functions
19 #include <sys/ioctl.h>
20 #include <linux/cdrom.h>
28 static SDL_CD *s_cd = NULL;
29 static int initialised = 0;
42 if (initialised) return;
43 if (FindArg("-nocdrom")) return;
45 if (SDL_Init(SDL_INIT_CDROM) < 0)
47 Warning("SDL library initialisation failed: %s.",SDL_GetError());
51 if (SDL_CDNumDrives() == 0)
53 Warning("No cdrom drives found!\n");
58 Warning("Could not open cdrom for redbook audio!\n");
75 int RBAPlayTrack(int a)
77 if (!initialised) return -1;
79 if (CD_INDRIVE(SDL_CDStatus(s_cd)) ) {
80 SDL_CDPlayTracks(s_cd, a-1, 0, 0, 0);
87 if (!initialised) return;
91 void RBASetVolume(int volume)
95 struct cdrom_volctrl volctrl;
97 if (!initialised) return;
102 if ((level<0) || (level>255)) {
103 fprintf(stderr, "illegal volume value (allowed values 0-255)\n");
112 if ( ioctl(cdfile, CDROMVOLCTRL, &volctrl) == -1 ) {
113 fprintf(stderr, "CDROMVOLCTRL ioctl failed\n");
121 if (!initialised) return;
127 if (!initialised) return -1;
132 int RBAGetNumberOfTracks()
134 if (!initialised) return -1;
136 return s_cd->numtracks;
139 int RBAPlayTracks(int tracknum,int something)
141 if (!initialised) return -1;
142 if (CD_INDRIVE(SDL_CDStatus(s_cd)) ) {
143 SDL_CDPlayTracks(s_cd, tracknum-1, 0, 0, 0);
150 if (!initialised) return -1;
152 return s_cd->cur_track;
155 int RBAPeekPlayStatus()
157 return (SDL_CDStatus(s_cd) == CD_PLAYING);