Home | History | Annotate | Download | only in html
      1 <HTML
      2 ><HEAD
      3 ><TITLE
      4 >SDL_CDStatus</TITLE
      5 ><META
      6 NAME="GENERATOR"
      7 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
      8 "><LINK
      9 REL="HOME"
     10 TITLE="SDL Library Documentation"
     11 HREF="index.html"><LINK
     12 REL="UP"
     13 TITLE="CD-ROM"
     14 HREF="cdrom.html"><LINK
     15 REL="PREVIOUS"
     16 TITLE="SDL_CDOpen"
     17 HREF="sdlcdopen.html"><LINK
     18 REL="NEXT"
     19 TITLE="SDL_CDPlay"
     20 HREF="sdlcdplay.html"></HEAD
     21 ><BODY
     22 CLASS="REFENTRY"
     23 BGCOLOR="#FFF8DC"
     24 TEXT="#000000"
     25 LINK="#0000ee"
     26 VLINK="#551a8b"
     27 ALINK="#ff0000"
     28 ><DIV
     29 CLASS="NAVHEADER"
     30 ><TABLE
     31 SUMMARY="Header navigation table"
     32 WIDTH="100%"
     33 BORDER="0"
     34 CELLPADDING="0"
     35 CELLSPACING="0"
     36 ><TR
     37 ><TH
     38 COLSPAN="3"
     39 ALIGN="center"
     40 >SDL Library Documentation</TH
     41 ></TR
     42 ><TR
     43 ><TD
     44 WIDTH="10%"
     45 ALIGN="left"
     46 VALIGN="bottom"
     47 ><A
     48 HREF="sdlcdopen.html"
     49 ACCESSKEY="P"
     50 >Prev</A
     51 ></TD
     52 ><TD
     53 WIDTH="80%"
     54 ALIGN="center"
     55 VALIGN="bottom"
     56 ></TD
     57 ><TD
     58 WIDTH="10%"
     59 ALIGN="right"
     60 VALIGN="bottom"
     61 ><A
     62 HREF="sdlcdplay.html"
     63 ACCESSKEY="N"
     64 >Next</A
     65 ></TD
     66 ></TR
     67 ></TABLE
     68 ><HR
     69 ALIGN="LEFT"
     70 WIDTH="100%"></DIV
     71 ><H1
     72 ><A
     73 NAME="SDLCDSTATUS"
     74 ></A
     75 >SDL_CDStatus</H1
     76 ><DIV
     77 CLASS="REFNAMEDIV"
     78 ><A
     79 NAME="AEN7308"
     80 ></A
     81 ><H2
     82 >Name</H2
     83 >SDL_CDStatus&nbsp;--&nbsp;Returns the current status of the given drive.</DIV
     84 ><DIV
     85 CLASS="REFSYNOPSISDIV"
     86 ><A
     87 NAME="AEN7311"
     88 ></A
     89 ><H2
     90 >Synopsis</H2
     91 ><DIV
     92 CLASS="FUNCSYNOPSIS"
     93 ><A
     94 NAME="AEN7312"
     95 ></A
     96 ><P
     97 ></P
     98 ><PRE
     99 CLASS="FUNCSYNOPSISINFO"
    100 >#include "SDL.h"</PRE
    101 ><P
    102 ><CODE
    103 ><CODE
    104 CLASS="FUNCDEF"
    105 >CDstatus <B
    106 CLASS="FSFUNC"
    107 >SDL_CDStatus</B
    108 ></CODE
    109 >(SDL_CD *cdrom);</CODE
    110 ></P
    111 ><PRE
    112 CLASS="FUNCSYNOPSISINFO"
    113 >/* Given a status, returns true if there's a disk in the drive */
    114 #define CD_INDRIVE(status)      ((int)status &#62; 0)</PRE
    115 ><P
    116 ></P
    117 ></DIV
    118 ></DIV
    119 ><DIV
    120 CLASS="REFSECT1"
    121 ><A
    122 NAME="AEN7319"
    123 ></A
    124 ><H2
    125 >Description</H2
    126 ><P
    127 >This function returns the current status of the given drive. Status is described like so:
    128 <PRE
    129 CLASS="PROGRAMLISTING"
    130 >typedef enum {
    131   CD_TRAYEMPTY,
    132   CD_STOPPED,
    133   CD_PLAYING,
    134   CD_PAUSED,
    135   CD_ERROR = -1
    136 } CDstatus;</PRE
    137 ></P
    138 ><P
    139 >If the drive has a CD in it, the table of contents of the CD and current
    140 play position of the CD will be stored in the SDL_CD structure.</P
    141 ><P
    142 >The macro <TT
    143 CLASS="LITERAL"
    144 >CD_INDRIVE</TT
    145 > is provided for convenience, 
    146 and given a status returns true if there's a disk in the drive.</P
    147 ><DIV
    148 CLASS="NOTE"
    149 ><BLOCKQUOTE
    150 CLASS="NOTE"
    151 ><P
    152 ><B
    153 >Note: </B
    154 ><TT
    155 CLASS="FUNCTION"
    156 >SDL_CDStatus</TT
    157 > also updates the <A
    158 HREF="sdlcd.html"
    159 ><SPAN
    160 CLASS="STRUCTNAME"
    161 >SDL_CD</SPAN
    162 ></A
    163 > structure passed to it.</P
    164 ></BLOCKQUOTE
    165 ></DIV
    166 ></DIV
    167 ><DIV
    168 CLASS="REFSECT1"
    169 ><A
    170 NAME="AEN7331"
    171 ></A
    172 ><H2
    173 >Example</H2
    174 ><PRE
    175 CLASS="PROGRAMLISTING"
    176 >int playTrack(int track)
    177 {
    178   int playing = 0;
    179 
    180   if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) {
    181   /* clamp to the actual number of tracks on the CD */
    182     if (track &#62;= cdrom-&#62;numtracks) {
    183       track = cdrom-&#62;numtracks-1;
    184     }
    185 
    186     if ( SDL_CDPlayTracks(cdrom, track, 0, 1, 0) == 0 ) {
    187       playing = 1;
    188     }
    189   }
    190   return playing;
    191 }</PRE
    192 ></DIV
    193 ><DIV
    194 CLASS="REFSECT1"
    195 ><A
    196 NAME="AEN7334"
    197 ></A
    198 ><H2
    199 >See Also</H2
    200 ><P
    201 ><A
    202 HREF="sdlcd.html"
    203 ><TT
    204 CLASS="FUNCTION"
    205 >SDL_CD</TT
    206 ></A
    207 ></P
    208 ></DIV
    209 ><DIV
    210 CLASS="NAVFOOTER"
    211 ><HR
    212 ALIGN="LEFT"
    213 WIDTH="100%"><TABLE
    214 SUMMARY="Footer navigation table"
    215 WIDTH="100%"
    216 BORDER="0"
    217 CELLPADDING="0"
    218 CELLSPACING="0"
    219 ><TR
    220 ><TD
    221 WIDTH="33%"
    222 ALIGN="left"
    223 VALIGN="top"
    224 ><A
    225 HREF="sdlcdopen.html"
    226 ACCESSKEY="P"
    227 >Prev</A
    228 ></TD
    229 ><TD
    230 WIDTH="34%"
    231 ALIGN="center"
    232 VALIGN="top"
    233 ><A
    234 HREF="index.html"
    235 ACCESSKEY="H"
    236 >Home</A
    237 ></TD
    238 ><TD
    239 WIDTH="33%"
    240 ALIGN="right"
    241 VALIGN="top"
    242 ><A
    243 HREF="sdlcdplay.html"
    244 ACCESSKEY="N"
    245 >Next</A
    246 ></TD
    247 ></TR
    248 ><TR
    249 ><TD
    250 WIDTH="33%"
    251 ALIGN="left"
    252 VALIGN="top"
    253 >SDL_CDOpen</TD
    254 ><TD
    255 WIDTH="34%"
    256 ALIGN="center"
    257 VALIGN="top"
    258 ><A
    259 HREF="cdrom.html"
    260 ACCESSKEY="U"
    261 >Up</A
    262 ></TD
    263 ><TD
    264 WIDTH="33%"
    265 ALIGN="right"
    266 VALIGN="top"
    267 >SDL_CDPlay</TD
    268 ></TR
    269 ></TABLE
    270 ></DIV
    271 ></BODY
    272 ></HTML
    273 >