src/cdrom/osf/SDL_syscdrom.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 29 May 2006 04:04:35 +0000
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
permissions -rw-r--r--
more tweaking indent options
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@1668
    48
static const char *SDL_SYS_CDName(int drive);
slouken@1668
    49
static int SDL_SYS_CDOpen(int drive);
slouken@1668
    50
static int SDL_SYS_CDGetTOC(SDL_CD * cdrom);
slouken@1668
    51
static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position);
slouken@1668
    52
static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length);
slouken@1668
    53
static int SDL_SYS_CDPause(SDL_CD * cdrom);
slouken@1668
    54
static int SDL_SYS_CDResume(SDL_CD * cdrom);
slouken@1668
    55
static int SDL_SYS_CDStop(SDL_CD * cdrom);
slouken@1668
    56
static int SDL_SYS_CDEject(SDL_CD * cdrom);
slouken@1668
    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@1662
    60
/* Caution!! Not tested. */
slouken@1662
    61
static int
slouken@1668
    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@1662
    69
    char *devtype[] = { "Disk", "Tape", "Printer", "Processor", "WORM",
slouken@1662
    70
        "CD-ROM", "Scanner", "Optical", "Changer", "Comm", "Unknown"
slouken@1662
    71
    };
slouken@873
    72
#endif
slouken@873
    73
slouken@1668
    74
    bzero(&msp, sizeof(msp));
slouken@1668
    75
    bzero(&inq, sizeof(inq));
slouken@654
    76
slouken@654
    77
    /* If it doesn't exist, return -1 */
slouken@1668
    78
    if (stat(drive, stbuf) < 0) {
slouken@1662
    79
        return (-1);
slouken@654
    80
    }
slouken@654
    81
slouken@1668
    82
    if ((cdfd = open(drive, (O_RDWR | O_NDELAY), 0)) >= 0) {
slouken@1662
    83
        msp.msp_addr = (caddr_t) & inq;
slouken@1662
    84
        msp.msp_pgcode = 0;
slouken@1662
    85
        msp.msp_pgctrl = 0;
slouken@1668
    86
        msp.msp_length = sizeof(inq);
slouken@1662
    87
        msp.msp_setps = 0;
slouken@654
    88
slouken@1668
    89
        if (ioctl(cdfd, SCSI_GET_INQUIRY_DATA, &msp))
slouken@1662
    90
            return (0);
slouken@873
    91
slouken@873
    92
#ifdef DEBUG_CDROM
slouken@1668
    93
        fprintf(stderr, "Device Type: %s\n", devtype[inq.perfdt]);
slouken@1668
    94
        fprintf(stderr, "Vendor: %.8s\n", inq.vndrid);
slouken@1668
    95
        fprintf(stderr, "Product: %.8s\n", inq.prodid);
slouken@1668
    96
        fprintf(stderr, "Revision: %.8s\n", inq.revlvl);
slouken@873
    97
#endif
slouken@1662
    98
        if (inq.perfdt == DTYPE_RODIRECT)
slouken@1662
    99
            is_cd = 1;
slouken@654
   100
    }
slouken@654
   101
slouken@1662
   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@1662
   106
static void
slouken@1668
   107
AddDrive(char *drive, struct stat *stbuf)
slouken@654
   108
{
slouken@654
   109
    int i;
slouken@654
   110
slouken@1662
   111
    if (SDL_numcds < MAX_DRIVES) {
slouken@1662
   112
        /* Check to make sure it's not already in our list.
slouken@1662
   113
         * This can happen when we see a drive via symbolic link.
slouken@1662
   114
         *
slouken@1662
   115
         */
slouken@1662
   116
        for (i = 0; i < SDL_numcds; ++i) {
slouken@1662
   117
            if (stbuf->st_rdev == SDL_cdmode[i]) {
slouken@654
   118
#ifdef DEBUG_CDROM
slouken@1668
   119
                fprintf(stderr, "Duplicate drive detected: %s == %s\n",
slouken@1668
   120
                        drive, SDL_cdlist[i]);
slouken@654
   121
#endif
slouken@1662
   122
                return;
slouken@1662
   123
            }
slouken@1662
   124
        }
slouken@654
   125
slouken@1662
   126
        /* Add this drive to our list */
slouken@1662
   127
        i = SDL_numcds;
slouken@1668
   128
        SDL_cdlist[i] = SDL_strdup(drive);
slouken@1662
   129
        if (SDL_cdlist[i] == NULL) {
slouken@1668
   130
            SDL_OutOfMemory();
slouken@1662
   131
            return;
slouken@1662
   132
        }
slouken@1662
   133
        SDL_cdmode[i] = stbuf->st_rdev;
slouken@1662
   134
        ++SDL_numcds;
slouken@654
   135
#ifdef DEBUG_CDROM
slouken@1668
   136
        fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
slouken@654
   137
#endif
slouken@654
   138
    }
slouken@654
   139
}
slouken@654
   140
