minor cleanups for CDDA mode

This commit is contained in:
nehalmistry 2002-12-11 08:09:41 +00:00
parent ab7f36b465
commit 19887eef44
2 changed files with 15 additions and 27 deletions

View file

@ -254,8 +254,12 @@ local int PlayCDRom(const char* name)
}
}
}
// CDPlayer command?
if (!strncmp(name, ":", 1)) {
StopMusic();
if (!CDRom) {
fprintf(stderr, "Couldn't open cdrom drive: %s\n", SDL_GetError());
CDMode = ":stopped";
@ -278,15 +282,9 @@ local int PlayCDRom(const char* name)
return 1;
}
// StopMusic(); // FIXME: JOHNS: why stop music here?
// FIXME: no cdrom, must stop it now!
return 0;
}
#endif
#ifdef USE_LIBCDA
#elif defined(USE_LIBCDA)
/**
** Play music from cdrom.
**
@ -331,10 +329,10 @@ local int PlayCDRom(const char* name)
}
}
StopMusic();
if (!strncmp(name, ":", 1)) {
StopMusic();
if (cd_get_tracks(NULL, NULL) == -1)
return 1;
@ -361,13 +359,10 @@ local int PlayCDRom(const char* name)
}
return 1;
}
// FIXME: no cdrom, must stop it now!
return 0;
}
#endif
#ifdef USE_CDDA
#elif defined(USE_CDDA)
/**
** Play music from cdrom.
**
@ -381,16 +376,12 @@ local int PlayCDRom(const char* name)
{
int i;
Sample *sample;
struct cdrom_volctrl cdvolume;
if (!strcmp(CDMode, ":off")) {
if (!strncmp(name, ":", 1)) {
CDDrive = open("/dev/cdrom", O_RDONLY | O_NONBLOCK);
ioctl(CDDrive, CDROMRESET);
ioctl(CDDrive, CDROM_DRIVE_STATUS);
ioctl(CDDrive, CDROM_DISC_STATUS);
ioctl(CDDrive, CDROMREADTOCHDR, &CDchdr);
for (i = CDchdr.cdth_trk0; i <= CDchdr.cdth_trk1; ++i){
@ -400,9 +391,6 @@ local int PlayCDRom(const char* name)
}
NumCDTracks = i + 1;
ioctl(CDDrive, CDROMVOLREAD, &cdvolume);
if (NumCDTracks == 0) {
CDMode = ":off";
return 1;
@ -411,10 +399,10 @@ local int PlayCDRom(const char* name)
}
}
// StopMusic();
if (!strncmp(name, ":", 1)) {
StopMusic();
// if mode is play all tracks
if (!strcmp(name, ":all")) {
CDMode = ":all";
@ -432,14 +420,14 @@ local int PlayCDRom(const char* name)
CDTrack = MyRand() % NumCDTracks;
} while (CDtocentry[++CDTrack].cdte_ctrl&CDROM_DATA_TRACK);
}
CDTrack = 3;
StopMusic();
CDTrack = 3; // temporary
sample = LoadCD(NULL, CDTrack);
MusicSample = sample;
PlayingMusic = 1;
return 1;
}
// FIXME: no cdrom, must stop it now!
return 0;

View file

@ -1743,11 +1743,11 @@ local void SetCdPower(Menuitem *mi __attribute__((unused)))
}
#elif defined(USE_CDDA)
// Start Playing CD
if (!PlayingMusic) {
if (!strcmp(":off", CDMode) || !strcmp(":stopped", CDMode)) {
PlayMusic(":random");
} else {
// Stop Playing CD
PlayingMusic = 0;
StopMusic();
CDMode = ":stopped";
}
#endif