src/cdrom/osf/SDL_syscdrom.c
author Sam Lantinga <slouken@libsdl.org>
Wed, 27 Aug 2008 15:10:03 +0000
changeset 2735 204be4fc2726
parent 1895 c121d94672cb
permissions -rw-r--r--
Final merge of Google Summer of Code 2008 work...

Port SDL 1.3 to the Nintendo DS
by Darren Alton, mentored by Sam Lantinga
slouken@654
     1
/*
slouken@654
     2
    Tru64 audio module for SDL (Simple DirectMedia Layer)
slouken@654
     3
    Copyright (C) 2003
slouken@654
     4
slouken@654
     5
    This library is free software; you can redistribute it and/or
slouken@654
     6
    modify it under the terms of the GNU Library General Public
slouken@654
     7
    License as published by the Free Software Foundation; either
slouken@654
     8
    version 2 of the License, or (at your option) any later version.
slouken@654
     9
slouken@654
    10
    This library is distributed in the hope that it will be useful,
slouken@654
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@654
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@654
    13
    Library General Public License for more details.
slouken@654
    14
slouken@654
    15
    You should have received a copy of the GNU Library General Public
slouken@654
    16
    License along with this library; if not, write to the Free
slouken@654
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
slouken@654
    18
slouken@654
    19
slouken@654
    20
*/
slouken@1402
    21
#include "SDL_config.h"
slouken@654
    22
slouken@1635
    23
#ifdef SDL_CDROM_OSF
slouken@1635
    24
slouken@654
    25
/* Functions for system-level CD-ROM audio control */
slouken@654
    26
slouken@1019
    27
/* #define DEBUG_CDROM 1 */
slouken@654
    28
slouken@654
    29
#include <sys/types.h>
slouken@1019
    30
#include <dirent.h>
slouken@654
    31
#include <sys/stat.h>
slouken@654
    32
#include <fcntl.h>
slouken@654
    33
#include <io/cam/cdrom.h>
slouken@654
    34
#include <io/cam/rzdisk.h>
slouken@654
    35
#include <io/common/devgetinfo.h>
slouken@654
    36
slouken@654
    37
#include "SDL_cdrom.h"
slouken@1361
    38
#include "../SDL_syscdrom.h"
slouken@654
    39
slouken@654
    40
/* The maximum number of CD-ROM drives we'll detect */
slouken@654
    41
#define MAX_DRIVES 16
slouken@654
    42
slouken@654
    43
/* A list of available CD-ROM drives */
slouken@654
    44
static char *SDL_cdlist[MAX_DRIVES];
slouken@654
    45
static dev_t SDL_cdmode[MAX_DRIVES];
slouken@654
    46
slouken@654
    47
/* The system-dependent CD control functions */
slouken@654
    48
static const char *SDL_SYS_CDName(int drive);
slouken@1895
    49
static int SDL_SYS_CDOpen(int drive);
slouken@1895
    50
static int SDL_SYS_CDGetTOC(SDL_CD * cdrom);
slouken@1895
    51
static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position);
slouken@1895
    52
static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length);
slouken@1895
    53
static int SDL_SYS_CDPause(SDL_CD * cdrom);
slouken@1895
    54
static int SDL_SYS_CDResume(SDL_CD * cdrom);
slouken@1895
    55
static int SDL_SYS_CDStop(SDL_CD * cdrom);
slouken@1895
    56
static int SDL_SYS_CDEject(SDL_CD * cdrom);
slouken@1895
    57
static void SDL_SYS_CDClose(SDL_CD * cdrom);
slouken@654
    58
slouken@654
    59
/* Check a drive to see if it is a CD-ROM */
slouken@1895
    60
/* Caution!! Not tested. */
slouken@1895
    61
static int
slouken@1895
    62
