24 #include "../client/client.h"
54 Com_DPrintf(
"MCI_SET_DOOR_OPEN failed (%i)\n", dwReturn);
63 Com_DPrintf(
"MCI_SET_DOOR_CLOSED failed (%i)\n", dwReturn);
70 MCI_STATUS_PARMS mciStatusParms;
75 mciStatusParms.dwItem = MCI_STATUS_READY;
76 dwReturn = mciSendCommand(
wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (
DWORD) (LPVOID) &mciStatusParms);
79 Com_DPrintf(
"CDAudio: drive ready test - get status failed\n");
82 if (!mciStatusParms.dwReturn)
88 mciStatusParms.dwItem = MCI_STATUS_NUMBER_OF_TRACKS;
89 dwReturn = mciSendCommand(
wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (
DWORD) (LPVOID) &mciStatusParms);
92 Com_DPrintf(
"CDAudio: get tracks - status failed\n");
95 if (mciStatusParms.dwReturn < 1)
110 MCI_PLAY_PARMS mciPlayParms;
111 MCI_STATUS_PARMS mciStatusParms;
123 track =
remap[track];
132 mciStatusParms.dwItem = MCI_CDA_STATUS_TYPE_TRACK;
133 mciStatusParms.dwTrack = track;
134 dwReturn = mciSendCommand(
wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (
DWORD) (LPVOID) &mciStatusParms);
140 if (mciStatusParms.dwReturn != MCI_CDA_TRACK_AUDIO)
142 Com_Printf(
"CDAudio: track %i is not audio\n", track);
147 mciStatusParms.dwItem = MCI_STATUS_LENGTH;
148 mciStatusParms.dwTrack = track;
149 dwReturn = mciSendCommand(
wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (
DWORD) (LPVOID) &mciStatusParms);
163 mciPlayParms.dwFrom = MCI_MAKE_TMSF(track, 0, 0, 0);
164 mciPlayParms.dwTo = (mciStatusParms.dwReturn << 8) | track;
166 dwReturn = mciSendCommand(
wDeviceID, MCI_PLAY, MCI_NOTIFY | MCI_FROM | MCI_TO, (
DWORD)(LPVOID) &mciPlayParms);
169 Com_DPrintf(
"CDAudio: MCI_PLAY failed (%i)\n", dwReturn);
192 int track,
i = 0, free_tracks = 0, remap_track;
196 MCI_PLAY_PARMS mciPlayParms;
197 MCI_STATUS_PARMS mciStatusParms;
204 track_bools = (
byte*)malloc(
maxTrack *
sizeof(
byte));
206 if (track_bools == 0)
212 mciStatusParms.dwItem = MCI_CDA_STATUS_TYPE_TRACK;
213 mciStatusParms.dwTrack =
remap[
i];
214 dwReturn = mciSendCommand(
wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (
DWORD) (LPVOID) &mciStatusParms);
220 track_bools[
i] = (mciStatusParms.dwReturn == MCI_CDA_TRACK_AUDIO);
222 free_tracks += track_bools[
i];
227 Com_DPrintf(
"CDAudio_RandomPlay: Unable to find and play a random audio track, insert an audio cd please");
236 f = ((float)rand()) / ((
float)RAND_MAX + 1.0);
239 while(!track_bools[track]);
241 remap_track =
remap[track];
244 mciStatusParms.dwItem = MCI_STATUS_LENGTH;
245 mciStatusParms.dwTrack = remap_track;
246 dwReturn = mciSendCommand(
wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (
DWORD) (LPVOID) &mciStatusParms);
262 mciPlayParms.dwFrom = MCI_MAKE_TMSF(remap_track, 0, 0, 0);
263 mciPlayParms.dwTo = (mciStatusParms.dwReturn << 8) | remap_track;
265 dwReturn = mciSendCommand(
wDeviceID, MCI_PLAY, MCI_NOTIFY | MCI_FROM | MCI_TO, (
DWORD)(LPVOID) &mciPlayParms);
268 track_bools[track] = 0;
278 while (free_tracks > 0);
281 free((
void*)track_bools);
305 MCI_GENERIC_PARMS mciGenericParms;
314 if (dwReturn = mciSendCommand(
wDeviceID, MCI_PAUSE, 0, (
DWORD)(LPVOID) &mciGenericParms))
322 void CDAudio_Resume(
void)
325 MCI_PLAY_PARMS mciPlayParms;
336 mciPlayParms.dwFrom = MCI_MAKE_TMSF(
playTrack, 0, 0, 0);
337 mciPlayParms.dwTo = MCI_MAKE_TMSF(
playTrack + 1, 0, 0, 0);
339 dwReturn = mciSendCommand(
wDeviceID, MCI_PLAY, MCI_TO | MCI_NOTIFY, (
DWORD)(LPVOID) &mciPlayParms);
342 Com_DPrintf(
"CDAudio: MCI_PLAY failed (%i)\n", dwReturn);
349 static void CD_f (
void)
379 for (n = 0; n < 100; n++)
390 for (n = 1; n < 100; n++)
395 for (n = 1; n <= ret; n++)
467 LONG CDAudio_MessageHandler(HWND hWnd,
UINT uMsg, WPARAM wParam, LPARAM lParam)
474 case MCI_NOTIFY_SUCCESSFUL:
490 case MCI_NOTIFY_ABORTED:
491 case MCI_NOTIFY_SUPERSEDED:
494 case MCI_NOTIFY_FAILURE:
501 Com_DPrintf(
"Unexpected MM_MCINOTIFY type (%i)\n", wParam);
530 MCI_OPEN_PARMS mciOpenParms;
531 MCI_SET_PARMS mciSetParms;
543 mciOpenParms.lpstrDeviceType =
"cdaudio";
544 if (dwReturn = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_SHAREABLE, (
DWORD) (LPVOID) &mciOpenParms))
546 Com_Printf(
"CDAudio_Init: MCI_OPEN failed (%i)\n", dwReturn);
552 mciSetParms.dwTimeFormat = MCI_FORMAT_TMSF;
553 if (dwReturn = mciSendCommand(
wDeviceID, MCI_SET, MCI_SET_TIME_FORMAT, (
DWORD)(LPVOID) &mciSetParms))
555 Com_Printf(
"MCI_SET_TIME_FORMAT failed (%i)\n", dwReturn);
560 for (n = 0; n < 100; n++)
586 Com_DPrintf(
"CDAudio_Shutdown: MCI_CLOSE failed\n");