vkQuake2 doxygen  1.0 dev
cdaudio.h File Reference

Go to the source code of this file.

Functions

int CDAudio_Init (void)
 
void CDAudio_Shutdown (void)
 
qboolean CDAudio_Play (int track, qboolean looping)
 
void CDAudio_Stop (void)
 
void CDAudio_Update (void)
 
void CDAudio_Activate (qboolean active)
 

Function Documentation

◆ CDAudio_Activate()

void CDAudio_Activate ( qboolean  active)

Definition at line 506 of file cd_win.c.

507 {
508  if (active)
509  CDAudio_Resume ();
510  else
511  CDAudio_Pause ();
512 }

Referenced by AppActivate().

◆ CDAudio_Init()

int CDAudio_Init ( void  )

Definition at line 437 of file cd_win.c.

438 {
439  DWORD dwReturn;
440  MCI_OPEN_PARMS mciOpenParms;
441  MCI_SET_PARMS mciSetParms;
442  int n;
443 
444  cd_nocd = Cvar_Get ("cd_nocd", "0", CVAR_ARCHIVE );
445  cd_loopcount = Cvar_Get ("cd_loopcount", "4", 0);
446  cd_looptrack = Cvar_Get ("cd_looptrack", "11", 0);
447  if ( cd_nocd->value)
448  return -1;
449 
450  mciOpenParms.lpstrDeviceType = "cdaudio";
451  if (dwReturn = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_SHAREABLE, (DWORD_PTR) (LPVOID) &mciOpenParms))
452  {
453  Com_Printf("CDAudio_Init: MCI_OPEN failed (%i)\n", dwReturn);
454  return -1;
455  }
456  wDeviceID = mciOpenParms.wDeviceID;
457 
458  // Set the time format to track/minute/second/frame (TMSF).
459  mciSetParms.dwTimeFormat = MCI_FORMAT_TMSF;
460  if (dwReturn = mciSendCommand(wDeviceID, MCI_SET, MCI_SET_TIME_FORMAT, (DWORD_PTR)(LPVOID) &mciSetParms))
461  {
462  Com_Printf("MCI_SET_TIME_FORMAT failed (%i)\n", dwReturn);
463  mciSendCommand(wDeviceID, MCI_CLOSE, 0, (DWORD_PTR)NULL);
464  return -1;
465  }
466 
467  for (n = 0; n < 100; n++)
468  remap[n] = n;
469  initialized = true;
470  enabled = true;
471 
473  {
474 // Com_Printf("CDAudio_Init: No CD in player.\n");
475  cdValid = false;
476  enabled = false;
477  }
478 
479  Cmd_AddCommand ("cd", CD_f);
480 
481  Com_Printf("CD Audio Initialized\n");
482 
483  return 0;
484 }

Referenced by CL_Init().

◆ CDAudio_Play()

qboolean CDAudio_Play ( int  track,
qboolean  looping 
)

Definition at line 186 of file cd_win.c.

187 {
188  // set a loop counter so that this track will change to the
189  // looptrack later
190  loopcounter = 0;
191  return CDAudio_Play2(track, looping);
192 }

Referenced by CD_f(), CDAudio_Update(), CL_ParseConfigString(), and CL_PrepRefresh().

◆ CDAudio_Shutdown()

void CDAudio_Shutdown ( void  )

Definition at line 487 of file cd_win.c.

488 {
489  if (!initialized)
490  return;
491  CDAudio_Stop();
492  if (mciSendCommand(wDeviceID, MCI_CLOSE, MCI_WAIT, (DWORD_PTR)NULL))
493  Com_DPrintf("CDAudio_Shutdown: MCI_CLOSE failed\n");
494 }

Referenced by CL_Shutdown().

◆ CDAudio_Stop()

void CDAudio_Stop ( void  )

Definition at line 194 of file cd_win.c.

195 {
196  DWORD dwReturn;
197 
198  if (!enabled)
199  return;
200 
201  if (!playing)
202  return;
203 
204  if (dwReturn = mciSendCommand(wDeviceID, MCI_STOP, 0, (DWORD_PTR)NULL))
205  Com_DPrintf("MCI_STOP failed (%i)", dwReturn);
206 
207  wasPlaying = false;
208  playing = false;
209 }

Referenced by CD_f(), CDAudio_MessageHandler(), CDAudio_Play2(), CDAudio_Shutdown(), and CDAudio_Update().

◆ CDAudio_Update()

void CDAudio_Update ( void  )

Definition at line 419 of file cd_win.c.

420 {
421  if ( cd_nocd->value != !enabled )
422  {
423  if ( cd_nocd->value )
424  {
425  CDAudio_Stop ();
426  enabled = false;
427  }
428  else
429  {
430  enabled = true;
432  }
433  }
434 }

Referenced by CL_Frame().

wDeviceID
UINT wDeviceID
Definition: cd_win.c:43
CDAudio_GetAudioDiskInfo
static int CDAudio_GetAudioDiskInfo(void)
Definition: cd_win.c:67
playTrack
static byte playTrack
Definition: cd_win.c:36
cd_nocd
cvar_t * cd_nocd
Definition: cd_win.c:39
playLooping
static qboolean playLooping
Definition: cd_win.c:33
cd_loopcount
cvar_t * cd_loopcount
Definition: cd_win.c:40
Cvar_Get
cvar_t * Cvar_Get(char *var_name, char *var_value, int flags)
Definition: cvar.c:127
CDAudio_Stop
void CDAudio_Stop(void)
Definition: cd_win.c:194
loopcounter
int loopcounter
Definition: cd_win.c:44
CDAudio_Play
qboolean CDAudio_Play(int track, qboolean looping)
Definition: cd_win.c:186
CD_f
static void CD_f(void)
Definition: cd_win.c:259
cdValid
static qboolean cdValid
Definition: cd_win.c:28
Cmd_AddCommand
void Cmd_AddCommand(char *cmd_name, xcommand_t function)
Definition: cmd.c:691
CVAR_ARCHIVE
#define CVAR_ARCHIVE
Definition: q_shared.h:316
cvar_s::value
float value
Definition: q_shared.h:331
NULL
#define NULL
Definition: q_shared.h:67
CDAudio_Pause
void CDAudio_Pause(void)
Definition: cd_win.c:212
wasPlaying
static qboolean wasPlaying
Definition: cd_win.c:30
CDAudio_Resume
void CDAudio_Resume(void)
Definition: cd_win.c:232
CDAudio_Play2
qboolean CDAudio_Play2(int track, qboolean looping)
Definition: cd_win.c:109
playing
static qboolean playing
Definition: cd_win.c:29
Com_DPrintf
void Com_DPrintf(char *fmt,...)
Definition: common.c:157
DWORD
DWORD
Definition: qgl_win.c:49
initialized
static qboolean initialized
Definition: cd_win.c:31
Com_Printf
void Com_Printf(char *fmt,...)
Definition: common.c:104
enabled
static qboolean enabled
Definition: cd_win.c:32
remap
static byte remap[100]
Definition: cd_win.c:34
cd_looptrack
cvar_t * cd_looptrack
Definition: cd_win.c:41