This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
if (!enabled)
return;
-
+
if (!cdValid)
{
CDAudio_GetAudioDiskInfo();
if (!enabled)
return;
-
+
if (!playing)
return;
if (!enabled)
return;
-
+
if (!cdValid)
return;
if (!wasPlaying)
return;
-
+
mciPlayParms.dwFrom = MCI_MAKE_TMSF(playTrack, 0, 0, 0);
mciPlayParms.dwTo = MCI_MAKE_TMSF(playTrack + 1, 0, 0, 0);
mciPlayParms.dwCallback = (DWORD)mainwindow;
static void CD_f (void)
{
- char *command;
- int ret;
- int n;
+ const char *command;
+ int ret;
+ int n;
if (Cmd_Argc() < 2)
return;
command = Cmd_Argv (1);
- if (Q_strcasecmp(command, "on") == 0)
+ if (strcasecmp(command, "on") == 0)
{
enabled = true;
return;
}
- if (Q_strcasecmp(command, "off") == 0)
+ if (strcasecmp(command, "off") == 0)
{
if (playing)
CDAudio_Stop();
return;
}
- if (Q_strcasecmp(command, "reset") == 0)
+ if (strcasecmp(command, "reset") == 0)
{
enabled = true;
if (playing)
return;
}
- if (Q_strcasecmp(command, "remap") == 0)
+ if (strcasecmp(command, "remap") == 0)
{
ret = Cmd_Argc() - 2;
if (ret <= 0)
return;
}
- if (Q_strcasecmp(command, "close") == 0)
+ if (strcasecmp(command, "close") == 0)
{
CDAudio_CloseDoor();
return;
}
}
- if (Q_strcasecmp(command, "play") == 0)
+ if (strcasecmp(command, "play") == 0)
{
CDAudio_Play((qbyte)atoi(Cmd_Argv (2)), false);
return;
}
- if (Q_strcasecmp(command, "loop") == 0)
+ if (strcasecmp(command, "loop") == 0)
{
CDAudio_Play((qbyte)atoi(Cmd_Argv (2)), true);
return;
}
- if (Q_strcasecmp(command, "stop") == 0)
+ if (strcasecmp(command, "stop") == 0)
{
CDAudio_Stop();
return;
}
- if (Q_strcasecmp(command, "pause") == 0)
+ if (strcasecmp(command, "pause") == 0)
{
CDAudio_Pause();
return;
}
- if (Q_strcasecmp(command, "resume") == 0)
+ if (strcasecmp(command, "resume") == 0)
{
CDAudio_Resume();
return;
}
- if (Q_strcasecmp(command, "eject") == 0)
+ if (strcasecmp(command, "eject") == 0)
{
if (playing)
CDAudio_Stop();
return;
}
- if (Q_strcasecmp(command, "info") == 0)
+ if (strcasecmp(command, "info") == 0)
{
Con_Printf("%u tracks\n", maxTrack);
if (playing)
LONG CDAudio_MessageHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- if (lParam != wDeviceID)
+ if (lParam != (LPARAM)wDeviceID)
return 1;
switch (wParam)
int CDAudio_Init(void)
{
- DWORD dwReturn;
- MCI_OPEN_PARMS mciOpenParms;
- MCI_SET_PARMS mciSetParms;
- int n;
+ int n;
if (cls.state == ca_dedicated)
return -1;
- if (COM_CheckParm("-nocdaudio"))
+ if (COM_CheckParm("-nocdaudio") || COM_CheckParm("-safe"))
return -1;
+ for (n = 0; n < 100; n++)
+ remap[n] = n;
+ cdaudioinitialized = true;
+ enabled = true;
+
+ Cmd_AddCommand("cd", CD_f);
+
+ return 0;
+}
+
+int CDAudio_Startup(void)
+{
+ DWORD dwReturn;
+ MCI_OPEN_PARMS mciOpenParms;
+ MCI_SET_PARMS mciSetParms;
+
mciOpenParms.lpstrDeviceType = "cdaudio";
if ((dwReturn = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_SHAREABLE, (DWORD) (LPVOID) &mciOpenParms)))
{
return -1;
}
- for (n = 0; n < 100; n++)
- remap[n] = n;
- cdaudioinitialized = true;
- initialized = true;
- enabled = true;
-
if (CDAudio_GetAudioDiskInfo())
{
- Con_Printf("CDAudio_Init: No CD in player.\n");
+ Con_DPrintf("CDAudio_Init: No CD in player.\n");
cdValid = false;
}
- Cmd_AddCommand ("cd", CD_f);
+ initialized = true;
- Con_Printf("CD Audio Initialized\n");
+ Con_DPrintf("CD Audio Initialized\n");
return 0;
}
CDAudio_Stop();
if (mciSendCommand(wDeviceID, MCI_CLOSE, MCI_WAIT, (DWORD)NULL))
Con_DPrintf("CDAudio_Shutdown: MCI_CLOSE failed\n");
+ initialized = false;
}