slouken@1662
   141
int
slouken@1668
   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@1662
   153
    struct
slouken@1662
   154
    {
slouken@1662
   155
        char *dir;
slouken@1662
   156
        char *name;
slouken@1019
   157
    } checklist[] = {
slouken@1662
   158
        {
slouken@1662
   159
        "/dev/rdisk", "cdrom"}, {
slouken@1662
   160
        "/dev", "rrz"}, {
slouken@1662
   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@1662
   168
    SDL_CDcaps.Name = SDL_SYS_CDName;
slouken@1662
   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@1662
   172
    SDL_CDcaps.Play = SDL_SYS_CDPlay;
slouken@1662
   173
    SDL_CDcaps.Pause = SDL_SYS_CDPause;
slouken@654
   174
    SDL_CDcaps.Resume = SDL_SYS_CDResume;
slouken@1662
   175
    SDL_CDcaps.Stop = SDL_SYS_CDStop;
slouken@1662
   176
    SDL_CDcaps.Eject = SDL_SYS_CDEject;
slouken@1662
   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@1668
   181
    SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */
slouken@1662
   182
    if (SDLcdrom != NULL) {
slouken@1662
   183
        char *cdpath, *delim;
slouken@1668
   184
        size_t len = SDL_strlen(SDLcdrom) + 1;
slouken@1668
   185
        cdpath = SDL_stack_alloc(char, len);
slouken@1662
   186
        if (cdpath != NULL) {
slouken@1668
   187
            SDL_strlcpy(cdpath, SDLcdrom, len);
slouken@1662
   188
            SDLcdrom = cdpath;
slouken@1662
   189
            do {
slouken@1668
   190
                delim = SDL_strchr(SDLcdrom, ':');
slouken@1662
   191
                if (delim) {
slouken@1662
   192
                    *delim++ = '\0';
slouken@1662
   193
                }
slouken@1668
   194
                if (CheckDrive(SDLcdrom, &stbuf) > 0) {
slouken@1668
   195
                    AddDrive(SDLcdrom, &stbuf);
slouken@1662
   196
                }
slouken@1662
   197
                if (delim) {
slouken@1662
   198
                    SDLcdrom = delim;
slouken@1662
   199
                } else {
slouken@1662
   200
                    SDLcdrom = NULL;
slouken@1662
   201
                }
slouken@1662
   202
            }
slouken@1662
   203
            while (SDLcdrom);
slouken@1668
   204
            SDL_stack_free(cdpath);
slouken@1662
   205
        }
slouken@654
   206
slouken@1662
   207
        /* If we found our drives, there's nothing left to do */
slouken@1662
   208
        if (SDL_numcds > 0) {
slouken@1662
   209
            return (0);
slouken@1662
   210
        }
slouken@654
   211
    }
slouken@654
   212
    /* Scan the system for CD-ROM drives */
slouken@1662
   213
    for (i = 0; checklist[i].dir; ++i) {
slouken@1662
   214
        DIR *devdir;
slouken@1662
   215
        struct dirent *devent;
slouken@1662
   216
        int name_len;
slouken@1019
   217
slouken@1668
   218
        devdir = opendir(checklist[i].dir);
slouken@1662
   219
        if (devdir) {
slouken@1668
   220
            name_len = SDL_strlen(checklist[i].name);
slouken@1668
   221
            while (devent = readdir(devdir))
slouken@1662
   222
                if (SDL_memcmp
slouken@1662
   223
                    (checklist[i].name, devent->d_name, name_len) == 0)
slouken@1662
   224
                    if (devent->d_name[devent->d_namlen - 1] == 'c') {
slouken@1668
   225
                        SDL_snprintf(drive, SDL_arraysize(drive),
slouken@1668
   226
                                     "%s/%s", checklist[i].dir,
slouken@1668
   227
                                     devent->d_name);
slouken@1019
   228
#ifdef DEBUG_CDROM
slouken@1668
   229
                        fprintf(stderr, "Try to add drive: %s\n", drive);
slouken@1019
   230
#endif
slouken@1668
   231
                        if (CheckDrive(drive, &stbuf) > 0)
slouken@1668
   232
                            AddDrive(drive, &stbuf);
slouken@1662
   233
                    }
slouken@1668
   234
            closedir(devdir);
slouken@1662
   235
        } else {
slouken@1019
   236
#ifdef DEBUG_CDROM
slouken@1668
   237
            fprintf(stderr, "cannot open dir: %s\n", checklist[i].dir);
slouken@1019
   238
#endif
slouken@1662
   239
        }
slouken@654
   240
    }
slouken@654
   241
    return (0);
slouken@654
   242
}
slouken@654
   243
slouken@1662
   244
static const char *
slouken@1668
   245
SDL_SYS_CDName(int drive)
slouken@654
   246
{
slouken@1662
   247
    return (SDL_cdlist[drive]);
slouken@654
   248
}
slouken@654
   249
slouken@1662
   250
static int
slouken@1668
   251
SDL_SYS_CDOpen(int drive)
slouken@654
   252
{
slouken@654
   253
    /* O_RDWR: To use ioctl(fd, SCSI_STOP_UNIT) */
slouken@1668
   254
    return (open(SDL_cdlist[drive], (O_RDWR | O_NDELAY), 0));
slouken@654
   255
}
slouken@654
   256
slouken@1662
   257
static int
slouken@1668
   258
SDL_SYS_CDGetTOC(SDL_CD * cdrom)
slouken@654
   259
{
slouken@1662
   260
    struct cd_toc toc;
slouken@1662
   261
    struct cd_toc_header hdr;
slouken@1662
   262
    struct cd_toc_entry *cdte;
slouken@654
   263
    int i;
slouken@654
   264
    int okay = 0;
slouken@1668
   265
    if (ioctl(cdrom->id, CDROM_TOC_HEADER, &hdr)) {
slouken@1668
   266
        fprintf(stderr, "ioctl error CDROM_TOC_HEADER\n");
slouken@1662
   267
        return -1;
slouken@654
   268
    }
slouken@654
   269
    cdrom->numtracks = hdr.th_ending_track - hdr.th_starting_track + 1;
slouken@1662
   270
    if (cdrom->numtracks > SDL_MAX_TRACKS) {
slouken@1662
   271
        cdrom->numtracks = SDL_MAX_TRACKS;
slouken@654
   272
    }
slouken@654
   273
#ifdef DEBUG_CDROM
slouken@1668
   274
    fprintf(stderr, "hdr.th_data_len1 = %d\n", hdr.th_data_len1);
slouken@1668
   275
    fprintf(stderr, "hdr.th_data_len0 = %d\n", hdr.th_data_len0);
slouken@1668
   276
    fprintf(stderr, "hdr.th_starting_track = %d\n", hdr.th_starting_track);
slouken@1668
   277
    fprintf(stderr, "hdr.th_ending_track = %d\n", hdr.th_ending_track);
slouken@1668
   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@1668
   283
        hdr.th_data_len0 + sizeof(hdr);
slouken@1668
   284
    if ((toc.toc_buffer = alloca(toc.toc_alloc_length)) == NULL) {
slouken@1668
   285
        fprintf(stderr, "cannot allocate toc.toc_buffer\n");
slouken@1662
   286
        return -1;
slouken@654
   287
    }
slouken@654
   288
slouken@1668
   289
    bzero(toc.toc_buffer, toc.toc_alloc_length);
slouken@1668
   290
    if (ioctl(cdrom->id, CDROM_TOC_ENTRYS, &toc)) {
slouken@1668
   291
        fprintf(stderr, "ioctl error CDROM_TOC_ENTRYS\n");
slouken@1662
   292
        return -1;
slouken@654
   293
    }
slouken@654
   294
slouken@1668
   295
    cdte = (struct cd_toc_entry *) ((char *) toc.toc_buffer + sizeof(hdr));
slouken@1662
   296
    for (i = 0; i <= cdrom->numtracks; ++i) {
slouken@1662
   297
        if (i == cdrom->numtracks) {
slouken@1662
   298
            cdrom->track[i].id = 0xAA;;
slouken@1662
   299
        } else {
slouken@1662
   300
            cdrom->track[i].id = hdr.th_starting_track + i;
slouken@1662
   301
        }
slouken@654
   302
slouken@1662
   303
        cdrom->track[i].type = cdte[i].te_control & CDROM_DATA_TRACK;
slouken@1662
   304
        cdrom->track[i].offset =
slouken@1662
   305
            cdte[i].te_absaddr.lba.addr3 << 24 |
slouken@1662
   306
            cdte[i].te_absaddr.lba.addr2 << 16 |
slouken@1662
   307
            cdte[i].te_absaddr.lba.addr1 << 8 | cdte[i].te_absaddr.lba.addr0;
slouken@1662
   308
        cdrom->track[i].length = 0;
slouken@1662
   309
        if (i > 0) {
slouken@1662
   310
            cdrom->track[i - 1].length =
slouken@1662
   311
                cdrom->track[i].offset - cdrom->track[i - 1].offset;
slouken@1662
   312
        }
slouken@873
   313
    }
slouken@654
   314
#ifdef DEBUG_CDROM
slouken@1662
   315
    for (i = 0; i <= cdrom->numtracks; i++) {
slouken@1668
   316
        fprintf(stderr, "toc_entry[%d].te_track_number = %d\n",
slouken@1668
   317
                i, cdte[i].te_track_number);
slouken@1668
   318
        fprintf(stderr, "cdrom->track[%d].id = %d\n", i, cdrom->track[i].id);
slouken@1668
   319
        fprintf(stderr, "cdrom->track[%d].type = %x\n", i,
slouken@1668
   320
                cdrom->track[i].type);
slouken@1668
   321
        fprintf(stderr, "cdrom->track[%d].offset = %d\n", i,
slouken@1668
   322
                cdrom->track[i].offset);
slouken@1668
   323
        fprintf(stderr, "cdrom->track[%d].length = %d\n", i,
slouken@1668
   324
                cdrom->track[i].length);
slouken@1662
   325
    }
slouken@654
   326
#endif
slouken@1662
   327
    if (i == (cdrom->numtracks + 1)) {
slouken@1662
   328
        okay = 1;
slouken@654
   329
    }
slouken@654
   330
slouken@1662
   331
    return (okay ? 0 : -1);
slouken@654
   332
}
slouken@654
   333
slouken@654
   334
/* Get CD-ROM status */
slouken@1662
   335
static CDstatus
slouken@1668
   336
SDL_SYS_CDStatus(SDL_CD * cdrom, int *position)
slouken@654
   337
{
slouken@1662
   338
    CDstatus status;
slouken@1662
   339
    struct cd_sub_channel sc;
slouken@1662
   340
    struct cd_subc_channel_data scd;
slouken@654
   341
slouken@654
   342
    sc.sch_address_format = CDROM_LBA_FORMAT;
slouken@1662
   343
    sc.sch_data_format = CDROM_CURRENT_POSITION;
slouken@1662
   344
    sc.sch_track_number = 0;
slouken@1668
   345
    sc.sch_alloc_length = sizeof(scd);
slouken@1662
   346
    sc.sch_buffer = (caddr_t) & scd;
slouken@1668
   347
    if (ioctl(cdrom->id, CDROM_READ_SUBCHANNEL, &sc)) {
slouken@1662
   348
        status = CD_ERROR;
slouken@1668
   349
        fprintf(stderr, "ioctl error CDROM_READ_SUBCHANNEL \n");
slouken@654
   350
    } else {
slouken@1662
   351
        switch (scd.scd_header.sh_audio_status) {
slouken@1662
   352
        case AS_AUDIO_INVALID:
slouken@1662
   353
            status = CD_STOPPED;
slouken@1662
   354
            break;
slouken@1662
   355
        case AS_PLAY_IN_PROGRESS:
slouken@1662
   356
            status = CD_PLAYING;
slouken@1662
   357
            break;
slouken@1662
   358
        case AS_PLAY_PAUSED:
slouken@1662
   359
            status = CD_PAUSED;
slouken@1662
   360
            break;
slouken@1662
   361
        case AS_PLAY_COMPLETED:
slouken@1662
   362
            status = CD_STOPPED;
slouken@1662
   363
            break;
slouken@1662
   364
        case AS_PLAY_ERROR:
slouken@1662
   365
            status = CD_ERROR;
slouken@1662
   366
            break;
slouken@1662
   367
        case AS_NO_STATUS:
slouken@1662
   368
            status = CD_STOPPED;
slouken@1662
   369
            break;
slouken@1662
   370
        default:
slouken@1662
   371
            status = CD_ERROR;
slouken@1662
   372
            break;
slouken@1662
   373
        }
slouken@654
   374
#ifdef DEBUG_CDROM
slouken@1668
   375
        fprintf(stderr, "scd.scd_header.sh_audio_status = %x\n",
slouken@1668
   376
                scd.scd_header.sh_audio_status);
slouken@654
   377
#endif
slouken@654
   378
    }
slouken@654
   379
    if (position) {
slouken@1662
   380
        if (status == CD_PLAYING || (status == CD_PAUSED)) {
slouken@1662
   381
            *position =
slouken@1662
   382
                scd.scd_position_data.scp_absaddr.lba.addr3 << 24 |
slouken@1662
   383
                scd.scd_position_data.scp_absaddr.lba.addr2 << 16 |
slouken@1662
   384
                scd.scd_position_data.scp_absaddr.lba.addr1 << 8 |
slouken@1662
   385
                scd.scd_position_data.scp_absaddr.lba.addr0;
slouken@1662
   386
        } else {
slouken@1662
   387
            *position = 0;
slouken@1662
   388
        }
slouken@654
   389
    }
slouken@654
   390
slouken@654
   391
    return status;
slouken@654
   392
}
slouken@654
   393
slouken@654
   394
/* Start play */
slouken@1662
   395
static int
slouken@1668
   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@1668
   404
    bzero(&msf, sizeof(msf));
slouken@1662
   405
    end = start + length;
slouken@1668
   406
    FRAMES_TO_MSF(start + 150,  /* LBA = 4500*M + 75*S + F - 150 */
slouken@1668
   407
                  &msf.msf_starting_M_unit,
slouken@1668
   408
                  &msf.msf_starting_S_unit, &msf.msf_starting_F_unit);
slouken@1668
   409
    FRAMES_TO_MSF(end + 150,    /* LBA = 4500*M + 75*S + F - 150 */
slouken@1668
   410
                  &msf.msf_ending_M_unit,
slouken@1668
   411
                  &msf.msf_ending_S_unit, &msf.msf_ending_F_unit);
slouken@654
   412
slouken@1668
   413
    return (ioctl(cdrom->id, CDROM_PLAY_AUDIO_MSF, &msf));
slouken@654
   414
}
slouken@654
   415