CheckDrive(char *drive, struct stat *stbuf)
slouken@654
    63
{
slouken@873
    64
    int cdfd, is_cd = 0;
slouken@873
    65
    struct mode_sel_sns_params msp;
slouken@873
    66
    struct inquiry_info inq;
slouken@873
    67
slouken@873
    68
#ifdef DEBUG_CDROM
slouken@1895
    69
    char *devtype[] = { "Disk", "Tape", "Printer", "Processor", "WORM",
slouken@1895
    70
        "CD-ROM", "Scanner", "Optical", "Changer", "Comm", "Unknown"
slouken@1895
    71
    };
slouken@873
    72
#endif
slouken@873
    73
slouken@873
    74
    bzero(&msp, sizeof(msp));
slouken@873
    75
    bzero(&inq, sizeof(inq));
slouken@654
    76
slouken@654
    77
    /* If it doesn't exist, return -1 */
slouken@1895
    78
    if (stat(drive, stbuf) < 0) {
slouken@1895
    79
        return (-1);
slouken@654
    80
    }
slouken@654
    81
slouken@1895
    82
    if ((cdfd = open(drive, (O_RDWR | O_NDELAY), 0)) >= 0) {
slouken@1895
    83
        msp.msp_addr = (caddr_t) & inq;
slouken@1895
    84
        msp.msp_pgcode = 0;
slouken@1895
    85
        msp.msp_pgctrl = 0;
slouken@1895
    86
        msp.msp_length = sizeof(inq);
slouken@1895
    87
        msp.msp_setps = 0;
slouken@654
    88
slouken@1895
    89
        if (ioctl(cdfd, SCSI_GET_INQUIRY_DATA, &msp))
slouken@1895
    90
            return (0);
slouken@873
    91
slouken@873
    92
#ifdef DEBUG_CDROM
slouken@1895
    93
        fprintf(stderr, "Device Type: %s\n", devtype[inq.perfdt]);
slouken@1895
    94
        fprintf(stderr, "Vendor: %.8s\n", inq.vndrid);
slouken@1895
    95
        fprintf(stderr, "Product: %.8s\n", inq.prodid);
slouken@1895
    96
        fprintf(stderr, "Revision: %.8s\n", inq.revlvl);
slouken@873
    97
#endif
slouken@1895
    98
        if (inq.perfdt == DTYPE_RODIRECT)
slouken@1895
    99
            is_cd = 1;
slouken@654
   100
    }
slouken@654
   101
slouken@1895
   102
    return (is_cd);
slouken@654
   103
}
slouken@654
   104
slouken@654
   105
/* Add a CD-ROM drive to our list of valid drives */
slouken@1895
   106
static void
slouken@1895
   107
AddDrive(char *drive, struct stat *stbuf)
slouken@654
   108
{
slouken@654
   109
    int i;
slouken@654
   110
slouken@1895
   111
    if (SDL_numcds < MAX_DRIVES) {
slouken@1895
   112
        /* Check to make sure it's not already in our list.
slouken@1895
   113
         * This can happen when we see a drive via symbolic link.
slouken@1895
   114
         *
slouken@1895
   115
         */
slouken@1895
   116
        for (i = 0; i < SDL_numcds; ++i) {
slouken@1895
   117
            if (stbuf->st_rdev == SDL_cdmode[i]) {
slouken@654
   118
#ifdef DEBUG_CDROM
slouken@1895
   119
                fprintf(stderr, "Duplicate drive detected: %s == %s\n",
slouken@1895
   120
                        drive, SDL_cdlist[i]);
slouken@654
   121
#endif
slouken@1895
   122
                return;
slouken@1895
   123
            }
slouken@1895
   124
        }
slouken@654
   125
slouken@1895
   126
        /* Add this drive to our list */
slouken@1895
   127
        i = SDL_numcds;
slouken@1895
   128
        SDL_cdlist[i] = SDL_strdup(drive);
slouken@1895
   129
        if (SDL_cdlist[i] == NULL) {
slouken@1895
   130
            SDL_OutOfMemory();
slouken@1895
   131
            return;
slouken@1895
   132
        }
slouken@1895
   133
        SDL_cdmode[i] = stbuf->st_rdev;
slouken@1895
   134
        ++SDL_numcds;
slouken@654
   135
#ifdef DEBUG_CDROM
slouken@1895
   136
        fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
slouken@654
   137
#endif
slouken@654
   138
    }
slouken@654
   139
}
slouken@654
   140
