comparison src/cdrom/macos/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 19418e4422cb
comparison
equal deleted inserted replaced
1335:c39265384763 1336:3692456e7b0f
158 CDCntrlParam cdpb; 158 CDCntrlParam cdpb;
159 CDTrackData tracks[SDL_MAX_TRACKS]; 159 CDTrackData tracks[SDL_MAX_TRACKS];
160 long i, leadout; 160 long i, leadout;
161 161
162 /* Get the number of tracks on the CD by examining the TOC */ 162 /* Get the number of tracks on the CD by examining the TOC */
163 memset(&cdpb, 0, sizeof(cdpb)); 163 SDL_memset(&cdpb, 0, sizeof(cdpb));
164 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; 164 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
165 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; 165 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
166 cdpb.csCode = kReadTOC; 166 cdpb.csCode = kReadTOC;
167 cdpb.csParam.words[0] = kGetTrackRange; 167 cdpb.csParam.words[0] = kGetTrackRange;
168 if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) { 168 if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) {
179 cdrom->cur_track = 0; /* Apparently these are set elsewhere */ 179 cdrom->cur_track = 0; /* Apparently these are set elsewhere */
180 cdrom->cur_frame = 0; /* Apparently these are set elsewhere */ 180 cdrom->cur_frame = 0; /* Apparently these are set elsewhere */
181 181
182 182
183 /* Get the lead out area of the CD by examining the TOC */ 183 /* Get the lead out area of the CD by examining the TOC */
184 memset(&cdpb, 0, sizeof(cdpb)); 184 SDL_memset(&cdpb, 0, sizeof(cdpb));
185 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; 185 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
186 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; 186 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
187 cdpb.csCode = kReadTOC; 187 cdpb.csCode = kReadTOC;
188 cdpb.csParam.words[0] = kGetLeadOutArea; 188 cdpb.csParam.words[0] = kGetLeadOutArea;
189 if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) { 189 if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) {
195 SDL_SYS_BCDToShort(cdpb.csParam.bytes[0]), 195 SDL_SYS_BCDToShort(cdpb.csParam.bytes[0]),
196 SDL_SYS_BCDToShort(cdpb.csParam.bytes[1]), 196 SDL_SYS_BCDToShort(cdpb.csParam.bytes[1]),
197 SDL_SYS_BCDToShort(cdpb.csParam.bytes[2])); 197 SDL_SYS_BCDToShort(cdpb.csParam.bytes[2]));
198 198
199 /* Get an array of track locations by examining the TOC */ 199 /* Get an array of track locations by examining the TOC */
200 memset(tracks, 0, sizeof(tracks)); 200 SDL_memset(tracks, 0, sizeof(tracks));
201 memset(&cdpb, 0, sizeof(cdpb)); 201 SDL_memset(&cdpb, 0, sizeof(cdpb));
202 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; 202 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
203 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; 203 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
204 cdpb.csCode = kReadTOC; 204 cdpb.csCode = kReadTOC;
205 cdpb.csParam.words[0] = kGetTrackEntries; /* Type of Query */ 205 cdpb.csParam.words[0] = kGetTrackEntries; /* Type of Query */
206 * ((long *) (cdpb.csParam.words+1)) = (long) tracks; 206 * ((long *) (cdpb.csParam.words+1)) = (long) tracks;
253 253
254 /* Get the number of tracks on the CD by examining the TOC */ 254 /* Get the number of tracks on the CD by examining the TOC */
255 if ( ! get_drivenum(cdrom->id) ) { 255 if ( ! get_drivenum(cdrom->id) ) {
256 return(CD_TRAYEMPTY); 256 return(CD_TRAYEMPTY);
257 } 257 }
258 memset(&cdpb, 0, sizeof(cdpb)); 258 SDL_memset(&cdpb, 0, sizeof(cdpb));
259 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; 259 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
260 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; 260 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
261 cdpb.csCode = kReadTOC; 261 cdpb.csCode = kReadTOC;
262 cdpb.csParam.words[0] = kGetTrackRange; 262 cdpb.csParam.words[0] = kGetTrackRange;
263 if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) { 263 if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) {
274 cdrom->cur_frame = 0; /* Apparently these are set elsewhere */ 274 cdrom->cur_frame = 0; /* Apparently these are set elsewhere */
275 275
276 276
277 if (1 || SDL_cdlist[cdrom->id].hasAudio) { 277 if (1 || SDL_cdlist[cdrom->id].hasAudio) {
278 /* Get the current playback status */ 278 /* Get the current playback status */
279 memset(&cdpb, 0, sizeof(cdpb)); 279 SDL_memset(&cdpb, 0, sizeof(cdpb));
280 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; 280 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
281 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; 281 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
282 cdpb.csCode = kAudioStatus; 282 cdpb.csCode = kAudioStatus;
283 if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) { 283 if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) {
284 SDL_SetError("PBControlSync() failed"); 284 SDL_SetError("PBControlSync() failed");
333 if ( SDL_SYS_CDPause(cdrom) < 0 ) { 333 if ( SDL_SYS_CDPause(cdrom) < 0 ) {
334 return(-1); 334 return(-1);
335 } 335 }
336 336
337 /* Specify the AudioCD playback mode */ 337 /* Specify the AudioCD playback mode */
338 memset(&cdpb, 0, sizeof(cdpb)); 338 SDL_memset(&cdpb, 0, sizeof(cdpb));
339 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; 339 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
340 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; 340 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
341 cdpb.csCode = kSetPlayMode; 341 cdpb.csCode = kSetPlayMode;
342 cdpb.csParam.bytes[0] = false; /* Repeat? */ 342 cdpb.csParam.bytes[0] = false; /* Repeat? */
343 cdpb.csParam.bytes[1] = kPlayModeSequential; /* Play mode */ 343 cdpb.csParam.bytes[1] = kPlayModeSequential; /* Play mode */
344 /* ¥¥¥ÊTreat as soft error, NEC Drive doesnt support this call ¥¥¥ */ 344 /* ¥¥¥ÊTreat as soft error, NEC Drive doesnt support this call ¥¥¥ */
345 PBControlSync((ParmBlkPtr) &cdpb); 345 PBControlSync((ParmBlkPtr) &cdpb);
346 346
347 #if 1 347 #if 1
348 /* Specify the end of audio playback */ 348 /* Specify the end of audio playback */
349 memset(&cdpb, 0, sizeof(cdpb)); 349 SDL_memset(&cdpb, 0, sizeof(cdpb));
350 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; 350 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
351 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; 351 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
352 cdpb.csCode = kAudioStop; 352 cdpb.csCode = kAudioStop;
353 cdpb.csParam.words[0] = kBlockPosition; /* Position Mode */ 353 cdpb.csParam.words[0] = kBlockPosition; /* Position Mode */
354 *(long *) (cdpb.csParam.words + 1) = start+length-1; /* Search Address */ 354 *(long *) (cdpb.csParam.words + 1) = start+length-1; /* Search Address */
356 SDL_SetError("PBControlSync() failed"); 356 SDL_SetError("PBControlSync() failed");
357 return(-1); 357 return(-1);
358 } 358 }
359 359
360 /* Specify the start of audio playback, and start it */ 360 /* Specify the start of audio playback, and start it */
361 memset(&cdpb, 0, sizeof(cdpb)); 361 SDL_memset(&cdpb, 0, sizeof(cdpb));
362 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; 362 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
363 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; 363 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
364 cdpb.csCode = kAudioPlay; 364 cdpb.csCode = kAudioPlay;
365 cdpb.csParam.words[0] = kBlockPosition; /* Position Mode */ 365 cdpb.csParam.words[0] = kBlockPosition; /* Position Mode */
366 *(long *) (cdpb.csParam.words + 1) = start+1; /* Search Address */ 366 *(long *) (cdpb.csParam.words + 1) = start+1; /* Search Address */
371 return(-1); 371 return(-1);
372 } 372 }
373 #else 373 #else
374 /* Specify the end of audio playback */ 374 /* Specify the end of audio playback */
375 FRAMES_TO_MSF(start+length, &m, &s, &f); 375 FRAMES_TO_MSF(start+length, &m, &s, &f);
376 memset(&cdpb, 0, sizeof(cdpb)); 376 SDL_memset(&cdpb, 0, sizeof(cdpb));
377 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; 377 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
378 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; 378 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
379 cdpb.csCode = kAudioStop; 379 cdpb.csCode = kAudioStop;
380 cdpb.csParam.words[0] = kTrackPosition; /* Position Mode */ 380 cdpb.csParam.words[0] = kTrackPosition; /* Position Mode */
381 cdpb.csParam.words[1] = 0; /* Search Address (hiword)*/ 381 cdpb.csParam.words[1] = 0; /* Search Address (hiword)*/
386 return(-1); 386 return(-1);
387 } 387 }
388 388
389 /* Specify the start of audio playback, and start it */ 389 /* Specify the start of audio playback, and start it */
390 FRAMES_TO_MSF(start, &m, &s, &f); 390 FRAMES_TO_MSF(start, &m, &s, &f);
391 memset(&cdpb, 0, sizeof(cdpb)); 391 SDL_memset(&cdpb, 0, sizeof(cdpb));
392 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; 392 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
393 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; 393 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
394 cdpb.csCode = kAudioPlay; 394 cdpb.csCode = kAudioPlay;
395 cdpb.csParam.words[0] = kTrackPosition; /* Position Mode */ 395 cdpb.csParam.words[0] = kTrackPosition; /* Position Mode */
396 cdpb.csParam.words[1] = 0; /* Search Address (hiword)*/ 396 cdpb.csParam.words[1] = 0; /* Search Address (hiword)*/
409 /* Pause play */ 409 /* Pause play */
410 static int SDL_SYS_CDPause(SDL_CD *cdrom) 410 static int SDL_SYS_CDPause(SDL_CD *cdrom)
411 { 411 {
412 CDCntrlParam cdpb; 412 CDCntrlParam cdpb;
413 413
414 memset(&cdpb, 0, sizeof(cdpb)); 414 SDL_memset(&cdpb, 0, sizeof(cdpb));
415 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; 415 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
416 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; 416 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
417 cdpb.csCode = kAudioPause; 417 cdpb.csCode = kAudioPause;
418 cdpb.csParam.words[0] = 0; /* Pause/Continue Flag (hiword) */ 418 cdpb.csParam.words[0] = 0; /* Pause/Continue Flag (hiword) */
419 cdpb.csParam.words[1] = 1; /* Pause/Continue Flag (loword) */ 419 cdpb.csParam.words[1] = 1; /* Pause/Continue Flag (loword) */
427 /* Resume play */ 427 /* Resume play */
428 static int SDL_SYS_CDResume(SDL_CD *cdrom) 428 static int SDL_SYS_CDResume(SDL_CD *cdrom)
429 { 429 {
430 CDCntrlParam cdpb; 430 CDCntrlParam cdpb;
431 431
432 memset(&cdpb, 0, sizeof(cdpb)); 432 SDL_memset(&cdpb, 0, sizeof(cdpb));
433 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; 433 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
434 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; 434 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
435 cdpb.csCode = kAudioPause; 435 cdpb.csCode = kAudioPause;
436 cdpb.csParam.words[0] = 0; /* Pause/Continue Flag (hiword) */ 436 cdpb.csParam.words[0] = 0; /* Pause/Continue Flag (hiword) */
437 cdpb.csParam.words[1] = 0; /* Pause/Continue Flag (loword) */ 437 cdpb.csParam.words[1] = 0; /* Pause/Continue Flag (loword) */
445 /* Stop play */ 445 /* Stop play */
446 static int SDL_SYS_CDStop(SDL_CD *cdrom) 446 static int SDL_SYS_CDStop(SDL_CD *cdrom)
447 { 447 {
448 CDCntrlParam cdpb; 448 CDCntrlParam cdpb;
449 449
450 memset(&cdpb, 0, sizeof(cdpb)); 450 SDL_memset(&cdpb, 0, sizeof(cdpb));
451 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; 451 cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
452 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; 452 cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
453 cdpb.csCode = kAudioStop; 453 cdpb.csCode = kAudioStop;
454 cdpb.csParam.words[0] = 0; /* Position Mode */ 454 cdpb.csParam.words[0] = 0; /* Position Mode */
455 cdpb.csParam.words[1] = 0; /* Search Address (hiword) */ 455 cdpb.csParam.words[1] = 0; /* Search Address (hiword) */
479 if ( driveElem->dQRefNum != SDL_cdlist[cdrom->id].dRefNum ) { 479 if ( driveElem->dQRefNum != SDL_cdlist[cdrom->id].dRefNum ) {
480 continue; 480 continue;
481 } 481 }
482 482
483 /* Does drive contain mounted volume? If not, skip */ 483 /* Does drive contain mounted volume? If not, skip */
484 memset(&hpb, 0, sizeof(hpb)); 484 SDL_memset(&hpb, 0, sizeof(hpb));
485 hpb.volumeParam.ioVRefNum = driveElem->dQDrive; 485 hpb.volumeParam.ioVRefNum = driveElem->dQDrive;
486 if ( PBHGetVInfoSync(&hpb) != noErr ) { 486 if ( PBHGetVInfoSync(&hpb) != noErr ) {
487 continue; 487 continue;
488 } 488 }
489 if ( (UnmountVol(0, driveElem->dQDrive) == noErr) && 489 if ( (UnmountVol(0, driveElem->dQDrive) == noErr) &&
493 } 493 }
494 } 494 }
495 495
496 /* If no disk is present, just eject the tray */ 496 /* If no disk is present, just eject the tray */
497 if (! disk) { 497 if (! disk) {
498 memset(&cpb, 0, sizeof(cpb)); 498 SDL_memset(&cpb, 0, sizeof(cpb));
499 cpb.cntrlParam.ioVRefNum = 0; /* No Drive */ 499 cpb.cntrlParam.ioVRefNum = 0; /* No Drive */
500 cpb.cntrlParam.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; 500 cpb.cntrlParam.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
501 cpb.cntrlParam.csCode = kEjectTheDisc; 501 cpb.cntrlParam.csCode = kEjectTheDisc;
502 if ( PBControlSync((ParmBlkPtr)&cpb) != noErr ) { 502 if ( PBControlSync((ParmBlkPtr)&cpb) != noErr ) {
503 SDL_SetError("PBControlSync() failed"); 503 SDL_SetError("PBControlSync() failed");
514 } 514 }
515 515
516 void SDL_SYS_CDQuit(void) 516 void SDL_SYS_CDQuit(void)
517 { 517 {
518 while(SDL_numcds--) 518 while(SDL_numcds--)
519 memset(SDL_cdlist + SDL_numcds, 0, sizeof(SDL_cdlist[0])); 519 SDL_memset(SDL_cdlist + SDL_numcds, 0, sizeof(SDL_cdlist[0]));
520 } 520 }
521 521