icculus quake2 doxygen  1.0 dev
cd_win.c File Reference
#include <windows.h>
#include "../client/client.h"

Go to the source code of this file.

Functions

void CDAudio_Pause (void)
 
static void CDAudio_Eject (void)
 
static void CDAudio_CloseDoor (void)
 
static int CDAudio_GetAudioDiskInfo (void)
 
void CDAudio_Play2 (int track, qboolean looping)
 
void CDAudio_Play (int track, qboolean looping)
 
void CDAudio_RandomPlay (void)
 

Variables

HWND cl_hwnd
 
static qboolean cdValid = false
 
static qboolean playing = false
 
static qboolean wasPlaying = false
 
static qboolean initialized = false
 
static qboolean enabled = false
 
static qboolean playLooping = false
 
static byte remap [100]
 
static byte cdrom
 
static byte playTrack
 
static byte maxTrack
 
cvar_tcd_nocd
 
cvar_tcd_loopcount
 
cvar_tcd_looptrack
 
UINT wDeviceID
 
int loopcounter
 

Function Documentation

◆ CDAudio_CloseDoor()

static void CDAudio_CloseDoor ( void  )
static

Definition at line 58 of file cd_win.c.

59 {
60  DWORD dwReturn;
61 
62  if (dwReturn = mciSendCommand(wDeviceID, MCI_SET, MCI_SET_DOOR_CLOSED, (DWORD)NULL))
63  Com_DPrintf("MCI_SET_DOOR_CLOSED failed (%i)\n", dwReturn);
64 }

Referenced by CDAudio_RandomPlay().

◆ CDAudio_Eject()

static void CDAudio_Eject ( void  )
static

Definition at line 49 of file cd_win.c.

50 {
51  DWORD dwReturn;
52 
53  if (dwReturn = mciSendCommand(wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN, (DWORD)NULL))
54  Com_DPrintf("MCI_SET_DOOR_OPEN failed (%i)\n", dwReturn);
55 }

Referenced by CDAudio_RandomPlay().

◆ CDAudio_GetAudioDiskInfo()

static int CDAudio_GetAudioDiskInfo ( void  )
static

Definition at line 67 of file cd_win.c.

68 {
69  DWORD dwReturn;
70  MCI_STATUS_PARMS mciStatusParms;
71 
72 
73  cdValid = false;
74 
75  mciStatusParms.dwItem = MCI_STATUS_READY;
76  dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD) (LPVOID) &mciStatusParms);
77  if (dwReturn)
78  {
79  Com_DPrintf("CDAudio: drive ready test - get status failed\n");
80  return -1;
81  }
82  if (!mciStatusParms.dwReturn)
83  {
84  Com_DPrintf("CDAudio: drive not ready\n");
85  return -1;
86  }
87 
88  mciStatusParms.dwItem = MCI_STATUS_NUMBER_OF_TRACKS;
89  dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD) (LPVOID) &mciStatusParms);
90  if (dwReturn)
91  {
92  Com_DPrintf("CDAudio: get tracks - status failed\n");
93  return -1;
94  }
95  if (mciStatusParms.dwReturn < 1)
96  {
97  Com_DPrintf("CDAudio: no music tracks\n");
98  return -1;
99  }
100 
101  cdValid = true;
102  maxTrack = mciStatusParms.dwReturn;
103 
104  return 0;
105 }

Referenced by CDAudio_Play2(), and CDAudio_RandomPlay().

◆ CDAudio_Pause()

void CDAudio_Pause ( void  )

◆ CDAudio_Play()

void CDAudio_Play ( int  track,
qboolean  looping 
)

Definition at line 182 of file cd_win.c.

183 {
184  // set a loop counter so that this track will change to the
185  // looptrack later
186  loopcounter = 0;
187  CDAudio_Play2(track, looping);
188 }

Referenced by CDAudio_RandomPlay(), CL_ParseConfigString(), CL_PrepRefresh(), and UpdateCDVolumeFunc().

◆ CDAudio_Play2()

void CDAudio_Play2 ( int  track,
qboolean  looping 
)

Definition at line 107 of file cd_win.c.

108 {
109  DWORD dwReturn;
110  MCI_PLAY_PARMS mciPlayParms;
111  MCI_STATUS_PARMS mciStatusParms;
112 
113  if (!enabled)
114  return;
115 
116  if (!cdValid)
117  {
119  if (!cdValid)
120  return;
121  }
122 
123  track = remap[track];
124 
125  if (track < 1 || track > maxTrack)
126  {
127  CDAudio_Stop();
128  return;
129  }
130 
131  // don't try to play a non-audio 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);
135  if (dwReturn)
136  {
137  Com_DPrintf("MCI_STATUS failed (%i)\n", dwReturn);
138  return;
139  }
140  if (mciStatusParms.dwReturn != MCI_CDA_TRACK_AUDIO)
141  {
142  Com_Printf("CDAudio: track %i is not audio\n", track);
143  return;
144  }
145 
146  // get the length of the track to be played
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);
150  if (dwReturn)
151  {
152  Com_DPrintf("MCI_STATUS failed (%i)\n", dwReturn);
153  return;
154  }
155 
156  if (playing)
157  {
158  if (playTrack == track)
159  return;
160  CDAudio_Stop();
161  }
162 
163  mciPlayParms.dwFrom = MCI_MAKE_TMSF(track, 0, 0, 0);
164  mciPlayParms.dwTo = (mciStatusParms.dwReturn << 8) | track;
165  mciPlayParms.dwCallback = (DWORD)cl_hwnd;
166  dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_NOTIFY | MCI_FROM | MCI_TO, (DWORD)(LPVOID) &mciPlayParms);
167  if (dwReturn)
168  {
169  Com_DPrintf("CDAudio: MCI_PLAY failed (%i)\n", dwReturn);
170  return;
171  }
172 
173  playLooping = looping;
174  playTrack = track;
175  playing = true;
176 
177  if ( Cvar_VariableValue( "cd_nocd" ) )
178  CDAudio_Pause ();
179 }

