Mercurial > sdl-ios-xcode
comparison src/cdrom/os2/SDL_syscdrom.c @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | 92947e3a18db |
children | 4da1ee79c9af |
comparison
equal
deleted
inserted
replaced
1661:281d3f4870e5 | 1662:782fd950bd46 |
---|---|
34 | 34 |
35 /* Size of MCI result buffer (in bytes) */ | 35 /* Size of MCI result buffer (in bytes) */ |
36 #define MCI_CMDRETBUFSIZE 128 | 36 #define MCI_CMDRETBUFSIZE 128 |
37 | 37 |
38 /* The maximum number of CD-ROM drives we'll detect */ | 38 /* The maximum number of CD-ROM drives we'll detect */ |
39 #define MAX_DRIVES 16 | 39 #define MAX_DRIVES 16 |
40 | 40 |
41 /* A list of available CD-ROM drives */ | 41 /* A list of available CD-ROM drives */ |
42 static char *SDL_cdlist[MAX_DRIVES]; | 42 static char *SDL_cdlist[MAX_DRIVES]; |
43 //static dev_t SDL_cdmode[MAX_DRIVES]; | 43 //static dev_t SDL_cdmode[MAX_DRIVES]; |
44 | 44 |
45 /* The system-dependent CD control functions */ | 45 /* The system-dependent CD control functions */ |
46 static const char *SDL_SYS_CDName(int drive); | 46 static const char *SDL_SYS_CDName (int drive); |
47 static int SDL_SYS_CDOpen(int drive); | 47 static int SDL_SYS_CDOpen (int drive); |
48 static int SDL_SYS_CDGetTOC(SDL_CD *cdrom); | 48 static int SDL_SYS_CDGetTOC (SDL_CD * cdrom); |
49 static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position); | 49 static CDstatus SDL_SYS_CDStatus (SDL_CD * cdrom, int *position); |
50 static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length); | 50 static int SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length); |
51 static int SDL_SYS_CDPause(SDL_CD *cdrom); | 51 static int SDL_SYS_CDPause (SDL_CD * cdrom); |
52 static int SDL_SYS_CDResume(SDL_CD *cdrom); | 52 static int SDL_SYS_CDResume (SDL_CD * cdrom); |
53 static int SDL_SYS_CDStop(SDL_CD *cdrom); | 53 static int SDL_SYS_CDStop (SDL_CD * cdrom); |
54 static int SDL_SYS_CDEject(SDL_CD *cdrom); | 54 static int SDL_SYS_CDEject (SDL_CD * cdrom); |
55 static void SDL_SYS_CDClose(SDL_CD *cdrom); | 55 static void SDL_SYS_CDClose (SDL_CD * cdrom); |
56 | 56 |
57 /* MCI Timing Functions */ | 57 /* MCI Timing Functions */ |
58 #define MCI_MMTIMEPERSECOND 3000 | 58 #define MCI_MMTIMEPERSECOND 3000 |
59 #define FRAMESFROMMM(mmtime) (((mmtime)*CD_FPS)/MCI_MMTIMEPERSECOND) | 59 #define FRAMESFROMMM(mmtime) (((mmtime)*CD_FPS)/MCI_MMTIMEPERSECOND) |
60 | 60 |
61 | 61 |
62 /* Ready for MCI CDAudio Devices */ | 62 /* Ready for MCI CDAudio Devices */ |
63 int SDL_SYS_CDInit(void) | 63 int |
64 { | 64 SDL_SYS_CDInit (void) |
65 int i; /* generig counter */ | 65 { |
66 MCI_SYSINFO_PARMS msp; /* Structure to MCI SysInfo parameters */ | 66 int i; /* generig counter */ |
67 CHAR SysInfoRet[MCI_CMDRETBUFSIZE]; /* Buffer for MCI Command result */ | 67 MCI_SYSINFO_PARMS msp; /* Structure to MCI SysInfo parameters */ |
68 CHAR SysInfoRet[MCI_CMDRETBUFSIZE]; /* Buffer for MCI Command result */ | |
68 | 69 |
69 /* Fill in our driver capabilities */ | 70 /* Fill in our driver capabilities */ |
70 SDL_CDcaps.Name = SDL_SYS_CDName; | 71 SDL_CDcaps.Name = SDL_SYS_CDName; |
71 SDL_CDcaps.Open = SDL_SYS_CDOpen; | 72 SDL_CDcaps.Open = SDL_SYS_CDOpen; |
72 SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC; | 73 SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC; |
73 SDL_CDcaps.Status = SDL_SYS_CDStatus; | 74 SDL_CDcaps.Status = SDL_SYS_CDStatus; |
74 SDL_CDcaps.Play = SDL_SYS_CDPlay; | 75 SDL_CDcaps.Play = SDL_SYS_CDPlay; |
75 SDL_CDcaps.Pause = SDL_SYS_CDPause; | 76 SDL_CDcaps.Pause = SDL_SYS_CDPause; |
76 SDL_CDcaps.Resume = SDL_SYS_CDResume; | 77 SDL_CDcaps.Resume = SDL_SYS_CDResume; |
77 SDL_CDcaps.Stop = SDL_SYS_CDStop; | 78 SDL_CDcaps.Stop = SDL_SYS_CDStop; |
78 SDL_CDcaps.Eject = SDL_SYS_CDEject; | 79 SDL_CDcaps.Eject = SDL_SYS_CDEject; |
79 SDL_CDcaps.Close = SDL_SYS_CDClose; | 80 SDL_CDcaps.Close = SDL_SYS_CDClose; |
80 | 81 |
81 /* Get the number of CD ROMs in the System */ | 82 /* Get the number of CD ROMs in the System */ |
82 /* Clean SysInfo structure */ | 83 /* Clean SysInfo structure */ |
83 SDL_memset(&msp, 0x00, sizeof(MCI_SYSINFO_PARMS)); | 84 SDL_memset (&msp, 0x00, sizeof (MCI_SYSINFO_PARMS)); |
84 /* Prepare structure to Ask Numer of Audio CDs */ | 85 /* Prepare structure to Ask Numer of Audio CDs */ |
85 msp.usDeviceType = MCI_DEVTYPE_CD_AUDIO; /* CD Audio Type */ | 86 msp.usDeviceType = MCI_DEVTYPE_CD_AUDIO; /* CD Audio Type */ |
86 msp.pszReturn = (PSZ)&SysInfoRet; /* Return Structure */ | 87 msp.pszReturn = (PSZ) & SysInfoRet; /* Return Structure */ |
87 msp.ulRetSize = MCI_CMDRETBUFSIZE; /* Size of ret struct */ | 88 msp.ulRetSize = MCI_CMDRETBUFSIZE; /* Size of ret struct */ |
88 if (LOUSHORT(mciSendCommand(0,MCI_SYSINFO, MCI_SYSINFO_QUANTITY | MCI_WAIT, (PVOID)&msp, 0)) != MCIERR_SUCCESS) return(CD_ERROR); | 89 if (LOUSHORT |
89 SDL_numcds = atoi(SysInfoRet); | 90 (mciSendCommand |
90 if (SDL_numcds > MAX_DRIVES) SDL_numcds = MAX_DRIVES; /* Limit maximum CD number */ | 91 (0, MCI_SYSINFO, MCI_SYSINFO_QUANTITY | MCI_WAIT, (PVOID) & msp, |
92 0)) != MCIERR_SUCCESS) | |
93 return (CD_ERROR); | |
94 SDL_numcds = atoi (SysInfoRet); | |
95 if (SDL_numcds > MAX_DRIVES) | |
96 SDL_numcds = MAX_DRIVES; /* Limit maximum CD number */ | |
91 | 97 |
92 /* Get and Add their system name to the SDL_cdlist */ | 98 /* Get and Add their system name to the SDL_cdlist */ |
93 msp.pszReturn = (PSZ)&SysInfoRet; /* Return Structure */ | 99 msp.pszReturn = (PSZ) & SysInfoRet; /* Return Structure */ |
94 msp.ulRetSize = MCI_CMDRETBUFSIZE; /* Size of ret struct */ | 100 msp.ulRetSize = MCI_CMDRETBUFSIZE; /* Size of ret struct */ |
95 msp.usDeviceType = MCI_DEVTYPE_CD_AUDIO; /* CD Audio Type */ | 101 msp.usDeviceType = MCI_DEVTYPE_CD_AUDIO; /* CD Audio Type */ |
96 for (i=0; i<SDL_numcds; i++) | 102 for (i = 0; i < SDL_numcds; i++) { |
97 { | 103 msp.ulNumber = i + 1; |
98 msp.ulNumber = i+1; | 104 mciSendCommand (0, MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_WAIT, &msp, 0); |
99 mciSendCommand(0,MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_WAIT,&msp, 0); | 105 SDL_cdlist[i] = SDL_strdup (SysInfoRet); |
100 SDL_cdlist[i] = SDL_strdup(SysInfoRet); | 106 if (SDL_cdlist[i] == NULL) { |
101 if ( SDL_cdlist[i] == NULL ) | 107 SDL_OutOfMemory (); |
102 { | 108 return (-1); |
103 SDL_OutOfMemory(); | 109 } |
104 return(-1); | 110 } |
105 } | 111 return (0); |
106 } | |
107 return(0); | |
108 } | 112 } |
109 | 113 |
110 /* Return CDAudio System Dependent Device Name - Ready for MCI*/ | 114 /* Return CDAudio System Dependent Device Name - Ready for MCI*/ |
111 static const char *SDL_SYS_CDName(int drive) | 115 static const char * |
112 { | 116 SDL_SYS_CDName (int drive) |
113 return(SDL_cdlist[drive]); | 117 { |
118 return (SDL_cdlist[drive]); | |
114 } | 119 } |
115 | 120 |
116 /* Open CDAudio Device - Ready for MCI */ | 121 /* Open CDAudio Device - Ready for MCI */ |
117 static int SDL_SYS_CDOpen(int drive) | 122 static int |
118 { | 123 SDL_SYS_CDOpen (int drive) |
119 MCI_OPEN_PARMS mop; | 124 { |
120 MCI_SET_PARMS msp; | 125 MCI_OPEN_PARMS mop; |
121 MCI_GENERIC_PARMS mgp; | 126 MCI_SET_PARMS msp; |
127 MCI_GENERIC_PARMS mgp; | |
122 | 128 |
123 /* Open the device */ | 129 /* Open the device */ |
124 mop.hwndCallback = (HWND)NULL; // None | 130 mop.hwndCallback = (HWND) NULL; // None |
125 mop.usDeviceID = (USHORT)NULL; // Will be returned. | 131 mop.usDeviceID = (USHORT) NULL; // Will be returned. |
126 mop.pszDeviceType = (PSZ)SDL_cdlist[drive]; // CDAudio Device | 132 mop.pszDeviceType = (PSZ) SDL_cdlist[drive]; // CDAudio Device |
127 if (LOUSHORT(mciSendCommand(0,MCI_OPEN,MCI_WAIT,&mop, 0)) != MCIERR_SUCCESS) return(CD_ERROR); | 133 if (LOUSHORT (mciSendCommand (0, MCI_OPEN, MCI_WAIT, &mop, 0)) != |
134 MCIERR_SUCCESS) | |
135 return (CD_ERROR); | |
128 /* Set time format */ | 136 /* Set time format */ |
129 msp.hwndCallback = (HWND)NULL; // None | 137 msp.hwndCallback = (HWND) NULL; // None |
130 msp.ulTimeFormat = MCI_FORMAT_MSF; // Minute : Second : Frame structure | 138 msp.ulTimeFormat = MCI_FORMAT_MSF; // Minute : Second : Frame structure |
131 msp.ulSpeedFormat = (ULONG)NULL; // No change | 139 msp.ulSpeedFormat = (ULONG) NULL; // No change |
132 msp.ulAudio = (ULONG)NULL; // No Channel | 140 msp.ulAudio = (ULONG) NULL; // No Channel |
133 msp.ulLevel = (ULONG)NULL; // No Volume | 141 msp.ulLevel = (ULONG) NULL; // No Volume |
134 msp.ulOver = (ULONG)NULL; // No Delay | 142 msp.ulOver = (ULONG) NULL; // No Delay |
135 msp.ulItem = (ULONG)NULL; // No item | 143 msp.ulItem = (ULONG) NULL; // No item |
136 msp.ulValue = (ULONG)NULL; // No value for item flag | 144 msp.ulValue = (ULONG) NULL; // No value for item flag |
137 if (LOUSHORT(mciSendCommand(mop.usDeviceID,MCI_SET,MCI_WAIT | MCI_SET_TIME_FORMAT,&msp, 0)) == MCIERR_SUCCESS) return (mop.usDeviceID); | 145 if (LOUSHORT |
146 (mciSendCommand | |
147 (mop.usDeviceID, MCI_SET, MCI_WAIT | MCI_SET_TIME_FORMAT, &msp, | |
148 0)) == MCIERR_SUCCESS) | |
149 return (mop.usDeviceID); | |
138 /* Error setting time format? - Close opened device */ | 150 /* Error setting time format? - Close opened device */ |
139 mgp.hwndCallback = (HWND)NULL; // None | 151 mgp.hwndCallback = (HWND) NULL; // None |
140 mciSendCommand(mop.usDeviceID,MCI_CLOSE,MCI_WAIT,&mgp, 0); | 152 mciSendCommand (mop.usDeviceID, MCI_CLOSE, MCI_WAIT, &mgp, 0); |
141 return(CD_ERROR); | 153 return (CD_ERROR); |
142 } | 154 } |
143 | 155 |
144 /* Get CD Table Of Contents - Ready for MCI */ | 156 /* Get CD Table Of Contents - Ready for MCI */ |
145 static int SDL_SYS_CDGetTOC(SDL_CD *cdrom) | 157 static int |
146 { | 158 SDL_SYS_CDGetTOC (SDL_CD * cdrom) |
147 MCI_TOC_PARMS mtp; | 159 { |
148 MCI_STATUS_PARMS msp; | 160 MCI_TOC_PARMS mtp; |
149 MCI_TOC_REC * mtr; | 161 MCI_STATUS_PARMS msp; |
150 INT i; | 162 MCI_TOC_REC *mtr; |
163 INT i; | |
151 | 164 |
152 /* Correction because MCI cannot read TOC while CD is playing (it'll stop!) */ | 165 /* Correction because MCI cannot read TOC while CD is playing (it'll stop!) */ |
153 if (cdrom->status == CD_PLAYING || cdrom->status == CD_PAUSED) return 0; | 166 if (cdrom->status == CD_PLAYING || cdrom->status == CD_PAUSED) |
167 return 0; | |
154 | 168 |
155 /* Get Number of Tracks */ | 169 /* Get Number of Tracks */ |
156 msp.hwndCallback = (HWND)NULL; /* None */ | 170 msp.hwndCallback = (HWND) NULL; /* None */ |
157 msp.ulReturn = (ULONG)NULL; /* We want this information */ | 171 msp.ulReturn = (ULONG) NULL; /* We want this information */ |
158 msp.ulItem = MCI_STATUS_NUMBER_OF_TRACKS; | 172 msp.ulItem = MCI_STATUS_NUMBER_OF_TRACKS; |
159 msp.ulValue = (ULONG)NULL; /* No additional information */ | 173 msp.ulValue = (ULONG) NULL; /* No additional information */ |
160 if (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_STATUS_ITEM,&msp, 0)) != MCIERR_SUCCESS) return(CD_ERROR); | 174 if (LOUSHORT |
161 cdrom->numtracks = msp.ulReturn; | 175 (mciSendCommand |
162 if ( cdrom->numtracks > SDL_MAX_TRACKS ) | 176 (cdrom->id, MCI_STATUS, MCI_WAIT | MCI_STATUS_ITEM, &msp, |
163 { | 177 0)) != MCIERR_SUCCESS) |
164 cdrom->numtracks = SDL_MAX_TRACKS; | 178 return (CD_ERROR); |
165 } | 179 cdrom->numtracks = msp.ulReturn; |
180 if (cdrom->numtracks > SDL_MAX_TRACKS) { | |
181 cdrom->numtracks = SDL_MAX_TRACKS; | |
182 } | |
166 /* Alocate space for TOC data */ | 183 /* Alocate space for TOC data */ |
167 mtr = (MCI_TOC_REC *)SDL_malloc(cdrom->numtracks*sizeof(MCI_TOC_REC)); | 184 mtr = |
168 if ( mtr == NULL ) | 185 (MCI_TOC_REC *) SDL_malloc (cdrom->numtracks * sizeof (MCI_TOC_REC)); |
169 { | 186 if (mtr == NULL) { |
170 SDL_OutOfMemory(); | 187 SDL_OutOfMemory (); |
171 return(-1); | 188 return (-1); |
172 } | 189 } |
173 /* Get TOC from CD */ | 190 /* Get TOC from CD */ |
174 mtp.pBuf = mtr; | 191 mtp.pBuf = mtr; |
175 mtp.ulBufSize = cdrom->numtracks*sizeof(MCI_TOC_REC); | 192 mtp.ulBufSize = cdrom->numtracks * sizeof (MCI_TOC_REC); |
176 if (LOUSHORT(mciSendCommand(cdrom->id,MCI_GETTOC,MCI_WAIT,&mtp, 0)) != MCIERR_SUCCESS) | 193 if (LOUSHORT (mciSendCommand (cdrom->id, MCI_GETTOC, MCI_WAIT, &mtp, 0)) |
177 { | 194 != MCIERR_SUCCESS) { |
178 SDL_OutOfMemory(); | 195 SDL_OutOfMemory (); |
179 SDL_free(mtr); | 196 SDL_free (mtr); |
180 return(CD_ERROR); | 197 return (CD_ERROR); |
181 } | 198 } |
182 /* Fill SDL Tracks Structure */ | 199 /* Fill SDL Tracks Structure */ |
183 for (i=0; i<cdrom->numtracks; i++) | 200 for (i = 0; i < cdrom->numtracks; i++) { |
184 { | 201 /* Set Track ID */ |
185 /* Set Track ID */ | 202 cdrom->track[i].id = (mtr + i)->TrackNum; |
186 cdrom->track[i].id = (mtr+i)->TrackNum; | 203 /* Set Track Type */ |
187 /* Set Track Type */ | 204 msp.hwndCallback = (HWND) NULL; /* None */ |
188 msp.hwndCallback = (HWND)NULL; /* None */ | 205 msp.ulReturn = (ULONG) NULL; /* We want this information */ |
189 msp.ulReturn = (ULONG)NULL; /* We want this information */ | 206 msp.ulItem = MCI_CD_STATUS_TRACK_TYPE; |
190 msp.ulItem = MCI_CD_STATUS_TRACK_TYPE; | 207 msp.ulValue = (ULONG) ((mtr + i)->TrackNum); /* Track Number? */ |
191 msp.ulValue = (ULONG)((mtr+i)->TrackNum); /* Track Number? */ | 208 if (LOUSHORT |
192 if (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_TRACK | MCI_STATUS_ITEM,&msp, 0)) != MCIERR_SUCCESS) | 209 (mciSendCommand |
193 { | 210 (cdrom->id, MCI_STATUS, MCI_WAIT | MCI_TRACK | MCI_STATUS_ITEM, |
194 SDL_free(mtr); | 211 &msp, 0)) != MCIERR_SUCCESS) { |
195 return (CD_ERROR); | 212 SDL_free (mtr); |
196 } | 213 return (CD_ERROR); |
197 if (msp.ulReturn==MCI_CD_TRACK_AUDIO) cdrom->track[i].type = SDL_AUDIO_TRACK; | 214 } |
198 else cdrom->track[i].type = SDL_DATA_TRACK; | 215 if (msp.ulReturn == MCI_CD_TRACK_AUDIO) |
199 /* Set Track Length - values from MCI are in MMTIMEs - 3000 MMTIME = 1 second */ | 216 cdrom->track[i].type = SDL_AUDIO_TRACK; |
200 cdrom->track[i].length = FRAMESFROMMM((mtr+i)->ulEndAddr - (mtr+i)->ulStartAddr); | 217 else |
201 /* Set Track Offset */ | 218 cdrom->track[i].type = SDL_DATA_TRACK; |
202 cdrom->track[i].offset = FRAMESFROMMM((mtr+i)->ulStartAddr); | 219 /* Set Track Length - values from MCI are in MMTIMEs - 3000 MMTIME = 1 second */ |
203 } | 220 cdrom->track[i].length = |
204 SDL_free(mtr); | 221 FRAMESFROMMM ((mtr + i)->ulEndAddr - (mtr + i)->ulStartAddr); |
205 return(0); | 222 /* Set Track Offset */ |
223 cdrom->track[i].offset = FRAMESFROMMM ((mtr + i)->ulStartAddr); | |
224 } | |
225 SDL_free (mtr); | |
226 return (0); | |
206 } | 227 } |
207 | 228 |
208 | 229 |
209 /* Get CD-ROM status - Ready for MCI */ | 230 /* Get CD-ROM status - Ready for MCI */ |
210 static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position) | 231 static CDstatus |
211 { | 232 SDL_SYS_CDStatus (SDL_CD * cdrom, int *position) |
212 CDstatus status; | 233 { |
213 MCI_STATUS_PARMS msp; | 234 CDstatus status; |
235 MCI_STATUS_PARMS msp; | |
214 | 236 |
215 /* Get Status from MCI */ | 237 /* Get Status from MCI */ |
216 msp.hwndCallback = (HWND)NULL; /* None */ | 238 msp.hwndCallback = (HWND) NULL; /* None */ |
217 msp.ulReturn = (ULONG)NULL; /* We want this information */ | 239 msp.ulReturn = (ULONG) NULL; /* We want this information */ |
218 msp.ulItem = MCI_STATUS_MODE; | 240 msp.ulItem = MCI_STATUS_MODE; |
219 msp.ulValue = (ULONG)NULL; /* No additional information */ | 241 msp.ulValue = (ULONG) NULL; /* No additional information */ |
220 if (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_STATUS_ITEM,&msp, 0)) != MCIERR_SUCCESS) status = CD_ERROR; | 242 if (LOUSHORT |
221 else | 243 (mciSendCommand |
222 { | 244 (cdrom->id, MCI_STATUS, MCI_WAIT | MCI_STATUS_ITEM, &msp, |
223 switch(msp.ulReturn) | 245 0)) != MCIERR_SUCCESS) |
224 { | 246 status = CD_ERROR; |
225 case MCI_MODE_NOT_READY: | 247 else { |
226 status = CD_TRAYEMPTY; | 248 switch (msp.ulReturn) { |
227 break; | 249 case MCI_MODE_NOT_READY: |
228 case MCI_MODE_PAUSE: | 250 status = CD_TRAYEMPTY; |
229 status = CD_PAUSED; | 251 break; |
230 break; | 252 case MCI_MODE_PAUSE: |
231 case MCI_MODE_PLAY: | 253 status = CD_PAUSED; |
232 status = CD_PLAYING; | 254 break; |
233 break; | 255 case MCI_MODE_PLAY: |
234 case MCI_MODE_STOP: | 256 status = CD_PLAYING; |
235 status = CD_STOPPED; | 257 break; |
236 break; | 258 case MCI_MODE_STOP: |
237 /* These cases should not occour */ | 259 status = CD_STOPPED; |
238 case MCI_MODE_RECORD: | 260 break; |
239 case MCI_MODE_SEEK: | 261 /* These cases should not occour */ |
240 default: | 262 case MCI_MODE_RECORD: |
241 status = CD_ERROR; | 263 case MCI_MODE_SEEK: |
242 break; | 264 default: |
243 } | 265 status = CD_ERROR; |
244 } | 266 break; |
267 } | |
268 } | |
245 | 269 |
246 /* Determine position */ | 270 /* Determine position */ |
247 if (position != NULL) /* The SDL $&$&%# CDROM call sends NULL pointer here! */ | 271 if (position != NULL) { /* The SDL $&$&%# CDROM call sends NULL pointer here! */ |
248 { | 272 if ((status == CD_PLAYING) || (status == CD_PAUSED)) { |
249 if ((status == CD_PLAYING) || (status == CD_PAUSED)) | 273 /* Get Position */ |
250 { | 274 msp.hwndCallback = (HWND) NULL; /* None */ |
251 /* Get Position */ | 275 msp.ulReturn = (ULONG) NULL; /* We want this information */ |
252 msp.hwndCallback = (HWND)NULL; /* None */ | 276 msp.ulItem = MCI_STATUS_POSITION; |
253 msp.ulReturn = (ULONG)NULL; /* We want this information */ | 277 msp.ulValue = (ULONG) NULL; /* No additiona info */ |
254 msp.ulItem = MCI_STATUS_POSITION; | 278 if (LOUSHORT |
255 msp.ulValue = (ULONG)NULL; /* No additiona info */ | 279 (mciSendCommand |
256 if (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_STATUS_ITEM,&msp, 0)) != MCIERR_SUCCESS) return (CD_ERROR); | 280 (cdrom->id, MCI_STATUS, MCI_WAIT | MCI_STATUS_ITEM, &msp, |
257 /* Convert from MSF (format selected in the Open process) to Frames (format that will be returned) */ | 281 0)) != MCIERR_SUCCESS) |
258 *position = MSF_TO_FRAMES(MSF_MINUTE(msp.ulReturn),MSF_SECOND(msp.ulReturn),MSF_FRAME(msp.ulReturn)); | 282 return (CD_ERROR); |
259 } | 283 /* Convert from MSF (format selected in the Open process) to Frames (format that will be returned) */ |
260 else *position = 0; | 284 *position = |
261 } | 285 MSF_TO_FRAMES (MSF_MINUTE (msp.ulReturn), |
262 return(status); | 286 MSF_SECOND (msp.ulReturn), |
287 MSF_FRAME (msp.ulReturn)); | |
288 } else | |
289 *position = 0; | |
290 } | |
291 return (status); | |
263 } | 292 } |
264 | 293 |
265 /* Start play - Ready for MCI */ | 294 /* Start play - Ready for MCI */ |
266 static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length) | 295 static int |
267 { | 296 SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length) |
268 MCI_GENERIC_PARMS mgp; | 297 { |
269 MCI_STATUS_PARMS msp; | 298 MCI_GENERIC_PARMS mgp; |
270 MCI_PLAY_PARMS mpp; | 299 MCI_STATUS_PARMS msp; |
271 ULONG min,sec,frm; | 300 MCI_PLAY_PARMS mpp; |
301 ULONG min, sec, frm; | |
272 | 302 |
273 /* Start MSF */ | 303 /* Start MSF */ |
274 FRAMES_TO_MSF(start, &min, &sec, &frm); | 304 FRAMES_TO_MSF (start, &min, &sec, &frm); |
275 MSF_MINUTE(mpp.ulFrom) = min; | 305 MSF_MINUTE (mpp.ulFrom) = min; |
276 MSF_SECOND(mpp.ulFrom) = sec; | 306 MSF_SECOND (mpp.ulFrom) = sec; |
277 MSF_FRAME(mpp.ulFrom) = frm; | 307 MSF_FRAME (mpp.ulFrom) = frm; |
278 /* End MSF */ | 308 /* End MSF */ |
279 FRAMES_TO_MSF(start+length, &min, &sec, &frm); | 309 FRAMES_TO_MSF (start + length, &min, &sec, &frm); |
280 MSF_MINUTE(mpp.ulTo) = min; | 310 MSF_MINUTE (mpp.ulTo) = min; |
281 MSF_SECOND(mpp.ulTo) = sec; | 311 MSF_SECOND (mpp.ulTo) = sec; |
282 MSF_FRAME(mpp.ulTo) = frm; | 312 MSF_FRAME (mpp.ulTo) = frm; |
283 #ifdef DEBUG_CDROM | 313 #ifdef DEBUG_CDROM |
284 fprintf(stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n", | 314 fprintf (stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n", |
285 playtime.cdmsf_min0, playtime.cdmsf_sec0, playtime.cdmsf_frame0, | 315 playtime.cdmsf_min0, playtime.cdmsf_sec0, playtime.cdmsf_frame0, |
286 playtime.cdmsf_min1, playtime.cdmsf_sec1, playtime.cdmsf_frame1); | 316 playtime.cdmsf_min1, playtime.cdmsf_sec1, playtime.cdmsf_frame1); |
287 #endif | 317 #endif |
288 /* Verifies if it is paused first... and if it is, unpause before stopping it. */ | 318 /* Verifies if it is paused first... and if it is, unpause before stopping it. */ |
289 msp.hwndCallback = (HWND)NULL; /* None */ | 319 msp.hwndCallback = (HWND) NULL; /* None */ |
290 msp.ulReturn = (ULONG)NULL; /* We want this information */ | 320 msp.ulReturn = (ULONG) NULL; /* We want this information */ |
291 msp.ulItem = MCI_STATUS_MODE; | 321 msp.ulItem = MCI_STATUS_MODE; |
292 msp.ulValue = (ULONG)NULL; /* No additional information */ | 322 msp.ulValue = (ULONG) NULL; /* No additional information */ |
293 if (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_STATUS_ITEM,&msp, 0)) == MCIERR_SUCCESS) | 323 if (LOUSHORT |
294 { | 324 (mciSendCommand |
295 if (msp.ulReturn == MCI_MODE_PAUSE) | 325 (cdrom->id, MCI_STATUS, MCI_WAIT | MCI_STATUS_ITEM, &msp, |
296 { | 326 0)) == MCIERR_SUCCESS) { |
297 mgp.hwndCallback = (HWND)NULL; // None | 327 if (msp.ulReturn == MCI_MODE_PAUSE) { |
298 mciSendCommand(cdrom->id,MCI_RESUME,0,&mgp, 0); | 328 mgp.hwndCallback = (HWND) NULL; // None |
299 } | 329 mciSendCommand (cdrom->id, MCI_RESUME, 0, &mgp, 0); |
300 } | 330 } |
331 } | |
301 /* Now play it. */ | 332 /* Now play it. */ |
302 mpp.hwndCallback = (HWND)NULL; // We do not want the info. temp | 333 mpp.hwndCallback = (HWND) NULL; // We do not want the info. temp |
303 if (LOUSHORT(mciSendCommand(cdrom->id,MCI_PLAY,MCI_FROM | MCI_TO,&mpp, 0)) == MCIERR_SUCCESS) return 0; | 334 if (LOUSHORT |
304 return (CD_ERROR); | 335 (mciSendCommand (cdrom->id, MCI_PLAY, MCI_FROM | MCI_TO, &mpp, 0)) == |
336 MCIERR_SUCCESS) | |
337 return 0; | |
338 return (CD_ERROR); | |
305 } | 339 } |
306 | 340 |
307 /* Pause play - Ready for MCI */ | 341 /* Pause play - Ready for MCI */ |
308 static int SDL_SYS_CDPause(SDL_CD *cdrom) | 342 static int |
309 { | 343 SDL_SYS_CDPause (SDL_CD * cdrom) |
310 MCI_GENERIC_PARMS mgp; | 344 { |
311 | 345 MCI_GENERIC_PARMS mgp; |
312 mgp.hwndCallback = (HWND)NULL; // None | 346 |
313 if (LOUSHORT(mciSendCommand(cdrom->id,MCI_PAUSE,MCI_WAIT,&mgp, 0)) == MCIERR_SUCCESS) return 0; | 347 mgp.hwndCallback = (HWND) NULL; // None |
314 return(CD_ERROR); | 348 if (LOUSHORT (mciSendCommand (cdrom->id, MCI_PAUSE, MCI_WAIT, &mgp, 0)) == |
349 MCIERR_SUCCESS) | |
350 return 0; | |
351 return (CD_ERROR); | |
315 } | 352 } |
316 | 353 |
317 /* Resume play - Ready for MCI */ | 354 /* Resume play - Ready for MCI */ |
318 static int SDL_SYS_CDResume(SDL_CD *cdrom) | 355 static int |
319 { | 356 SDL_SYS_CDResume (SDL_CD * cdrom) |
320 MCI_GENERIC_PARMS mgp; | 357 { |
321 | 358 MCI_GENERIC_PARMS mgp; |
322 mgp.hwndCallback = (HWND)NULL; // None | 359 |
323 if (LOUSHORT(mciSendCommand(cdrom->id,MCI_RESUME,MCI_WAIT,&mgp, 0)) == MCIERR_SUCCESS) return 0; | 360 mgp.hwndCallback = (HWND) NULL; // None |
324 return(CD_ERROR); | 361 if (LOUSHORT (mciSendCommand (cdrom->id, MCI_RESUME, MCI_WAIT, &mgp, 0)) |
362 == MCIERR_SUCCESS) | |
363 return 0; | |
364 return (CD_ERROR); | |
325 } | 365 } |
326 | 366 |
327 /* Stop play - Ready for MCI */ | 367 /* Stop play - Ready for MCI */ |
328 static int SDL_SYS_CDStop(SDL_CD *cdrom) | 368 static int |
329 { | 369 SDL_SYS_CDStop (SDL_CD * cdrom) |
330 MCI_GENERIC_PARMS mgp; | 370 { |
331 MCI_STATUS_PARMS msp; | 371 MCI_GENERIC_PARMS mgp; |
372 MCI_STATUS_PARMS msp; | |
332 | 373 |
333 /* Verifies if it is paused first... and if it is, unpause before stopping it. */ | 374 /* Verifies if it is paused first... and if it is, unpause before stopping it. */ |
334 msp.hwndCallback = (HWND)NULL; /* None */ | 375 msp.hwndCallback = (HWND) NULL; /* None */ |
335 msp.ulReturn = (ULONG)NULL; /* We want this information */ | 376 msp.ulReturn = (ULONG) NULL; /* We want this information */ |
336 msp.ulItem = MCI_STATUS_MODE; | 377 msp.ulItem = MCI_STATUS_MODE; |
337 msp.ulValue = (ULONG)NULL; /* No additional information */ | 378 msp.ulValue = (ULONG) NULL; /* No additional information */ |
338 if (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_STATUS_ITEM,&msp, 0)) == MCIERR_SUCCESS) | 379 if (LOUSHORT |
339 { | 380 (mciSendCommand |
340 if (msp.ulReturn == MCI_MODE_PAUSE) | 381 (cdrom->id, MCI_STATUS, MCI_WAIT | MCI_STATUS_ITEM, &msp, |
341 { | 382 0)) == MCIERR_SUCCESS) { |
342 mgp.hwndCallback = (HWND)NULL; // None | 383 if (msp.ulReturn == MCI_MODE_PAUSE) { |
343 mciSendCommand(cdrom->id,MCI_RESUME,0,&mgp, 0); | 384 mgp.hwndCallback = (HWND) NULL; // None |
344 } | 385 mciSendCommand (cdrom->id, MCI_RESUME, 0, &mgp, 0); |
345 } | 386 } |
387 } | |
346 /* Now stops the media */ | 388 /* Now stops the media */ |
347 mgp.hwndCallback = (HWND)NULL; // None | 389 mgp.hwndCallback = (HWND) NULL; // None |
348 if (LOUSHORT(mciSendCommand(cdrom->id,MCI_STOP,MCI_WAIT,&mgp, 0)) == MCIERR_SUCCESS) return 0; | 390 if (LOUSHORT (mciSendCommand (cdrom->id, MCI_STOP, MCI_WAIT, &mgp, 0)) == |
349 return(CD_ERROR); | 391 MCIERR_SUCCESS) |
392 return 0; | |
393 return (CD_ERROR); | |
350 } | 394 } |
351 | 395 |
352 /* Eject the CD-ROM - Ready for MCI */ | 396 /* Eject the CD-ROM - Ready for MCI */ |
353 static int SDL_SYS_CDEject(SDL_CD *cdrom) | 397 static int |
354 { | 398 SDL_SYS_CDEject (SDL_CD * cdrom) |
355 MCI_SET_PARMS msp; | 399 { |
356 | 400 MCI_SET_PARMS msp; |
357 msp.hwndCallback = (HWND)NULL; // None | 401 |
358 msp.ulTimeFormat = (ULONG)NULL; // No change | 402 msp.hwndCallback = (HWND) NULL; // None |
359 msp.ulSpeedFormat = (ULONG)NULL; // No change | 403 msp.ulTimeFormat = (ULONG) NULL; // No change |
360 msp.ulAudio = (ULONG)NULL; // No Channel | 404 msp.ulSpeedFormat = (ULONG) NULL; // No change |
361 msp.ulLevel = (ULONG)NULL; // No Volume | 405 msp.ulAudio = (ULONG) NULL; // No Channel |
362 msp.ulOver = (ULONG)NULL; // No Delay | 406 msp.ulLevel = (ULONG) NULL; // No Volume |
363 msp.ulItem = (ULONG)NULL; // No item | 407 msp.ulOver = (ULONG) NULL; // No Delay |
364 msp.ulValue = (ULONG)NULL; // No value for item flag | 408 msp.ulItem = (ULONG) NULL; // No item |
365 if (LOUSHORT(mciSendCommand(cdrom->id,MCI_SET,MCI_WAIT | MCI_SET_DOOR_OPEN,&msp, 0)) == MCIERR_SUCCESS) return 0; | 409 msp.ulValue = (ULONG) NULL; // No value for item flag |
366 return(CD_ERROR); | 410 if (LOUSHORT |
411 (mciSendCommand | |
412 (cdrom->id, MCI_SET, MCI_WAIT | MCI_SET_DOOR_OPEN, &msp, | |
413 0)) == MCIERR_SUCCESS) | |
414 return 0; | |
415 return (CD_ERROR); | |
367 } | 416 } |
368 | 417 |
369 /* Close the CD-ROM handle - Ready for MCI */ | 418 /* Close the CD-ROM handle - Ready for MCI */ |
370 static void SDL_SYS_CDClose(SDL_CD *cdrom) | 419 static void |
371 { | 420 SDL_SYS_CDClose (SDL_CD * cdrom) |
372 MCI_GENERIC_PARMS mgp; | 421 { |
373 | 422 MCI_GENERIC_PARMS mgp; |
374 mgp.hwndCallback = (HWND)NULL; // None | 423 |
375 mciSendCommand(cdrom->id,MCI_CLOSE,MCI_WAIT,&mgp, 0); | 424 mgp.hwndCallback = (HWND) NULL; // None |
425 mciSendCommand (cdrom->id, MCI_CLOSE, MCI_WAIT, &mgp, 0); | |
376 } | 426 } |
377 | 427 |
378 /* Finalize CDROM Subsystem - Ready for MCI */ | 428 /* Finalize CDROM Subsystem - Ready for MCI */ |
379 void SDL_SYS_CDQuit(void) | 429 void |
380 { | 430 SDL_SYS_CDQuit (void) |
381 int i; | 431 { |
382 | 432 int i; |
383 if ( SDL_numcds > 0 ) | 433 |
384 { | 434 if (SDL_numcds > 0) { |
385 for ( i=0; i<SDL_numcds; ++i ) | 435 for (i = 0; i < SDL_numcds; ++i) { |
386 { | 436 SDL_free (SDL_cdlist[i]); |
387 SDL_free(SDL_cdlist[i]); | 437 } |
388 } | 438 SDL_numcds = 0; |
389 SDL_numcds = 0; | 439 } |
390 } | |
391 } | 440 } |
392 | 441 |
393 #endif /* SDL_CDROM_OS2 */ | 442 #endif /* SDL_CDROM_OS2 */ |
443 /* vi: set ts=4 sw=4 expandtab: */ |