src/cdrom/osf/SDL_syscdrom.c
author Sam Lantinga <slouken@libsdl.org>
Sun, 29 Oct 2006 14:45:46 +0000
changeset 2063 dea73e1d07b0
parent 1895 c121d94672cb
child 2669 e27bdcc80744
permissions -rw-r--r--
Merged Ryan's fix, in case we need it later.
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@1895
   202
            }
slouken@1895
   203
            while (SDLcdrom);
slouken@1895
   204
            SDL_stack_free(cdpath);
slouken@1895
   205
        }
slouken@654
   206
slouken@1895
   207
        /* If we found our drives, there's nothing left to do */
slouken@1895
   208
        if (SDL_numcds > 0) {
slouken@1895
   209
            return (0);
slouken@1895
   210
        }
slouken@654
   211
    }
slouken@654
   212
    /* Scan the system for CD-ROM drives */
slouken@1895
   213
    for (i = 0; checklist[i].dir; ++i) {
slouken@1895
   214
        DIR *devdir;
slouken@1895
   215
        struct dirent *devent;
slouken@1895
   216
        int name_len;
slouken@1019
   217
slouken@1895
   218
        devdir = opendir(checklist[i].dir);
slouken@1895
   219
        if (devdir) {
slouken@1895
   220
            name_len = SDL_strlen(checklist[i].name);
slouken@1895
   221
            while (devent = readdir(devdir))
slouken@1895
   222
                if (SDL_memcmp
slouken@1895
   223
                    (checklist[i].name, devent->d_name, name_len) == 0)
slouken@1895
   224
                    if (devent->d_name[devent->d_namlen - 1] == 'c') {
slouken@1895
   225
                        SDL_snprintf(drive, SDL_arraysize(drive),
slouken@1895
   226
                                     "%s/%s", checklist[i].dir,
slouken@1895
   227
                                     devent->d_name);
slouken@1019
   228
#ifdef DEBUG_CDROM
slouken@1895
   229
                        fprintf(stderr, "Try to add drive: %s\n", drive);
slouken@1019
   230
#endif
slouken@1895
   231
                        if (CheckDrive(drive, &stbuf) > 0)
slouken@1895
   232
                            AddDrive(drive, &stbuf);
slouken@1895
   233
                    }
slouken@1895
   234
            closedir(devdir);
slouken@1895
   235
        } else {
slouken@1019
   236
#ifdef DEBUG_CDROM
slouken@1895
   237
            fprintf(stderr, "cannot open dir: %s\n", checklist[i].dir);
slouken@1019
   238
#endif
slouken@1895
   239
        }
slouken@654
   240
    }
slouken@654
   241
    return (0);
slouken@654
   242
}
slouken@654
   243
slouken@1895
   244
static const char *
slouken@1895
   245
SDL_SYS_CDName(int drive)
slouken@654
   246
{
slouken@1895
   247
    return (SDL_cdlist[drive]);
slouken@654
   248
}
slouken@654
   249
slouken@1895
   250
static int
slouken@1895
   251
SDL_SYS_CDOpen(int drive)
slouken@654
   252
{
slouken@654
   253
    /* O_RDWR: To use ioctl(fd, SCSI_STOP_UNIT) */
slouken@1895
   254
    return (open(SDL_cdlist[drive], (O_RDWR | O_NDELAY), 0));
slouken@654
   255
}
slouken@654
   256
slouken@1895
   257
static int
slouken@1895
   258