slouken@654
   416
/* Pause play */
slouken@1662
   417
static int
slouken@1668
   418
SDL_SYS_CDPause(SDL_CD * cdrom)
slouken@654
   419
{
slouken@1668
   420
    return (ioctl(cdrom->id, CDROM_PAUSE_PLAY));
slouken@654
   421
}
slouken@654
   422
slouken@654
   423
/* Resume play */
slouken@1662
   424
static int
slouken@1668
   425
SDL_SYS_CDResume(SDL_CD * cdrom)
slouken@654
   426
{
slouken@1668
   427
    return (ioctl(cdrom->id, CDROM_RESUME_PLAY));
slouken@654
   428
}
slouken@654
   429
slouken@654
   430
/* Stop play */
slouken@1662
   431
static int
slouken@1668
   432
SDL_SYS_CDStop(SDL_CD * cdrom)
slouken@654
   433
{
slouken@1668
   434
    return (ioctl(cdrom->id, SCSI_STOP_UNIT));
slouken@654
   435
}
slouken@654
   436
slouken@654
   437
/* Eject the CD-ROM */
slouken@1662
   438
static int
slouken@1668
   439
SDL_SYS_CDEject(SDL_CD * cdrom)
slouken@654
   440
{
slouken@1668
   441
    return (ioctl(cdrom->id, CDROM_EJECT_CADDY));
slouken@654
   442
}
slouken@654
   443
slouken@654
   444
/* Close the CD-ROM handle */
slouken@1662
   445
static void
slouken@1668
   446
SDL_SYS_CDClose(SDL_CD * cdrom)
slouken@654
   447
{
slouken@1668
   448
    close(cdrom->id);
slouken@654
   449
}
slouken@654
   450
slouken@1662
   451
void
slouken@1668
   452
SDL_SYS_CDQuit(void)
slouken@654
   453
{
slouken@654
   454
    int i;
slouken@654
   455
slouken@1662
   456
    if (SDL_numcds > 0) {
slouken@1662
   457
        for (i = 0; i < SDL_numcds; ++i) {
slouken@1668
   458
            SDL_free(SDL_cdlist[i]);
slouken@1662
   459
        }
slouken@1662
   460
        SDL_numcds = 0;
slouken@654
   461
    }
slouken@654
   462
}
slouken@654
   463
slouken@1635
   464
#endif /* SDL_CDROM_OSF */
slouken@1662
   465
/* vi: set ts=4 sw=4 expandtab: */