1 /* $Id: rbaudio.c,v 1.5 2003-03-15 13:12:07 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 extern int Redbook_playing;
30 static int initialised = 0;
43 if (initialised) return;
44 if (FindArg("-nocdrom")) return;
46 if (SDL_Init(SDL_INIT_CDROM) < 0)
48 Warning("SDL library initialisation failed: %s.",SDL_GetError());
52 if (SDL_CDNumDrives() == 0)
54 Warning("No cdrom drives found!\n");
59 Warning("Could not open cdrom for redbook audio!\n");
76 int RBAPlayTrack(int a)
78 if (!initialised) return -1;
80 if (CD_INDRIVE(SDL_CDStatus(s_cd)) ) {
81 SDL_CDPlayTracks(s_cd, a-1, 0, 0, 0);
88 if (!initialised) return;
92 void RBASetVolume(int volume)
96 struct cdrom_volctrl volctrl;
98 if (!initialised) return;
103 if ((level<0) || (level>255)) {
104 fprintf(stderr, "illegal volume value (allowed values 0-255)\n");
113 if ( ioctl(cdfile, CDROMVOLCTRL, &volctrl) == -1 ) {
114 fprintf(stderr, "CDROMVOLCTRL ioctl failed\n");
122 if (!initialised) return;
128 if (!initialised) return -1;
133 int RBAGetNumberOfTracks()
135 if (!initialised) return -1;
137 return s_cd->numtracks;
140 int RBAPlayTracks(int tracknum,int something)
142 if (!initialised) return -1;
143 if (CD_INDRIVE(SDL_CDStatus(s_cd)) ) {
144 SDL_CDPlayTracks(s_cd, tracknum-1, 0, 0, 0);
151 if (!initialised) return -1;
153 return s_cd->cur_track;
156 int RBAPeekPlayStatus()
158 return (SDL_CDStatus(s_cd) == CD_PLAYING);