slouken@1895
   141
int
slouken@1895
   142
SDL_SYS_CDInit(void)
slouken@654
   143
{
slouken@1019
   144
    /* checklist:
slouken@1019
   145
     *
slouken@1019
   146
     * Tru64 5.X (/dev/rdisk/cdrom?c)
slouken@1019
   147
     * dir: /dev/rdisk, name: cdrom
slouken@1019
   148
     *
slouken@1019
   149
     * Digital UNIX 4.0X (/dev/rrz?c)
slouken@1019
   150
     * dir: /dev, name: rrz
slouken@654
   151
     *
slouken@654
   152
     */
slouken@1895
   153
    struct
slouken@1895
   154
    {
slouken@1895
   155
        char *dir;
slouken@1895
   156
        char *name;
slouken@1019
   157
    } checklist[] = {
slouken@1895
   158
        {
slouken@1895
   159
        "/dev/rdisk", "cdrom"}, {
slouken@1895
   160
        "/dev", "rrz"}, {
slouken@1895
   161
    NULL, NULL}};
slouken@654
   162
    char drive[32];
slouken@654
   163
    char *SDLcdrom;
slouken@654
   164
    int i, j, exists;
slouken@654
   165
    struct stat stbuf;
slouken@654
   166
slouken@654
   167
    /* Fill in our driver capabilities */
slouken@1895
   168
    SDL_CDcaps.Name = SDL_SYS_CDName;
slouken@1895
   169
    SDL_CDcaps.Open = SDL_SYS_CDOpen;
slouken@654
   170
    SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
slouken@654
   171
    SDL_CDcaps.Status = SDL_SYS_CDStatus;
slouken@1895
   172
    SDL_CDcaps.Play = SDL_SYS_CDPlay;
slouken@1895
   173
    SDL_CDcaps.Pause = SDL_SYS_CDPause;
slouken@654
   174
    SDL_CDcaps.Resume = SDL_SYS_CDResume;
slouken@1895
   175
    SDL_CDcaps.Stop = SDL_SYS_CDStop;
slouken@1895
   176
    SDL_CDcaps.Eject = SDL_SYS_CDEject;
slouken@1895
   177
    SDL_CDcaps.Close = SDL_SYS_CDClose;
slouken@654
   178
slouken@654
   179
slouken@654
   180
    /* Look in the environment for our CD-ROM drive list */
slouken@1895
   181
    SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */
slouken@1895
   182
    if (SDLcdrom != NULL) {
slouken@1895
   183
        char *cdpath, *delim;
slouken@1895
   184
        size_t len = SDL_strlen(SDLcdrom) + 1;
slouken@1895
   185
        cdpath = SDL_stack_alloc(char, len);
slouken@1895
   186
        if (cdpath != NULL) {
slouken@1895
   187
            SDL_strlcpy(cdpath, SDLcdrom, len);
slouken@1895
   188
            SDLcdrom = cdpath;
slouken@1895
   189
            do {
slouken@1895
   190
                delim = SDL_strchr(SDLcdrom, ':');
slouken@1895
   191
                if (delim) {
slouken@1895
   192
                    *delim++ = '\0';
slouken@1895
   193
                }
slouken@1895
   194
                if (CheckDrive(SDLcdrom, &stbuf) > 0) {
slouken@1895
   195
                    AddDrive(SDLcdrom, &stbuf);
slouken@1895
   196
                }
slouken@1895
   197
                if (delim) {
slouken@1895
   198
                    SDLcdrom = delim;
slouken@1895
   199
                } else {
slouken@1895
   200
                    SDLcdrom = NULL;
slouken@1895
   201
                }
slouken@2735
   202
            } while (SDLcdrom);
slouken@1895
   203
            SDL_stack_free(cdpath);
slouken@1895
   204
        }
slouken@654
   205
slouken@1895
   206
        /* If we found our drives, there's nothing left to do */
slouken@1895
   207
        if (SDL_numcds > 0) {
slouken@1895
   208
            return (0);
slouken@1895
   209
        }
slouken@654
   210
    }
slouken@654
   211
    /* Scan the system for CD-ROM drives */
slouken@1895
   212
    for (i = 0; checklist[i].dir; ++i) {
slouken@1895
   213
        DIR *devdir;
slouken@1895
   214
        struct dirent *devent;
slouken@1895
   215
        int name_len;
slouken@1019
   216
slouken@1895
   217
        devdir = opendir(checklist[i].dir);
slouken@1895
   218
        if (devdir) {
slouken@1895
   219
            name_len = SDL_strlen(checklist[i].name);
slouken@1895
   220
            while (devent = readdir(devdir))
slouken@1895
   221
                if (SDL_memcmp
slouken@1895
   222
                    (checklist[i].name, devent->d_name, name_len) == 0)
slouken@1895
   223
                    if (devent->d_name[devent->d_namlen - 1] == 'c') {
slouken@1895
   224
                        SDL_snprintf(drive, SDL_arraysize(drive),
slouken@1895
   225
                                     "%s/%s", checklist[i].dir,
slouken@1895
   226
                                     devent->d_name);
slouken@1019
   227
#ifdef DEBUG_CDROM
slouken@1895
   228
                        fprintf(stderr, "Try to add drive: %s\n", drive);
slouken@1019
   229
#endif
slouken@1895
   230
                        if (CheckDrive(drive, &stbuf) > 0)
slouken@1895
   231
                            AddDrive(drive, &stbuf);
slouken@1895
   232
                    }
slouken@1895
   233
            closedir(devdir);
slouken@1895
   234
        } else {
slouken@1019
   235
#ifdef DEBUG_CDROM
slouken@1895
   236
            fprintf(stderr, "cannot open dir: %s\n", checklist[i].dir);
slouken@1019
   237
#endif
slouken@1895
   238
        }
slouken@654
   239
    }
slouken@654
   240
    return (0);
slouken@654
   241
}
slouken@654
   242