Referenced by CDAudio_Play(), and CDAudio_RandomPlay().

◆ CDAudio_RandomPlay()

void CDAudio_RandomPlay ( void  )

Definition at line 190 of file cd_win.c.

Referenced by CL_PrepRefresh(), and UpdateCDVolumeFunc().

Variable Documentation

◆ cd_loopcount

cvar_t* cd_loopcount

Definition at line 40 of file cd_win.c.

Referenced by CDAudio_RandomPlay().

◆ cd_looptrack

cvar_t* cd_looptrack

Definition at line 41 of file cd_win.c.

Referenced by CDAudio_RandomPlay().

◆ cd_nocd

cvar_t* cd_nocd

Definition at line 39 of file cd_win.c.

Referenced by CDAudio_RandomPlay().

◆ cdrom

byte cdrom
static

Definition at line 35 of file cd_win.c.

◆ cdValid

qboolean cdValid = false
static

Definition at line 28 of file cd_win.c.

Referenced by CDAudio_GetAudioDiskInfo(), CDAudio_Play2(), and CDAudio_RandomPlay().

◆ cl_hwnd

◆ enabled

qboolean enabled = false
static

Definition at line 32 of file cd_win.c.

Referenced by CDAudio_Play2(), and CDAudio_RandomPlay().

◆ initialized

qboolean initialized = false
static

Definition at line 31 of file cd_win.c.

Referenced by CDAudio_RandomPlay(), and Sys_Milliseconds().

◆ loopcounter

int loopcounter

Definition at line 44 of file cd_win.c.

Referenced by CDAudio_Play(), and CDAudio_RandomPlay().

◆ maxTrack

byte maxTrack
static

Definition at line 37 of file cd_win.c.

Referenced by CDAudio_GetAudioDiskInfo(), CDAudio_Play2(), and CDAudio_RandomPlay().

◆ playing

qboolean playing = false
static

Definition at line 29 of file cd_win.c.

Referenced by CDAudio_Play2(), and CDAudio_RandomPlay().

◆ playLooping

qboolean playLooping = false
static

Definition at line 33 of file cd_win.c.

Referenced by CDAudio_Play2(), and CDAudio_RandomPlay().

◆ playTrack

byte playTrack
static

Definition at line 36 of file cd_win.c.

Referenced by CDAudio_Play2(), and CDAudio_RandomPlay().

◆ remap

byte remap[100]
static

Definition at line 34 of file cd_win.c.

Referenced by CDAudio_Play2(), and CDAudio_RandomPlay().

◆ wasPlaying

qboolean wasPlaying = false
static

Definition at line 30 of file cd_win.c.

Referenced by CDAudio_RandomPlay().

◆ wDeviceID

wDeviceID
UINT wDeviceID
Definition: cd_win.c:43
CDAudio_Stop
void CDAudio_Stop(void)
CDAudio_GetAudioDiskInfo
static int CDAudio_GetAudioDiskInfo(void)
Definition: cd_win.c:67
playTrack
static byte playTrack
Definition: cd_win.c:36
playLooping
static qboolean playLooping
Definition: cd_win.c:33
loopcounter
int loopcounter
Definition: cd_win.c:44
cdValid
static qboolean cdValid
Definition: cd_win.c:28
cl_hwnd
HWND cl_hwnd
Definition: vid_dll.c:53
NULL
#define NULL
Definition: q_shared.h:60
maxTrack
static byte maxTrack
Definition: cd_win.c:37
CDAudio_Pause
void CDAudio_Pause(void)
playing
static qboolean playing
Definition: cd_win.c:29
CDAudio_Play2
void CDAudio_Play2(int track, qboolean looping)
Definition: cd_win.c:107
Com_DPrintf
void Com_DPrintf(char *fmt,...)
Definition: common.c:155
DWORD
DWORD
Definition: qgl_win.c:49
Com_Printf
void Com_Printf(char *fmt,...)
Definition: common.c:102
enabled
static qboolean enabled
Definition: cd_win.c:32
remap
static byte remap[100]
Definition: cd_win.c:34
Cvar_VariableValue
float Cvar_VariableValue(char *var_name)
Definition: cvar.c:63