Mercurial > sdl-ios-xcode
comparison src/cdrom/os2/SDL_syscdrom.c @ 1336:3692456e7b0f
Use SDL_ prefixed versions of C library functions.
FIXME:
Change #include <stdlib.h> to #include "SDL_stdlib.h"
Change #include <string.h> to #include "SDL_string.h"
Make sure nothing else broke because of this...
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 07 Feb 2006 06:59:48 +0000 |
parents | c9b51268668f |
children | 604d73db6802 |
comparison
equal
deleted
inserted
replaced
1335:c39265384763 | 1336:3692456e7b0f |
---|---|
79 SDL_CDcaps.Eject = SDL_SYS_CDEject; | 79 SDL_CDcaps.Eject = SDL_SYS_CDEject; |
80 SDL_CDcaps.Close = SDL_SYS_CDClose; | 80 SDL_CDcaps.Close = SDL_SYS_CDClose; |
81 | 81 |
82 /* Get the number of CD ROMs in the System */ | 82 /* Get the number of CD ROMs in the System */ |
83 /* Clean SysInfo structure */ | 83 /* Clean SysInfo structure */ |
84 memset(&msp, 0x00, sizeof(MCI_SYSINFO_PARMS)); | 84 SDL_memset(&msp, 0x00, sizeof(MCI_SYSINFO_PARMS)); |
85 /* Prepare structure to Ask Numer of Audio CDs */ | 85 /* Prepare structure to Ask Numer of Audio CDs */ |
86 msp.usDeviceType = MCI_DEVTYPE_CD_AUDIO; /* CD Audio Type */ | 86 msp.usDeviceType = MCI_DEVTYPE_CD_AUDIO; /* CD Audio Type */ |
87 msp.pszReturn = (PSZ)&SysInfoRet; /* Return Structure */ | 87 msp.pszReturn = (PSZ)&SysInfoRet; /* Return Structure */ |
88 msp.ulRetSize = MCI_CMDRETBUFSIZE; /* Size of ret struct */ | 88 msp.ulRetSize = MCI_CMDRETBUFSIZE; /* Size of ret struct */ |
89 if (LOUSHORT(mciSendCommand(0,MCI_SYSINFO, MCI_SYSINFO_QUANTITY | MCI_WAIT, (PVOID)&msp, 0)) != MCIERR_SUCCESS) return(CD_ERROR); | 89 if (LOUSHORT(mciSendCommand(0,MCI_SYSINFO, MCI_SYSINFO_QUANTITY | MCI_WAIT, (PVOID)&msp, 0)) != MCIERR_SUCCESS) return(CD_ERROR); |
96 msp.usDeviceType = MCI_DEVTYPE_CD_AUDIO; /* CD Audio Type */ | 96 msp.usDeviceType = MCI_DEVTYPE_CD_AUDIO; /* CD Audio Type */ |
97 for (i=0; i<SDL_numcds; i++) | 97 for (i=0; i<SDL_numcds; i++) |
98 { | 98 { |
99 msp.ulNumber = i+1; | 99 msp.ulNumber = i+1; |
100 mciSendCommand(0,MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_WAIT,&msp, 0); | 100 mciSendCommand(0,MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_WAIT,&msp, 0); |
101 SDL_cdlist[i] = (char *)malloc(strlen(SysInfoRet)+1); | 101 SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(SysInfoRet)+1); |
102 if ( SDL_cdlist[i] == NULL ) | 102 if ( SDL_cdlist[i] == NULL ) |
103 { | 103 { |
104 SDL_OutOfMemory(); | 104 SDL_OutOfMemory(); |
105 return(-1); | 105 return(-1); |
106 } | 106 } |
107 strcpy(SDL_cdlist[i], SysInfoRet); | 107 SDL_strcpy(SDL_cdlist[i], SysInfoRet); |
108 } | 108 } |
109 return(0); | 109 return(0); |
110 } | 110 } |
111 | 111 |
112 /* Return CDAudio System Dependent Device Name - Ready for MCI*/ | 112 /* Return CDAudio System Dependent Device Name - Ready for MCI*/ |
164 if ( cdrom->numtracks > SDL_MAX_TRACKS ) | 164 if ( cdrom->numtracks > SDL_MAX_TRACKS ) |
165 { | 165 { |
166 cdrom->numtracks = SDL_MAX_TRACKS; | 166 cdrom->numtracks = SDL_MAX_TRACKS; |
167 } | 167 } |
168 /* Alocate space for TOC data */ | 168 /* Alocate space for TOC data */ |
169 mtr = (MCI_TOC_REC *)malloc(cdrom->numtracks*sizeof(MCI_TOC_REC)); | 169 mtr = (MCI_TOC_REC *)SDL_malloc(cdrom->numtracks*sizeof(MCI_TOC_REC)); |
170 if ( mtr == NULL ) | 170 if ( mtr == NULL ) |
171 { | 171 { |
172 SDL_OutOfMemory(); | 172 SDL_OutOfMemory(); |
173 return(-1); | 173 return(-1); |
174 } | 174 } |
176 mtp.pBuf = mtr; | 176 mtp.pBuf = mtr; |
177 mtp.ulBufSize = cdrom->numtracks*sizeof(MCI_TOC_REC); | 177 mtp.ulBufSize = cdrom->numtracks*sizeof(MCI_TOC_REC); |
178 if (LOUSHORT(mciSendCommand(cdrom->id,MCI_GETTOC,MCI_WAIT,&mtp, 0)) != MCIERR_SUCCESS) | 178 if (LOUSHORT(mciSendCommand(cdrom->id,MCI_GETTOC,MCI_WAIT,&mtp, 0)) != MCIERR_SUCCESS) |
179 { | 179 { |
180 SDL_OutOfMemory(); | 180 SDL_OutOfMemory(); |
181 free(mtr); | 181 SDL_free(mtr); |
182 return(CD_ERROR); | 182 return(CD_ERROR); |
183 } | 183 } |
184 /* Fill SDL Tracks Structure */ | 184 /* Fill SDL Tracks Structure */ |
185 for (i=0; i<cdrom->numtracks; i++) | 185 for (i=0; i<cdrom->numtracks; i++) |
186 { | 186 { |
191 msp.ulReturn = (ULONG)NULL; /* We want this information */ | 191 msp.ulReturn = (ULONG)NULL; /* We want this information */ |
192 msp.ulItem = MCI_CD_STATUS_TRACK_TYPE; | 192 msp.ulItem = MCI_CD_STATUS_TRACK_TYPE; |
193 msp.ulValue = (ULONG)((mtr+i)->TrackNum); /* Track Number? */ | 193 msp.ulValue = (ULONG)((mtr+i)->TrackNum); /* Track Number? */ |
194 if (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_TRACK | MCI_STATUS_ITEM,&msp, 0)) != MCIERR_SUCCESS) | 194 if (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_TRACK | MCI_STATUS_ITEM,&msp, 0)) != MCIERR_SUCCESS) |
195 { | 195 { |
196 free(mtr); | 196 SDL_free(mtr); |
197 return (CD_ERROR); | 197 return (CD_ERROR); |
198 } | 198 } |
199 if (msp.ulReturn==MCI_CD_TRACK_AUDIO) cdrom->track[i].type = SDL_AUDIO_TRACK; | 199 if (msp.ulReturn==MCI_CD_TRACK_AUDIO) cdrom->track[i].type = SDL_AUDIO_TRACK; |
200 else cdrom->track[i].type = SDL_DATA_TRACK; | 200 else cdrom->track[i].type = SDL_DATA_TRACK; |
201 /* Set Track Length - values from MCI are in MMTIMEs - 3000 MMTIME = 1 second */ | 201 /* Set Track Length - values from MCI are in MMTIMEs - 3000 MMTIME = 1 second */ |
202 cdrom->track[i].length = FRAMESFROMMM((mtr+i)->ulEndAddr - (mtr+i)->ulStartAddr); | 202 cdrom->track[i].length = FRAMESFROMMM((mtr+i)->ulEndAddr - (mtr+i)->ulStartAddr); |
203 /* Set Track Offset */ | 203 /* Set Track Offset */ |
204 cdrom->track[i].offset = FRAMESFROMMM((mtr+i)->ulStartAddr); | 204 cdrom->track[i].offset = FRAMESFROMMM((mtr+i)->ulStartAddr); |
205 } | 205 } |
206 free(mtr); | 206 SDL_free(mtr); |
207 return(0); | 207 return(0); |
208 } | 208 } |
209 | 209 |
210 | 210 |
211 /* Get CD-ROM status - Ready for MCI */ | 211 /* Get CD-ROM status - Ready for MCI */ |
384 | 384 |
385 if ( SDL_numcds > 0 ) | 385 if ( SDL_numcds > 0 ) |
386 { | 386 { |
387 for ( i=0; i<SDL_numcds; ++i ) | 387 for ( i=0; i<SDL_numcds; ++i ) |
388 { | 388 { |
389 free(SDL_cdlist[i]); | 389 SDL_free(SDL_cdlist[i]); |
390 } | 390 } |
391 SDL_numcds = 0; | 391 SDL_numcds = 0; |
392 } | 392 } |
393 } | 393 } |
394 | 394 |