SDL_SYS_CDGetTOC(SDL_CD * cdrom)
slouken@654
   259
{
slouken@1895
   260
    struct cd_toc toc;
slouken@1895
   261
    struct cd_toc_header hdr;
slouken@1895
   262
    struct cd_toc_entry *cdte;
slouken@654
   263
    int i;
slouken@654
   264
    int okay = 0;
slouken@1895
   265
    if (ioctl(cdrom->id, CDROM_TOC_HEADER, &hdr)) {
slouken@1895
   266
        fprintf(stderr, "ioctl error CDROM_TOC_HEADER\n");
slouken@1895
   267
        return -1;
slouken@654
   268
    }
slouken@654
   269
    cdrom->numtracks = hdr.th_ending_track - hdr.th_starting_track + 1;
slouken@1895
   270
    if (cdrom->numtracks > SDL_MAX_TRACKS) {
slouken@1895
   271
        cdrom->numtracks = SDL_MAX_TRACKS;
slouken@654
   272
    }
slouken@654
   273
#ifdef DEBUG_CDROM
slouken@1895
   274
    fprintf(stderr, "hdr.th_data_len1 = %d\n", hdr.th_data_len1);
slouken@1895
   275
    fprintf(stderr, "hdr.th_data_len0 = %d\n", hdr.th_data_len0);
slouken@1895
   276
    fprintf(stderr, "hdr.th_starting_track = %d\n", hdr.th_starting_track);
slouken@1895
   277
    fprintf(stderr, "hdr.th_ending_track = %d\n", hdr.th_ending_track);
slouken@1895
   278
    fprintf(stderr, "cdrom->numtracks = %d\n", cdrom->numtracks);
slouken@654
   279
#endif
slouken@654
   280
    toc.toc_address_format = CDROM_LBA_FORMAT;
slouken@654
   281
    toc.toc_starting_track = 0;
slouken@654
   282
    toc.toc_alloc_length = (hdr.th_data_len1 << 8) +
slouken@1895
   283
        hdr.th_data_len0 + sizeof(hdr);
slouken@1895
   284
    if ((toc.toc_buffer = alloca(toc.toc_alloc_length)) == NULL) {
slouken@1895
   285
        fprintf(stderr, "cannot allocate toc.toc_buffer\n");
slouken@1895
   286
        return -1;
slouken@654
   287
    }
slouken@654
   288
slouken@1895
   289
    bzero(toc.toc_buffer, toc.toc_alloc_length);
slouken@654
   290
    if (ioctl(cdrom->id, CDROM_TOC_ENTRYS, &toc)) {
slouken@1895
   291
        fprintf(stderr, "ioctl error CDROM_TOC_ENTRYS\n");
slouken@1895
   292
        return -1;
slouken@654
   293
    }
slouken@654
   294
slouken@1895
   295
    cdte = (struct cd_toc_entry *) ((char *) toc.toc_buffer + sizeof(hdr));
slouken@1895
   296
    for (i = 0; i <= cdrom->numtracks; ++i) {
slouken@1895
   297
        if (i == cdrom->numtracks) {
slouken@1895
   298
            cdrom->track[i].id = 0xAA;;
slouken@1895
   299
        } else {
slouken@1895
   300
            cdrom->track[i].id = hdr.th_starting_track + i;
slouken@1895
   301
        }
slouken@654
   302
slouken@1895
   303
        cdrom->track[i].type = cdte[i].te_control & CDROM_DATA_TRACK;
slouken@1895
   304
        cdrom->track[i].offset =
slouken@1895
   305
            cdte[i].te_absaddr.lba.addr3 << 24 |
slouken@1895
   306
            cdte[i].te_absaddr.lba.addr2 << 16 |
slouken@1895
   307
            cdte[i].te_absaddr.lba.addr1 << 8 | cdte[i].te_absaddr.lba.addr0;
slouken@1895
   308
        cdrom->track[i].length = 0;
slouken@1895
   309
        if (i > 0) {
slouken@1895
   310
            cdrom->track[i - 1].length =
slouken@1895
   311
                cdrom->track[i].offset - cdrom->track[i - 1].offset;
slouken@1895
   312
        }
slouken@873
   313
    }
slouken@654
   314
#ifdef DEBUG_CDROM
slouken@1895
   315
    for (i = 0; i <= cdrom->numtracks; i++) {
slouken@1895
   316
        fprintf(stderr, "toc_entry[%d].te_track_number = %d\n",
slouken@1895
   317
                i, cdte[i].te_track_number);
slouken@1895
   318
        fprintf(stderr, "cdrom->track[%d].id = %d\n", i, cdrom->track[i].id);
slouken@1895
   319
        fprintf(stderr, "cdrom->track[%d].type = %x\n", i,
slouken@1895
   320
                cdrom->track[i].type);
slouken@1895
   321
        fprintf(stderr, "cdrom->track[%d].offset = %d\n", i,
slouken@1895
   322
                cdrom->track[i].offset);
slouken@1895
   323
        fprintf(stderr, "cdrom->track[%d].length = %d\n", i,
slouken@1895
   324
                cdrom->track[i].length);
slouken@1895
   325
    }
slouken@654
   326
#endif
slouken@1895
   327
    if (i == (cdrom->numtracks + 1)) {
slouken@1895
   328
        okay = 1;
slouken@654
   329
    }
slouken@654
   330
slouken@1895
   331
    return (okay ? 0 : -1);
slouken@654
   332
}
slouken@654
   333
