docs/man3/SDL_CDOpen.3
author Sam Lantinga <slouken@libsdl.org>
Wed, 08 Mar 2006 18:30:12 +0000
changeset 1486 9d77fc9d0ace
parent 181 e5bc29de3f0a
child 2283 546f7c1eb755
permissions -rw-r--r--
Re-added C runtime support for Visual C++ 5,6
slouken@181
     1
.TH "SDL_CDOpen" "3" "Tue 11 Sep 2001, 22:58" "SDL" "SDL API Reference" 
slouken@0
     2
.SH "NAME"
slouken@0
     3
SDL_CDOpen\- Opens a CD-ROM drive for access\&.
slouken@0
     4
.SH "SYNOPSIS"
slouken@0
     5
.PP
slouken@0
     6
\fB#include "SDL\&.h"
slouken@0
     7
.sp
slouken@0
     8
\fBSDL_CD *\fBSDL_CDOpen\fP\fR(\fBint drive\fR);
slouken@0
     9
.SH "DESCRIPTION"
slouken@0
    10
.PP
slouken@0
    11
Opens a CD-ROM drive for access\&. It returns a \fI\fBSDL_CD\fR\fR structure on success, or \fBNULL\fP if the drive was invalid or busy\&. This newly opened CD-ROM becomes the default CD used when other CD functions are passed a \fBNULL\fP CD-ROM handle\&. 
slouken@0
    12
.PP
slouken@0
    13
Drives are numbered starting with 0\&. Drive 0 is the system default CD-ROM\&.
slouken@0
    14
.SH "EXAMPLES"
slouken@0
    15
.PP
slouken@0
    16
.nf
slouken@0
    17
\f(CWSDL_CD *cdrom;
slouken@0
    18
int cur_track;
slouken@0
    19
int min, sec, frame;
slouken@0
    20
SDL_Init(SDL_INIT_CDROM);
slouken@0
    21
atexit(SDL_Quit);
slouken@0
    22
slouken@0
    23
/* Check for CD drives */
slouken@0
    24
if(!SDL_CDNumDrives()){
slouken@0
    25
  /* None found */
slouken@0
    26
  fprintf(stderr, "No CDROM devices available
slouken@0
    27
");
slouken@0
    28
  exit(-1);
slouken@0
    29
}
slouken@0
    30
slouken@0
    31
/* Open the default drive */
slouken@0
    32
cdrom=SDL_CDOpen(0);
slouken@0
    33
slouken@0
    34
/* Did if open? Check if cdrom is NULL */
slouken@0
    35
if(!cdrom){
slouken@0
    36
  fprintf(stderr, "Couldn\&'t open drive: %s
slouken@0
    37
", SDL_GetError());
slouken@0
    38
  exit(-1);
slouken@0
    39
}
slouken@0
    40
slouken@0
    41
/* Print Volume info */
slouken@0
    42
printf("Name: %s
slouken@0
    43
", SDL_CDName(0));
slouken@0
    44
printf("Tracks: %d
slouken@0
    45
", cdrom->numtracks);
slouken@0
    46
for(cur_track=0;cur_track < cdrom->numtracks; cur_track++){
slouken@0
    47
  FRAMES_TO_MSF(cdrom->track[cur_track]\&.length, &min, &sec, &frame);
slouken@0
    48
  printf("	Track %d: Length %d:%d
slouken@0
    49
", cur_track, min, sec);
slouken@0
    50
}
slouken@0
    51
slouken@0
    52
SDL_CDClose(cdrom);\fR
slouken@0
    53
.fi
slouken@0
    54
.PP
slouken@0
    55
.SH "SEE ALSO"
slouken@0
    56
.PP
slouken@0
    57
\fI\fBSDL_CD\fR\fR, \fI\fBSDL_CDtrack\fR\fR, \fI\fBSDL_CDClose\fP\fR
slouken@181
    58
...\" created by instant / docbook-to-man, Tue 11 Sep 2001, 22:58