slouken@1895
   243
static const char *
slouken@1895
   244
SDL_SYS_CDName(int drive)
slouken@654
   245
{
slouken@1895
   246
    return (SDL_cdlist[drive]);
slouken@654
   247
}
slouken@654
   248
slouken@1895
   249
static int
slouken@1895
   250
SDL_SYS_CDOpen(int drive)
slouken@654
   251
{
slouken@654
   252
    /* O_RDWR: To use ioctl(fd, SCSI_STOP_UNIT) */
slouken@1895
   253
    return (open(SDL_cdlist[drive], (O_RDWR | O_NDELAY), 0));
slouken@654
   254
}
slouken@654
   255
slouken@1895
   256
static int
slouken@1895
   257
SDL_SYS_CDGetTOC(SDL_CD * cdrom)
slouken@654
   258
{
slouken@1895
   259
    struct cd_toc toc;
slouken@1895
   260
    struct cd_toc_header hdr;
slouken@1895
   261
    struct cd_toc_entry *cdte;
slouken@654
   262
    int i;
slouken@654
   263
    int okay = 0;
slouken@1895
   264
    if (ioctl(cdrom->id, CDROM_TOC_HEADER, &hdr)) {
slouken@1895
   265
        fprintf(stderr, "ioctl error CDROM_TOC_HEADER\n");
slouken@1895
   266
        return -1;
slouken@654
   267
    }
slouken@654
   268
    cdrom->numtracks = hdr.th_ending_track - hdr.th_starting_track + 1;
slouken@1895
   269
    if (cdrom->numtracks > SDL_MAX_TRACKS) {
slouken@1895
   270
        cdrom->numtracks = SDL_MAX_TRACKS;
slouken@654
   271
    }
slouken@654
   272
#ifdef DEBUG_CDROM
slouken@1895
   273
    fprintf(stderr, "hdr.th_data_len1 = %d\n", hdr.th_data_len1);
slouken@1895
   274
    fprintf(stderr, "hdr.th_data_len0 = %d\n", hdr.th_data_len0);
slouken@1895
   275
    fprintf(stderr, "hdr.th_starting_track = %d\n", hdr.th_starting_track);
slouken@1895
   276
    fprintf(stderr, "hdr.th_ending_track = %d\n", hdr.th_ending_track);
slouken@1895
   277
    fprintf(stderr, "cdrom->numtracks = %d\n", cdrom->numtracks);
slouken@654
   278
#endif
slouken@654
   279
    toc.toc_address_format = CDROM_LBA_FORMAT;
slouken@654
   280
    toc.toc_starting_track = 0;
slouken@654
   281
    toc.toc_alloc_length = (hdr.th_data_len1 << 8) +
slouken@1895
   282
        hdr.th_data_len0 + sizeof(hdr);
slouken@1895
   283
    if ((toc.toc_buffer = alloca(toc.toc_alloc_length)) == NULL) {
slouken@1895
   284
        fprintf(stderr, "cannot allocate toc.toc_buffer\n");
slouken@1895
   285
        return -1;
slouken@654
   286
    }
slouken@654
   287
slouken@1895
   288
    bzero(toc.toc_buffer, toc.toc_alloc_length);
slouken@654
   289
    if (ioctl(cdrom->id, CDROM_TOC_ENTRYS, &toc)) {
slouken@1895
   290
        fprintf(stderr, "ioctl error CDROM_TOC_ENTRYS\n");
slouken@1895
   291
        return -1;
slouken@654
   292
    }
slouken@654
   293
slouken@1895
   294
    cdte = (struct cd_toc_entry *) ((char *) toc.toc_buffer + sizeof(hdr));
slouken@1895
   295
    for (i = 0; i <= cdrom->numtracks; ++i) {
slouken@1895
   296
        if (i == cdrom->numtracks) {
slouken@1895
   297
            cdrom->track[i].id = 0xAA;;
slouken@1895
   298
        } else {
slouken@1895
   299
            cdrom->track[i].id = hdr.th_starting_track + i;
slouken@1895
   300
        }
slouken@654
   301
slouken@1895
   302
        cdrom->track[i].type = cdte[i].te_control & CDROM_DATA_TRACK;
slouken@1895
   303
        cdrom->track[i].offset =
slouken@1895
   304
            cdte[i].te_absaddr.lba.addr3 << 24 |
slouken@1895
   305
            cdte[i].te_absaddr.lba.addr2 << 16 |
slouken@1895
   306
            cdte[i].te_absaddr.lba.addr1 << 8 | cdte[i].te_absaddr.lba.addr0;
slouken@1895
   307
        cdrom->track[i].length = 0;
slouken@1895
   308
        if (i > 0) {
slouken@1895
   309
            cdrom->track[i - 1].length =
slouken@1895
   310
                cdrom->track[i].offset - cdrom->track[i - 1].offset;
slouken@1895
   311
        }
slouken@873
   312
    }
slouken@654
   313
#ifdef DEBUG_CDROM
slouken@1895
   314
    for (i = 0; i <= cdrom->numtracks; i++) {
slouken@1895
   315
        fprintf(stderr, "toc_entry[%d].te_track_number = %d\n",
slouken@1895
   316
                i, cdte[i].te_track_number);
slouken@1895
   317
        fprintf(stderr, "cdrom->track[%d].id = %d\n", i, cdrom->track[i].id);
slouken@1895
   318
        fprintf(stderr, "cdrom->track[%d].type = %x\n", i,
slouken@1895
   319
                cdrom->track[i].type);
slouken@1895
   320
        fprintf(stderr, "cdrom->track[%d].offset = %d\n", i,
slouken@1895
   321
                cdrom->track[i].offset);
slouken@1895
   322
        fprintf(stderr, "cdrom->track[%d].length = %d\n", i,
slouken@1895
   323
                cdrom->track[i].length);
slouken@1895
   324
    }
slouken@654
   325
#endif
slouken@1895
   326
    if (i == (cdrom->numtracks + 1)) {
slouken@1895
   327
        okay = 1;
slouken@654
   328
    }
slouken@654
   329
slouken@1895
   330
    return (okay ? 0 : -1);
slouken@654
   331
}
slouken@654
   332
