src/cdrom/qnx/SDL_syscdrom.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/src/cdrom/qnx/SDL_syscdrom.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/cdrom/qnx/SDL_syscdrom.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -49,20 +49,20 @@
     1.4  static int SDL_cdopen[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  /* Check a drive to see if it is a CD-ROM */
    1.29  static int
    1.30 -CheckDrive (char *drive, struct stat *stbuf)
    1.31 +CheckDrive(char *drive, struct stat *stbuf)
    1.32  {
    1.33      int is_cd, cdfd;
    1.34      cam_devinfo_t dinfo;
    1.35 @@ -73,19 +73,19 @@
    1.36      int cdb10;
    1.37  
    1.38      /* If it doesn't exist, return -1 */
    1.39 -    if (stat (drive, stbuf) < 0) {
    1.40 +    if (stat(drive, stbuf) < 0) {
    1.41          return (-1);
    1.42      }
    1.43  
    1.44      /* If it does exist, verify that it's an available CD-ROM */
    1.45      is_cd = 0;
    1.46  
    1.47 -    if (S_ISCHR (stbuf->st_mode) || S_ISBLK (stbuf->st_mode)) {
    1.48 -        cdfd = open (drive, QNX_CD_OPENMODE);
    1.49 +    if (S_ISCHR(stbuf->st_mode) || S_ISBLK(stbuf->st_mode)) {
    1.50 +        cdfd = open(drive, QNX_CD_OPENMODE);
    1.51          if (cdfd >= 0) {
    1.52              devctlret =
    1.53 -                devctl (cdfd, DCMD_CAM_DEVINFO, &dinfo,
    1.54 -                        sizeof (cam_devinfo_t), NULL);
    1.55 +                devctl(cdfd, DCMD_CAM_DEVINFO, &dinfo,
    1.56 +                       sizeof(cam_devinfo_t), NULL);
    1.57  
    1.58              if (devctlret == EOK) {
    1.59                  atapi = dinfo.flags & DEV_ATAPI;
    1.60 @@ -98,7 +98,7 @@
    1.61                  }
    1.62              }
    1.63  
    1.64 -            close (cdfd);
    1.65 +            close(cdfd);
    1.66          }
    1.67      }
    1.68      return (is_cd);
    1.69 @@ -106,7 +106,7 @@
    1.70  
    1.71  /* Add a CD-ROM drive to our list of valid drives */
    1.72  static void
    1.73 -AddDrive (char *drive, struct stat *stbuf)
    1.74 +AddDrive(char *drive, struct stat *stbuf)
    1.75  {
    1.76      int i;
    1.77  
    1.78 @@ -123,9 +123,9 @@
    1.79          /* Add this drive to our list */
    1.80  
    1.81          i = SDL_numcds;
    1.82 -        SDL_cdlist[i] = SDL_strdup (drive);
    1.83 +        SDL_cdlist[i] = SDL_strdup(drive);
    1.84          if (SDL_cdlist[i] == NULL) {
    1.85 -            SDL_OutOfMemory ();
    1.86 +            SDL_OutOfMemory();
    1.87              return;
    1.88          }
    1.89          SDL_cdmode[i] = stbuf->st_rdev;
    1.90 @@ -134,7 +134,7 @@
    1.91  }
    1.92  
    1.93  int
    1.94 -SDL_SYS_CDInit (void)
    1.95 +SDL_SYS_CDInit(void)
    1.96  {
    1.97      /* checklist: /dev/cdrom, /dev/cd?, /dev/scd? */
    1.98      static char *checklist[] =
    1.99 @@ -163,21 +163,21 @@
   1.100      }
   1.101  
   1.102      /* Look in the environment for our CD-ROM drive list */
   1.103 -    SDLcdrom = SDL_getenv ("SDL_CDROM");        /* ':' separated list of devices */
   1.104 +    SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */
   1.105      if (SDLcdrom != NULL) {
   1.106          char *cdpath, *delim;
   1.107 -        size_t len = SDL_strlen (SDLcdrom) + 1;
   1.108 -        cdpath = SDL_stack_alloc (char, len);
   1.109 +        size_t len = SDL_strlen(SDLcdrom) + 1;
   1.110 +        cdpath = SDL_stack_alloc(char, len);
   1.111          if (cdpath != NULL) {
   1.112 -            SDL_strlcpy (cdpath, SDLcdrom, len);
   1.113 +            SDL_strlcpy(cdpath, SDLcdrom, len);
   1.114              SDLcdrom = cdpath;
   1.115              do {
   1.116 -                delim = SDL_strchr (SDLcdrom, ':');
   1.117 +                delim = SDL_strchr(SDLcdrom, ':');
   1.118                  if (delim) {
   1.119                      *delim++ = '\0';
   1.120                  }
   1.121 -                if (CheckDrive (SDLcdrom, &stbuf) > 0) {
   1.122 -                    AddDrive (SDLcdrom, &stbuf);
   1.123 +                if (CheckDrive(SDLcdrom, &stbuf) > 0) {
   1.124 +                    AddDrive(SDLcdrom, &stbuf);
   1.125                  }
   1.126                  if (delim) {
   1.127                      SDLcdrom = delim;
   1.128 @@ -186,7 +186,7 @@
   1.129                  }
   1.130              }
   1.131              while (SDLcdrom);
   1.132 -            SDL_stack_free (cdpath);
   1.133 +            SDL_stack_free(cdpath);
   1.134          }
   1.135  
   1.136          /* If we found our drives, there's nothing left to do */
   1.137 @@ -202,16 +202,16 @@
   1.138              exists = 1;
   1.139  
   1.140              for (j = checklist[i][1]; exists; ++j) {
   1.141 -                SDL_snprintf (drive, SDL_arraysize (drive), "/dev/%s",
   1.142 -                              &checklist[i][3]);
   1.143 -                insert = SDL_strchr (drive, '?');
   1.144 +                SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s",
   1.145 +                             &checklist[i][3]);
   1.146 +                insert = SDL_strchr(drive, '?');
   1.147                  if (insert != NULL) {
   1.148                      *insert = j;
   1.149                  }
   1.150 -                switch (CheckDrive (drive, &stbuf)) {
   1.151 +                switch (CheckDrive(drive, &stbuf)) {
   1.152                      /* Drive exists and is a CD-ROM */
   1.153                  case 1:
   1.154 -                    AddDrive (drive, &stbuf);
   1.155 +                    AddDrive(drive, &stbuf);
   1.156                      break;
   1.157                      /* Drive exists, but isn't a CD-ROM */
   1.158                  case 0:
   1.159 @@ -223,10 +223,10 @@
   1.160                  }
   1.161              }
   1.162          } else {
   1.163 -            SDL_snprintf (drive, SDL_arraysize (drive), "/dev/%s",
   1.164 -                          checklist[i]);
   1.165 -            if (CheckDrive (drive, &stbuf) > 0) {
   1.166 -                AddDrive (drive, &stbuf);
   1.167 +            SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s",
   1.168 +                         checklist[i]);
   1.169 +            if (CheckDrive(drive, &stbuf) > 0) {
   1.170 +                AddDrive(drive, &stbuf);
   1.171              }
   1.172          }
   1.173      }
   1.174 @@ -234,17 +234,17 @@
   1.175  }
   1.176  
   1.177  static const char *
   1.178 -SDL_SYS_CDName (int drive)
   1.179 +SDL_SYS_CDName(int drive)
   1.180  {
   1.181      return (SDL_cdlist[drive]);
   1.182  }
   1.183  
   1.184  static int
   1.185 -SDL_SYS_CDOpen (int drive)
   1.186 +SDL_SYS_CDOpen(int drive)
   1.187  {
   1.188      int handle;
   1.189  
   1.190 -    handle = open (SDL_cdlist[drive], QNX_CD_OPENMODE);
   1.191 +    handle = open(SDL_cdlist[drive], QNX_CD_OPENMODE);
   1.192  
   1.193      if (handle > 0) {
   1.194          SDL_cdopen[drive] = handle;
   1.195 @@ -254,13 +254,13 @@
   1.196  }
   1.197  
   1.198  static int
   1.199 -SDL_SYS_CDGetTOC (SDL_CD * cdrom)
   1.200 +SDL_SYS_CDGetTOC(SDL_CD * cdrom)
   1.201  {
   1.202      cdrom_read_toc_t toc;
   1.203      int i, okay;
   1.204  
   1.205      okay = 0;
   1.206 -    if (devctl (cdrom->id, DCMD_CAM_CDROMREADTOC, &toc, sizeof (toc), NULL) ==
   1.207 +    if (devctl(cdrom->id, DCMD_CAM_CDROMREADTOC, &toc, sizeof(toc), NULL) ==
   1.208          0) {
   1.209          cdrom->numtracks = toc.last_track - toc.first_track + 1;
   1.210          if (cdrom->numtracks > SDL_MAX_TRACKS) {
   1.211 @@ -292,7 +292,7 @@
   1.212  
   1.213  /* Get CD-ROM status */
   1.214  static CDstatus
   1.215 -SDL_SYS_CDStatus (SDL_CD * cdrom, int *position)
   1.216 +SDL_SYS_CDStatus(SDL_CD * cdrom, int *position)
   1.217  {
   1.218      CDstatus status;
   1.219  
   1.220 @@ -308,8 +308,8 @@
   1.221      /* check media presence before read subchannel call, some cdroms can lockups */
   1.222      /* if no media, while calling read subchannel functions.                     */
   1.223      devctlret =
   1.224 -        devctl (cdrom->id, DCMD_CAM_DEVINFO, &dinfo, sizeof (cam_devinfo_t),
   1.225 -                NULL);
   1.226 +        devctl(cdrom->id, DCMD_CAM_DEVINFO, &dinfo, sizeof(cam_devinfo_t),
   1.227 +               NULL);
   1.228  
   1.229      if (devctlret == EOK) {
   1.230          if ((dinfo.flags & DEV_NO_MEDIA) != 0) {
   1.231 @@ -323,13 +323,13 @@
   1.232  
   1.233      /* if media exists, then do other stuff */
   1.234  
   1.235 -    SDL_memset (&info, 0x00, sizeof (info));
   1.236 +    SDL_memset(&info, 0x00, sizeof(info));
   1.237      info.subch_command.data_format = CDROM_SUBCH_CURRENT_POSITION;
   1.238  
   1.239      do {
   1.240          devctlret =
   1.241 -            devctl (cdrom->id, DCMD_CAM_CDROMSUBCHNL, &info, sizeof (info),
   1.242 -                    NULL);
   1.243 +            devctl(cdrom->id, DCMD_CAM_CDROMSUBCHNL, &info, sizeof(info),
   1.244 +                   NULL);
   1.245          if (devctlret == EIO) {
   1.246              /* big workaround for media change, handle is unusable after that,
   1.247                 that bug was found in QNX 6.2, 6.2.1 is not released yet.    */
   1.248 @@ -344,8 +344,8 @@
   1.249                  /* that cannot happen, but ... */
   1.250                  break;
   1.251              }
   1.252 -            close (cdrom->id);
   1.253 -            cdrom->id = open (SDL_cdlist[drive], QNX_CD_OPENMODE);
   1.254 +            close(cdrom->id);
   1.255 +            cdrom->id = open(SDL_cdlist[drive], QNX_CD_OPENMODE);
   1.256              devctlret = EAGAIN;
   1.257          }
   1.258          if (devctlret == EAGAIN) {
   1.259 @@ -372,7 +372,7 @@
   1.260          case CDROM_AUDIO_NO_STATUS:
   1.261              /* Try to determine if there's a CD available */
   1.262              if (devctl
   1.263 -                (cdrom->id, DCMD_CAM_CDROMREADTOC, &toc, sizeof (toc),
   1.264 +                (cdrom->id, DCMD_CAM_CDROMREADTOC, &toc, sizeof(toc),
   1.265                   NULL) == 0)
   1.266                  status = CD_STOPPED;
   1.267              else
   1.268 @@ -401,9 +401,9 @@
   1.269      if (position) {
   1.270          if (status == CD_PLAYING || (status == CD_PAUSED)) {
   1.271              *position =
   1.272 -                MSF_TO_FRAMES (info.current_position.addr.msf.minute,
   1.273 -                               info.current_position.addr.msf.second,
   1.274 -                               info.current_position.addr.msf.frame);
   1.275 +                MSF_TO_FRAMES(info.current_position.addr.msf.minute,
   1.276 +                              info.current_position.addr.msf.second,
   1.277 +                              info.current_position.addr.msf.frame);
   1.278          } else {
   1.279              *position = 0;
   1.280          }
   1.281 @@ -414,17 +414,17 @@
   1.282  
   1.283  /* Start play */
   1.284  static int
   1.285 -SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length)
   1.286 +SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length)
   1.287  {
   1.288      cdrom_playmsf_t playtime;
   1.289  
   1.290 -    FRAMES_TO_MSF (start, &playtime.start_minute, &playtime.start_second,
   1.291 -                   &playtime.start_frame);
   1.292 -    FRAMES_TO_MSF (start + length, &playtime.end_minute, &playtime.end_second,
   1.293 -                   &playtime.end_frame);
   1.294 +    FRAMES_TO_MSF(start, &playtime.start_minute, &playtime.start_second,
   1.295 +                  &playtime.start_frame);
   1.296 +    FRAMES_TO_MSF(start + length, &playtime.end_minute, &playtime.end_second,
   1.297 +                  &playtime.end_frame);
   1.298  
   1.299      if (devctl
   1.300 -        (cdrom->id, DCMD_CAM_CDROMPLAYMSF, &playtime, sizeof (playtime),
   1.301 +        (cdrom->id, DCMD_CAM_CDROMPLAYMSF, &playtime, sizeof(playtime),
   1.302           NULL) != 0) {
   1.303          return -1;
   1.304      } else {
   1.305 @@ -434,9 +434,9 @@
   1.306  
   1.307  /* Pause play */
   1.308  static int
   1.309 -SDL_SYS_CDPause (SDL_CD * cdrom)
   1.310 +SDL_SYS_CDPause(SDL_CD * cdrom)
   1.311  {
   1.312 -    if (devctl (cdrom->id, DCMD_CAM_CDROMPAUSE, NULL, 0, NULL) != 0) {
   1.313 +    if (devctl(cdrom->id, DCMD_CAM_CDROMPAUSE, NULL, 0, NULL) != 0) {
   1.314          return -1;
   1.315      } else {
   1.316          return 0;
   1.317 @@ -445,9 +445,9 @@
   1.318  
   1.319  /* Resume play */
   1.320  static int
   1.321 -SDL_SYS_CDResume (SDL_CD * cdrom)
   1.322 +SDL_SYS_CDResume(SDL_CD * cdrom)
   1.323  {
   1.324 -    if (devctl (cdrom->id, DCMD_CAM_CDROMRESUME, NULL, 0, NULL) != 0) {
   1.325 +    if (devctl(cdrom->id, DCMD_CAM_CDROMRESUME, NULL, 0, NULL) != 0) {
   1.326          return -1;
   1.327      } else {
   1.328          return 0;
   1.329 @@ -456,9 +456,9 @@
   1.330  
   1.331  /* Stop play */
   1.332  static int
   1.333 -SDL_SYS_CDStop (SDL_CD * cdrom)
   1.334 +SDL_SYS_CDStop(SDL_CD * cdrom)
   1.335  {
   1.336 -    if (devctl (cdrom->id, DCMD_CAM_CDROMSTOP, NULL, 0, NULL) != 0) {
   1.337 +    if (devctl(cdrom->id, DCMD_CAM_CDROMSTOP, NULL, 0, NULL) != 0) {
   1.338          return -1;
   1.339      } else {
   1.340          return 0;
   1.341 @@ -467,9 +467,9 @@
   1.342  
   1.343  /* Eject the CD-ROM */
   1.344  static int
   1.345 -SDL_SYS_CDEject (SDL_CD * cdrom)
   1.346 +SDL_SYS_CDEject(SDL_CD * cdrom)
   1.347  {
   1.348 -    if (devctl (cdrom->id, DCMD_CAM_EJECT_MEDIA, NULL, 0, NULL) != 0) {
   1.349 +    if (devctl(cdrom->id, DCMD_CAM_EJECT_MEDIA, NULL, 0, NULL) != 0) {
   1.350          return -1;
   1.351      } else {
   1.352          return 0;
   1.353 @@ -478,7 +478,7 @@
   1.354  
   1.355  /* Close the CD-ROM handle */
   1.356  static void
   1.357 -SDL_SYS_CDClose (SDL_CD * cdrom)
   1.358 +SDL_SYS_CDClose(SDL_CD * cdrom)
   1.359  {
   1.360      int i;
   1.361  
   1.362 @@ -489,17 +489,17 @@
   1.363          }
   1.364      }
   1.365  
   1.366 -    close (cdrom->id);
   1.367 +    close(cdrom->id);
   1.368  }
   1.369  
   1.370  void
   1.371 -SDL_SYS_CDQuit (void)
   1.372 +SDL_SYS_CDQuit(void)
   1.373  {
   1.374      int i;
   1.375  
   1.376      if (SDL_numcds > 0) {
   1.377          for (i = 0; i < SDL_numcds; ++i) {
   1.378 -            SDL_free (SDL_cdlist[i]);
   1.379 +            SDL_free(SDL_cdlist[i]);
   1.380          }
   1.381          SDL_numcds = 0;
   1.382      }