slouken@654
   334
/* Get CD-ROM status */
slouken@1895
   335
static CDstatus
slouken@1895
   336
SDL_SYS_CDStatus(SDL_CD * cdrom, int *position)
slouken@654
   337
{
slouken@1895
   338
    CDstatus status;
slouken@1895
   339
    struct cd_sub_channel sc;
slouken@1895
   340
    struct cd_subc_channel_data scd;
slouken@654
   341
slouken@654
   342
    sc.sch_address_format = CDROM_LBA_FORMAT;
slouken@1895
   343
    sc.sch_data_format = CDROM_CURRENT_POSITION;
slouken@1895
   344
    sc.sch_track_number = 0;
slouken@1895
   345
    sc.sch_alloc_length = sizeof(scd);
slouken@1895
   346
    sc.sch_buffer = (caddr_t) & scd;
slouken@1895
   347
    if (ioctl(cdrom->id, CDROM_READ_SUBCHANNEL, &sc)) {
slouken@1895
   348
        status = CD_ERROR;
slouken@1895
   349
        fprintf(stderr, "ioctl error CDROM_READ_SUBCHANNEL \n");
slouken@654
   350
    } else {
slouken@1895
   351
        switch (scd.scd_header.sh_audio_status) {
slouken@1895
   352
        case AS_AUDIO_INVALID:
slouken@1895
   353
            status = CD_STOPPED;
slouken@1895
   354
            break;
slouken@1895
   355
        case AS_PLAY_IN_PROGRESS:
slouken@1895
   356
            status = CD_PLAYING;
slouken@1895
   357
            break;
slouken@1895
   358
        case AS_PLAY_PAUSED:
slouken@1895
   359
            status = CD_PAUSED;
slouken@1895
   360
            break;
slouken@1895
   361
        case AS_PLAY_COMPLETED:
slouken@1895
   362
            status = CD_STOPPED;
slouken@1895
   363
            break;
slouken@1895
   364
        case AS_PLAY_ERROR:
slouken@1895
   365
            status = CD_ERROR;
slouken@1895
   366
            break;
slouken@1895
   367
        case AS_NO_STATUS:
slouken@1895
   368
            status = CD_STOPPED;
slouken@1895
   369
            break;
slouken@1895
   370
        default:
slouken@1895
   371
            status = CD_ERROR;
slouken@1895
   372
            break;
slouken@1895
   373
        }
slouken@654
   374
#ifdef DEBUG_CDROM
slouken@1895
   375
        fprintf(stderr, "scd.scd_header.sh_audio_status = %x\n",
slouken@1895
   376
                scd.scd_header.sh_audio_status);
slouken@654
   377
#endif
slouken@654
   378
    }
slouken@654
   379
    if (position) {
slouken@1895
   380
        if (status == CD_PLAYING || (status == CD_PAUSED)) {
slouken@1895
   381
            *position =
slouken@1895
   382
                scd.scd_position_data.scp_absaddr.lba.addr3 << 24 |
slouken@1895
   383
                scd.scd_position_data.scp_absaddr.lba.addr2 << 16 |
slouken@1895
   384
                scd.scd_position_data.scp_absaddr.lba.addr1 << 8 |
slouken@1895
   385
                scd.scd_position_data.scp_absaddr.lba.addr0;
slouken@1895
   386
        } else {
slouken@1895
   387
            *position = 0;
slouken@1895
   388
        }
slouken@654
   389
    }
slouken@654
   390
slouken@654
   391
    return status;
slouken@654
   392
}
slouken@654
   393
