src/cdrom/os2/SDL_syscdrom.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/src/cdrom/os2/SDL_syscdrom.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/cdrom/os2/SDL_syscdrom.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -43,16 +43,16 @@
     1.4  //static dev_t SDL_cdmode[MAX_DRIVES];
     1.5  
     1.6  /* The system-dependent CD control functions */
     1.7 -static const char *SDL_SYS_CDName (int drive);
     1.8 -static int SDL_SYS_CDOpen (int drive);
     1.9 -static int SDL_SYS_CDGetTOC (SDL_CD * cdrom);
    1.10 -static CDstatus SDL_SYS_CDStatus (SDL_CD * cdrom, int *position);
    1.11 -static int SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length);
    1.12 -static int SDL_SYS_CDPause (SDL_CD * cdrom);
    1.13 -static int SDL_SYS_CDResume (SDL_CD * cdrom);
    1.14 -static int SDL_SYS_CDStop (SDL_CD * cdrom);
    1.15 -static int SDL_SYS_CDEject (SDL_CD * cdrom);
    1.16 -static void SDL_SYS_CDClose (SDL_CD * cdrom);
    1.17 +static const char *SDL_SYS_CDName(int drive);
    1.18 +static int SDL_SYS_CDOpen(int drive);
    1.19 +static int SDL_SYS_CDGetTOC(SDL_CD * cdrom);
    1.20 +static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position);
    1.21 +static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length);
    1.22 +static int SDL_SYS_CDPause(SDL_CD * cdrom);
    1.23 +static int SDL_SYS_CDResume(SDL_CD * cdrom);
    1.24 +static int SDL_SYS_CDStop(SDL_CD * cdrom);
    1.25 +static int SDL_SYS_CDEject(SDL_CD * cdrom);
    1.26 +static void SDL_SYS_CDClose(SDL_CD * cdrom);
    1.27  
    1.28  /* MCI Timing Functions */
    1.29  #define	MCI_MMTIMEPERSECOND		3000
    1.30 @@ -61,7 +61,7 @@
    1.31  
    1.32  /* Ready for MCI CDAudio Devices */
    1.33  int
    1.34 -SDL_SYS_CDInit (void)
    1.35 +SDL_SYS_CDInit(void)
    1.36  {
    1.37      int i;                      /* generig counter */
    1.38      MCI_SYSINFO_PARMS msp;      /* Structure to MCI SysInfo parameters */
    1.39 @@ -81,7 +81,7 @@
    1.40  
    1.41  /* Get the number of CD ROMs in the System */
    1.42  /* Clean SysInfo structure */
    1.43 -    SDL_memset (&msp, 0x00, sizeof (MCI_SYSINFO_PARMS));
    1.44 +    SDL_memset(&msp, 0x00, sizeof(MCI_SYSINFO_PARMS));
    1.45  /* Prepare structure to Ask Numer of Audio CDs */
    1.46      msp.usDeviceType = MCI_DEVTYPE_CD_AUDIO;    /* CD Audio Type */
    1.47      msp.pszReturn = (PSZ) & SysInfoRet; /* Return Structure */
    1.48 @@ -91,7 +91,7 @@
    1.49           (0, MCI_SYSINFO, MCI_SYSINFO_QUANTITY | MCI_WAIT, (PVOID) & msp,
    1.50            0)) != MCIERR_SUCCESS)
    1.51          return (CD_ERROR);
    1.52 -    SDL_numcds = atoi (SysInfoRet);
    1.53 +    SDL_numcds = atoi(SysInfoRet);
    1.54      if (SDL_numcds > MAX_DRIVES)
    1.55          SDL_numcds = MAX_DRIVES;        /* Limit maximum CD number */
    1.56  
    1.57 @@ -101,10 +101,10 @@
    1.58      msp.usDeviceType = MCI_DEVTYPE_CD_AUDIO;    /* CD Audio Type */
    1.59      for (i = 0; i < SDL_numcds; i++) {
    1.60          msp.ulNumber = i + 1;
    1.61 -        mciSendCommand (0, MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_WAIT, &msp, 0);
    1.62 -        SDL_cdlist[i] = SDL_strdup (SysInfoRet);
    1.63 +        mciSendCommand(0, MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_WAIT, &msp, 0);
    1.64 +        SDL_cdlist[i] = SDL_strdup(SysInfoRet);
    1.65          if (SDL_cdlist[i] == NULL) {
    1.66 -            SDL_OutOfMemory ();
    1.67 +            SDL_OutOfMemory();
    1.68              return (-1);
    1.69          }
    1.70      }
    1.71 @@ -113,14 +113,14 @@
    1.72  
    1.73  /* Return CDAudio System Dependent Device Name - Ready for MCI*/
    1.74  static const char *
    1.75 -SDL_SYS_CDName (int drive)
    1.76 +SDL_SYS_CDName(int drive)
    1.77  {
    1.78      return (SDL_cdlist[drive]);
    1.79  }
    1.80  
    1.81  /* Open CDAudio Device - Ready for MCI */
    1.82  static int
    1.83 -SDL_SYS_CDOpen (int drive)
    1.84 +SDL_SYS_CDOpen(int drive)
    1.85  {
    1.86      MCI_OPEN_PARMS mop;
    1.87      MCI_SET_PARMS msp;
    1.88 @@ -130,7 +130,7 @@
    1.89      mop.hwndCallback = (HWND) NULL;     // None
    1.90      mop.usDeviceID = (USHORT) NULL;     // Will be returned.
    1.91      mop.pszDeviceType = (PSZ) SDL_cdlist[drive];        // CDAudio Device
    1.92 -    if (LOUSHORT (mciSendCommand (0, MCI_OPEN, MCI_WAIT, &mop, 0)) !=
    1.93 +    if (LOUSHORT(mciSendCommand(0, MCI_OPEN, MCI_WAIT, &mop, 0)) !=
    1.94          MCIERR_SUCCESS)
    1.95          return (CD_ERROR);
    1.96  /* Set time format */
    1.97 @@ -149,13 +149,13 @@
    1.98          return (mop.usDeviceID);
    1.99  /* Error setting time format? - Close opened device */
   1.100      mgp.hwndCallback = (HWND) NULL;     // None
   1.101 -    mciSendCommand (mop.usDeviceID, MCI_CLOSE, MCI_WAIT, &mgp, 0);
   1.102 +    mciSendCommand(mop.usDeviceID, MCI_CLOSE, MCI_WAIT, &mgp, 0);
   1.103      return (CD_ERROR);
   1.104  }
   1.105  
   1.106  /* Get CD Table Of Contents - Ready for MCI */
   1.107  static int
   1.108 -SDL_SYS_CDGetTOC (SDL_CD * cdrom)
   1.109 +SDL_SYS_CDGetTOC(SDL_CD * cdrom)
   1.110  {
   1.111      MCI_TOC_PARMS mtp;
   1.112      MCI_STATUS_PARMS msp;
   1.113 @@ -181,19 +181,18 @@
   1.114          cdrom->numtracks = SDL_MAX_TRACKS;
   1.115      }
   1.116  /* Alocate space for TOC data */
   1.117 -    mtr =
   1.118 -        (MCI_TOC_REC *) SDL_malloc (cdrom->numtracks * sizeof (MCI_TOC_REC));
   1.119 +    mtr = (MCI_TOC_REC *) SDL_malloc(cdrom->numtracks * sizeof(MCI_TOC_REC));
   1.120      if (mtr == NULL) {
   1.121 -        SDL_OutOfMemory ();
   1.122 +        SDL_OutOfMemory();
   1.123          return (-1);
   1.124      }
   1.125  /* Get TOC from CD */
   1.126      mtp.pBuf = mtr;
   1.127 -    mtp.ulBufSize = cdrom->numtracks * sizeof (MCI_TOC_REC);
   1.128 -    if (LOUSHORT (mciSendCommand (cdrom->id, MCI_GETTOC, MCI_WAIT, &mtp, 0))
   1.129 +    mtp.ulBufSize = cdrom->numtracks * sizeof(MCI_TOC_REC);
   1.130 +    if (LOUSHORT(mciSendCommand(cdrom->id, MCI_GETTOC, MCI_WAIT, &mtp, 0))
   1.131          != MCIERR_SUCCESS) {
   1.132 -        SDL_OutOfMemory ();
   1.133 -        SDL_free (mtr);
   1.134 +        SDL_OutOfMemory();
   1.135 +        SDL_free(mtr);
   1.136          return (CD_ERROR);
   1.137      }
   1.138  /* Fill SDL Tracks Structure */
   1.139 @@ -209,7 +208,7 @@
   1.140              (mciSendCommand
   1.141               (cdrom->id, MCI_STATUS, MCI_WAIT | MCI_TRACK | MCI_STATUS_ITEM,
   1.142                &msp, 0)) != MCIERR_SUCCESS) {
   1.143 -            SDL_free (mtr);
   1.144 +            SDL_free(mtr);
   1.145              return (CD_ERROR);
   1.146          }
   1.147          if (msp.ulReturn == MCI_CD_TRACK_AUDIO)
   1.148 @@ -218,18 +217,18 @@
   1.149              cdrom->track[i].type = SDL_DATA_TRACK;
   1.150          /* Set Track Length - values from MCI are in MMTIMEs - 3000 MMTIME = 1 second */
   1.151          cdrom->track[i].length =
   1.152 -            FRAMESFROMMM ((mtr + i)->ulEndAddr - (mtr + i)->ulStartAddr);
   1.153 +            FRAMESFROMMM((mtr + i)->ulEndAddr - (mtr + i)->ulStartAddr);
   1.154          /* Set Track Offset */
   1.155 -        cdrom->track[i].offset = FRAMESFROMMM ((mtr + i)->ulStartAddr);
   1.156 +        cdrom->track[i].offset = FRAMESFROMMM((mtr + i)->ulStartAddr);
   1.157      }
   1.158 -    SDL_free (mtr);
   1.159 +    SDL_free(mtr);
   1.160      return (0);
   1.161  }
   1.162  
   1.163  
   1.164  /* Get CD-ROM status - Ready for MCI */
   1.165  static CDstatus
   1.166 -SDL_SYS_CDStatus (SDL_CD * cdrom, int *position)
   1.167 +SDL_SYS_CDStatus(SDL_CD * cdrom, int *position)
   1.168  {
   1.169      CDstatus status;
   1.170      MCI_STATUS_PARMS msp;
   1.171 @@ -282,9 +281,9 @@
   1.172                  return (CD_ERROR);
   1.173              /* Convert from MSF (format selected in the Open process) to Frames (format that will be returned) */
   1.174              *position =
   1.175 -                MSF_TO_FRAMES (MSF_MINUTE (msp.ulReturn),
   1.176 -                               MSF_SECOND (msp.ulReturn),
   1.177 -                               MSF_FRAME (msp.ulReturn));
   1.178 +                MSF_TO_FRAMES(MSF_MINUTE(msp.ulReturn),
   1.179 +                              MSF_SECOND(msp.ulReturn),
   1.180 +                              MSF_FRAME(msp.ulReturn));
   1.181          } else
   1.182              *position = 0;
   1.183      }
   1.184 @@ -293,7 +292,7 @@
   1.185  
   1.186  /* Start play - Ready for MCI */
   1.187  static int
   1.188 -SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length)
   1.189 +SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length)
   1.190  {
   1.191      MCI_GENERIC_PARMS mgp;
   1.192      MCI_STATUS_PARMS msp;
   1.193 @@ -301,19 +300,19 @@
   1.194      ULONG min, sec, frm;
   1.195  
   1.196  /* Start MSF */
   1.197 -    FRAMES_TO_MSF (start, &min, &sec, &frm);
   1.198 -    MSF_MINUTE (mpp.ulFrom) = min;
   1.199 -    MSF_SECOND (mpp.ulFrom) = sec;
   1.200 -    MSF_FRAME (mpp.ulFrom) = frm;
   1.201 +    FRAMES_TO_MSF(start, &min, &sec, &frm);
   1.202 +    MSF_MINUTE(mpp.ulFrom) = min;
   1.203 +    MSF_SECOND(mpp.ulFrom) = sec;
   1.204 +    MSF_FRAME(mpp.ulFrom) = frm;
   1.205  /* End MSF */
   1.206 -    FRAMES_TO_MSF (start + length, &min, &sec, &frm);
   1.207 -    MSF_MINUTE (mpp.ulTo) = min;
   1.208 -    MSF_SECOND (mpp.ulTo) = sec;
   1.209 -    MSF_FRAME (mpp.ulTo) = frm;
   1.210 +    FRAMES_TO_MSF(start + length, &min, &sec, &frm);
   1.211 +    MSF_MINUTE(mpp.ulTo) = min;
   1.212 +    MSF_SECOND(mpp.ulTo) = sec;
   1.213 +    MSF_FRAME(mpp.ulTo) = frm;
   1.214  #ifdef DEBUG_CDROM
   1.215 -    fprintf (stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n",
   1.216 -             playtime.cdmsf_min0, playtime.cdmsf_sec0, playtime.cdmsf_frame0,
   1.217 -             playtime.cdmsf_min1, playtime.cdmsf_sec1, playtime.cdmsf_frame1);
   1.218 +    fprintf(stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n",
   1.219 +            playtime.cdmsf_min0, playtime.cdmsf_sec0, playtime.cdmsf_frame0,
   1.220 +            playtime.cdmsf_min1, playtime.cdmsf_sec1, playtime.cdmsf_frame1);
   1.221  #endif
   1.222  /* Verifies if it is paused first... and if it is, unpause before stopping it. */
   1.223      msp.hwndCallback = (HWND) NULL;     /* None */
   1.224 @@ -326,13 +325,13 @@
   1.225            0)) == MCIERR_SUCCESS) {
   1.226          if (msp.ulReturn == MCI_MODE_PAUSE) {
   1.227              mgp.hwndCallback = (HWND) NULL;     // None
   1.228 -            mciSendCommand (cdrom->id, MCI_RESUME, 0, &mgp, 0);
   1.229 +            mciSendCommand(cdrom->id, MCI_RESUME, 0, &mgp, 0);
   1.230          }
   1.231      }
   1.232  /* Now play it. */
   1.233      mpp.hwndCallback = (HWND) NULL;     // We do not want the info. temp
   1.234      if (LOUSHORT
   1.235 -        (mciSendCommand (cdrom->id, MCI_PLAY, MCI_FROM | MCI_TO, &mpp, 0)) ==
   1.236 +        (mciSendCommand(cdrom->id, MCI_PLAY, MCI_FROM | MCI_TO, &mpp, 0)) ==
   1.237          MCIERR_SUCCESS)
   1.238          return 0;
   1.239      return (CD_ERROR);
   1.240 @@ -340,12 +339,12 @@
   1.241  
   1.242  /* Pause play - Ready for MCI */
   1.243  static int
   1.244 -SDL_SYS_CDPause (SDL_CD * cdrom)
   1.245 +SDL_SYS_CDPause(SDL_CD * cdrom)
   1.246  {
   1.247      MCI_GENERIC_PARMS mgp;
   1.248  
   1.249      mgp.hwndCallback = (HWND) NULL;     // None
   1.250 -    if (LOUSHORT (mciSendCommand (cdrom->id, MCI_PAUSE, MCI_WAIT, &mgp, 0)) ==
   1.251 +    if (LOUSHORT(mciSendCommand(cdrom->id, MCI_PAUSE, MCI_WAIT, &mgp, 0)) ==
   1.252          MCIERR_SUCCESS)
   1.253          return 0;
   1.254      return (CD_ERROR);
   1.255 @@ -353,12 +352,12 @@
   1.256  
   1.257  /* Resume play - Ready for MCI */
   1.258  static int
   1.259 -SDL_SYS_CDResume (SDL_CD * cdrom)
   1.260 +SDL_SYS_CDResume(SDL_CD * cdrom)
   1.261  {
   1.262      MCI_GENERIC_PARMS mgp;
   1.263  
   1.264      mgp.hwndCallback = (HWND) NULL;     // None
   1.265 -    if (LOUSHORT (mciSendCommand (cdrom->id, MCI_RESUME, MCI_WAIT, &mgp, 0))
   1.266 +    if (LOUSHORT(mciSendCommand(cdrom->id, MCI_RESUME, MCI_WAIT, &mgp, 0))
   1.267          == MCIERR_SUCCESS)
   1.268          return 0;
   1.269      return (CD_ERROR);
   1.270 @@ -366,7 +365,7 @@
   1.271  
   1.272  /* Stop play - Ready for MCI */
   1.273  static int
   1.274 -SDL_SYS_CDStop (SDL_CD * cdrom)
   1.275 +SDL_SYS_CDStop(SDL_CD * cdrom)
   1.276  {
   1.277      MCI_GENERIC_PARMS mgp;
   1.278      MCI_STATUS_PARMS msp;
   1.279 @@ -382,12 +381,12 @@
   1.280            0)) == MCIERR_SUCCESS) {
   1.281          if (msp.ulReturn == MCI_MODE_PAUSE) {
   1.282              mgp.hwndCallback = (HWND) NULL;     // None
   1.283 -            mciSendCommand (cdrom->id, MCI_RESUME, 0, &mgp, 0);
   1.284 +            mciSendCommand(cdrom->id, MCI_RESUME, 0, &mgp, 0);
   1.285          }
   1.286      }
   1.287  /* Now stops the media */
   1.288      mgp.hwndCallback = (HWND) NULL;     // None
   1.289 -    if (LOUSHORT (mciSendCommand (cdrom->id, MCI_STOP, MCI_WAIT, &mgp, 0)) ==
   1.290 +    if (LOUSHORT(mciSendCommand(cdrom->id, MCI_STOP, MCI_WAIT, &mgp, 0)) ==
   1.291          MCIERR_SUCCESS)
   1.292          return 0;
   1.293      return (CD_ERROR);
   1.294 @@ -395,7 +394,7 @@
   1.295  
   1.296  /* Eject the CD-ROM - Ready for MCI */
   1.297  static int
   1.298 -SDL_SYS_CDEject (SDL_CD * cdrom)
   1.299 +SDL_SYS_CDEject(SDL_CD * cdrom)
   1.300  {
   1.301      MCI_SET_PARMS msp;
   1.302  
   1.303 @@ -417,23 +416,23 @@
   1.304  
   1.305  /* Close the CD-ROM handle - Ready for MCI */
   1.306  static void
   1.307 -SDL_SYS_CDClose (SDL_CD * cdrom)
   1.308 +SDL_SYS_CDClose(SDL_CD * cdrom)
   1.309  {
   1.310      MCI_GENERIC_PARMS mgp;
   1.311  
   1.312      mgp.hwndCallback = (HWND) NULL;     // None
   1.313 -    mciSendCommand (cdrom->id, MCI_CLOSE, MCI_WAIT, &mgp, 0);
   1.314 +    mciSendCommand(cdrom->id, MCI_CLOSE, MCI_WAIT, &mgp, 0);
   1.315  }
   1.316  
   1.317  /* Finalize CDROM Subsystem - Ready for MCI */
   1.318  void
   1.319 -SDL_SYS_CDQuit (void)
   1.320 +SDL_SYS_CDQuit(void)
   1.321  {
   1.322      int i;
   1.323  
   1.324      if (SDL_numcds > 0) {
   1.325          for (i = 0; i < SDL_numcds; ++i) {
   1.326 -            SDL_free (SDL_cdlist[i]);
   1.327 +            SDL_free(SDL_cdlist[i]);
   1.328          }
   1.329          SDL_numcds = 0;
   1.330      }