slouken@654
   333
/* Get CD-ROM status */
slouken@1895
   334
static CDstatus
slouken@1895
   335
SDL_SYS_CDStatus(SDL_CD * cdrom, int *position)
slouken@654
   336
{
slouken@1895
   337
    CDstatus status;
slouken@1895
   338
    struct cd_sub_channel sc;
slouken@1895
   339
    struct cd_subc_channel_data scd;
slouken@654
   340
slouken@654
   341
    sc.sch_address_format = CDROM_LBA_FORMAT;
slouken@1895
   342
    sc.sch_data_format = CDROM_CURRENT_POSITION;
slouken@1895
   343
    sc.sch_track_number = 0;
slouken@1895
   344
    sc.sch_alloc_length = sizeof(scd);
slouken@1895
   345
    sc.sch_buffer = (caddr_t) & scd;
slouken@1895
   346
    if (ioctl(cdrom->id, CDROM_READ_SUBCHANNEL, &sc)) {
slouken@1895
   347
        status = CD_ERROR;
slouken@1895
   348
        fprintf(stderr, "ioctl error CDROM_READ_SUBCHANNEL \n");
slouken@654
   349
    } else {
slouken@1895
   350
        switch (scd.scd_header.sh_audio_status) {
slouken@1895
   351
        case AS_AUDIO_INVALID:
slouken@1895
   352
            status = CD_STOPPED;
slouken@1895
   353
            break;
slouken@1895
   354
        case AS_PLAY_IN_PROGRESS:
slouken@1895
   355
            status = CD_PLAYING;
slouken@1895
   356
            break;
slouken@1895
   357
        case AS_PLAY_PAUSED:
slouken@1895
   358
            status = CD_PAUSED;
slouken@1895
   359
            break;
slouken@1895
   360
        case AS_PLAY_COMPLETED:
slouken@1895
   361
            status = CD_STOPPED;
slouken@1895
   362
            break;
slouken@1895
   363
        case AS_PLAY_ERROR:
slouken@1895
   364
            status = CD_ERROR;
slouken@1895
   365
            break;
slouken@1895
   366
        case AS_NO_STATUS:
slouken@1895
   367
            status = CD_STOPPED;
slouken@1895
   368
            break;
slouken@1895
   369
        default:
slouken@1895
   370
            status = CD_ERROR;
slouken@1895
   371
            break;
slouken@1895
   372
        }
slouken@654
   373
#ifdef DEBUG_CDROM
slouken@1895
   374
        fprintf(stderr, "scd.scd_header.sh_audio_status = %x\n",
slouken@1895
   375
                scd.scd_header.sh_audio_status);
slouken@654
   376
#endif
slouken@654
   377
    }
slouken@654
   378
    if (position) {
slouken@1895
   379
        if (status == CD_PLAYING || (status == CD_PAUSED)) {
slouken@1895
   380
            *position =
slouken@1895
   381
                scd.scd_position_data.scp_absaddr.lba.addr3 << 24 |
slouken@1895
   382
                scd.scd_position_data.scp_absaddr.lba.addr2 << 16 |
slouken@1895
   383
                scd.scd_position_data.scp_absaddr.lba.addr1 << 8 |
slouken@1895
   384
                scd.scd_position_data.scp_absaddr.lba.addr0;
slouken@1895
   385
        } else {
slouken@1895
   386
            *position = 0;
slouken@1895
   387
        }
slouken@654
   388
    }
slouken@654
   389
slouken@654
   390
    return status;
slouken@654
   391
}
slouken@654
   392
