void I_UpdateCD() { if (!enabled) return; I_SetVolumeCD(cd_volume.value); if (playing && lastchk < SDL_GetTicks()) { lastchk = SDL_GetTicks() + 2000; //two seconds between chks if (CDAudio_GetAudioDiskInfo()) { playing = false; return; } if (cdStatus != CD_PLAYING && cdStatus != CD_PAUSED) { playing = false; if (playLooping) I_PlayCD(playTrack, true); } } return; }
/************************************************************************** * * function: UpdateCD * * description: * sets CD volume (may have changed) and initiates play evey 2 seconds * in case the song has elapsed * **************************************************************************/ void I_UpdateCD (void) { #ifndef NOSDLCD static Uint32 lastchk = 0; if (!cdEnabled || !cdrom) return; I_SetVolumeCD(cd_volume.value); if (cdPlaying && lastchk < SDL_GetTicks()) { lastchk = SDL_GetTicks() + 2000; //two seconds between chks if (CDAudio_GetAudioDiskInfo()==-1) { cdPlaying = SDL_FALSE; return; } if (cdStatus != CD_PLAYING && cdStatus != CD_PAUSED) { cdPlaying = SDL_FALSE; if (playLooping) I_PlayCD(playTrack, true); } } #endif }
// -------- // I_InitCD // Init CD Audio subsystem // -------- void I_InitCD (void) { MCI_SET_PARMS mciSet; MCIERROR iErr; int i; // We don't have an open device yet m_MCIOpen.wDeviceID = 0; m_nTracksCount = 0; cdaudio_started = false; m_MCIOpen.lpstrDeviceType = (LPCTSTR)MCI_DEVTYPE_CD_AUDIO; iErr = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE|MCI_OPEN_TYPE_ID, (DWORD_PTR)&m_MCIOpen); if (iErr) { MCIErrorMessageBox (iErr); return; } // Set the time format to track/minute/second/frame (TMSF). mciSet.dwTimeFormat = MCI_FORMAT_TMSF; iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_SET, MCI_SET_TIME_FORMAT, (DWORD_PTR)&mciSet); if (iErr) { MCIErrorMessageBox (iErr); mciSendCommand(m_MCIOpen.wDeviceID, MCI_CLOSE, 0, 0); return; } I_AddExitFunc (I_ShutdownCD); cdaudio_started = true; CONS_Printf ("I_InitCD: CD Audio started\n"); // last saved in config.cfg i = cd_volume.value; //I_SetVolumeCD (0); // initialize to 0 for some odd cd drivers I_SetVolumeCD (i); // now set the last saved volume for (i = 0; i < MAX_CD_TRACKS; i++) cdRemap[i] = (UINT8)i; if (!CD_ReadTrackInfo()) { CONS_Printf("\2I_InitCD: no CD in player.\n"); cdEnabled = false; cdValid = false; } else { cdEnabled = true; cdValid = true; } COM_AddCommand ("cd", Command_Cd_f); }