slouken@654
   394
/* Start play */
slouken@1895
   395
static int
slouken@1895
   396
SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length)
slouken@654
   397
{
slouken@873
   398
/*
slouken@873
   399
 * Play MSF
slouken@654
   400
 */
slouken@654
   401
    struct cd_play_audio_msf msf;
slouken@654
   402
    int end;
slouken@654
   403
slouken@654
   404
    bzero(&msf, sizeof(msf));
slouken@1895
   405
    end = start + length;
slouken@1895
   406
    FRAMES_TO_MSF(start + 150,  /* LBA = 4500*M + 75*S + F - 150 */
slouken@1895
   407
                  &msf.msf_starting_M_unit,
slouken@1895
   408
                  &msf.msf_starting_S_unit, &msf.msf_starting_F_unit);
slouken@1895
   409
    FRAMES_TO_MSF(end + 150,    /* LBA = 4500*M + 75*S + F - 150 */
slouken@1895
   410
                  &msf.msf_ending_M_unit,
slouken@1895
   411
                  &msf.msf_ending_S_unit, &msf.msf_ending_F_unit);
slouken@654
   412
slouken@1895
   413
    return (ioctl(cdrom->id, CDROM_PLAY_AUDIO_MSF, &msf));
slouken@654
   414
}
slouken@654
   415
slouken@654
   416
/* Pause play */
slouken@1895
   417
static int
slouken@1895
   418
SDL_SYS_CDPause(SDL_CD * cdrom)
slouken@654
   419
{
slouken@1895
   420
    return (ioctl(cdrom->id, CDROM_PAUSE_PLAY));
slouken@654
   421
}
slouken@654
   422
slouken@654
   423
/* Resume play */
slouken@1895
   424
static int
slouken@1895
   425
SDL_SYS_CDResume(SDL_CD * cdrom)
slouken@654
   426
{
slouken@1895
   427
    return (ioctl(cdrom->id, CDROM_RESUME_PLAY));
slouken@654
   428
}
slouken@654
   429
slouken@654
   430
/* Stop play */
slouken@1895
   431
static int
slouken@1895
   432
SDL_SYS_CDStop(SDL_CD * cdrom)
slouken@654
   433
{
slouken@1895
   434
    return (ioctl(cdrom->id, SCSI_STOP_UNIT));
slouken@654
   435
}
slouken@654
   436
slouken@654
   437
/* Eject the CD-ROM */
slouken@1895
   438
static int
slouken@1895
   439
SDL_SYS_CDEject(SDL_CD * cdrom)
slouken@654
   440
{
slouken@1895
   441
    return (ioctl(cdrom->id, CDROM_EJECT_CADDY));
slouken@654
   442
}
slouken@654
   443
slouken@654
   444
/* Close the CD-ROM handle */
slouken@1895
   445
static void
slouken@1895
   446
SDL_SYS_CDClose(SDL_CD * cdrom)
slouken@654
   447
{
slouken@654
   448
    close(cdrom->id);
slouken@654
   449
}
slouken@654
   450
slouken@1895
   451
void
slouken@1895
   452
SDL_SYS_CDQuit(void)
slouken@654
   453
{
slouken@654
   454
    int i;
slouken@654
   455
slouken@1895
   456
    if (SDL_numcds > 0) {
slouken@1895
   457
        for (i = 0; i < SDL_numcds; ++i) {
slouken@1895
   458
            SDL_free(SDL_cdlist[i]);
slouken@1895
   459
        }
slouken@1895
   460
        SDL_numcds = 0;
slouken@654
   461
    }
slouken@654
   462
}
slouken@654
   463
slouken@1635
   464
#endif /* SDL_CDROM_OSF */
slouken@1895
   465
/* vi: set ts=4 sw=4 expandtab: */