slouken@654
   393
/* Start play */
slouken@1895
   394
static int
slouken@1895
   395
SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length)
slouken@654
   396
{
slouken@873
   397
/*
slouken@873
   398
 * Play MSF
slouken@654
   399
 */
slouken@654
   400
    struct cd_play_audio_msf msf;
slouken@654
   401
    int end;
slouken@654
   402
slouken@654
   403
    bzero(&msf, sizeof(msf));
slouken@1895
   404
    end = start + length;
slouken@1895
   405
    FRAMES_TO_MSF(start + 150,  /* LBA = 4500*M + 75*S + F - 150 */
slouken@1895
   406
                  &msf.msf_starting_M_unit,
slouken@1895
   407
                  &msf.msf_starting_S_unit, &msf.msf_starting_F_unit);
slouken@1895
   408
    FRAMES_TO_MSF(end + 150,    /* LBA = 4500*M + 75*S + F - 150 */
slouken@1895
   409
                  &msf.msf_ending_M_unit,
slouken@1895
   410
                  &msf.msf_ending_S_unit, &msf.msf_ending_F_unit);
slouken@654
   411
slouken@1895
   412
    return (ioctl(cdrom->id, CDROM_PLAY_AUDIO_MSF, &msf));
slouken@654
   413
}
slouken@654
   414
slouken@654
   415
/* Pause play */
slouken@1895
   416
static int
slouken@1895
   417
SDL_SYS_CDPause(SDL_CD * cdrom)
slouken@654
   418
{
slouken@1895
   419
    return (ioctl(cdrom->id, CDROM_PAUSE_PLAY));
slouken@654
   420
}
slouken@654
   421
slouken@654
   422
/* Resume play */
slouken@1895
   423
static int
slouken@1895
   424
SDL_SYS_CDResume(SDL_CD * cdrom)
slouken@654
   425
{
slouken@1895
   426
    return (ioctl(cdrom->id, CDROM_RESUME_PLAY));
slouken@654
   427
}
slouken@654
   428
slouken@654
   429
/* Stop play */
slouken@1895
   430
static int
slouken@1895
   431
SDL_SYS_CDStop(SDL_CD * cdrom)
slouken@654
   432
{
slouken@1895
   433
    return (ioctl(cdrom->id, SCSI_STOP_UNIT));
slouken@654
   434
}
slouken@654
   435
slouken@654
   436
/* Eject the CD-ROM */
slouken@1895
   437
static int
slouken@1895
   438
SDL_SYS_CDEject(SDL_CD * cdrom)
slouken@654
   439
{
slouken@1895
   440
    return (ioctl(cdrom->id, CDROM_EJECT_CADDY));
slouken@654
   441
}
slouken@654
   442
slouken@654
   443
/* Close the CD-ROM handle */
slouken@1895
   444
static void
slouken@1895
   445
SDL_SYS_CDClose(SDL_CD * cdrom)
slouken@654
   446
{
slouken@654
   447
    close(cdrom->id);
slouken@654
   448
}
slouken@654
   449
slouken@1895
   450
void
slouken@1895
   451
SDL_SYS_CDQuit(void)
slouken@654
   452
{
slouken@654
   453
    int i;
slouken@654
   454
slouken@1895
   455
    if (SDL_numcds > 0) {
slouken@1895
   456
        for (i = 0; i < SDL_numcds; ++i) {
slouken@1895
   457
            SDL_free(SDL_cdlist[i]);
slouken@1895
   458
        }
slouken@1895
   459
        SDL_numcds = 0;
slouken@654
   460
    }
slouken@654
   461
}
slouken@654
   462
slouken@1635
   463
#endif /* SDL_CDROM_OSF */
slouken@1895
   464
/* vi: set ts=4 sw=4 expandtab: */