Date: Sun, 07 Mar 2004 22:54:11 +0900
authorSam Lantinga <slouken@libsdl.org>
Sun, 07 Mar 2004 16:40:15 +0000
changeset 87389666943c598
parent 872 e7be95d758e8
child 874 9719e7f51a3a
Date: Sun, 07 Mar 2004 22:54:11 +0900
From: Hayashi Naoyuki
Subject: Tru64 cdrom and pthread option fix

SDL-1.2.7/src/cdrom/osf/SDL_syscdrom.c Fixes
Some CD-ROM drives(ex. TEAC CD-532E) cannot play
first 150 frames(aka gap).
CheckDrive() fix.
The end of comment is "* /" in AddDrive().

SDL-1.2.7/configure.in Fixes
Add *-*-osf pthread option and
delete line SDL_LIBS="$SDL_LIBS -lrt".
configure.in
src/cdrom/osf/SDL_syscdrom.c
     1.1 --- a/configure.in	Sat Mar 06 02:58:06 2004 +0000
     1.2 +++ b/configure.in	Sun Mar 07 16:40:15 2004 +0000
     1.3 @@ -1217,6 +1217,15 @@
     1.4              pthread_cflags=""
     1.5              pthread_lib=""
     1.6              ;;
     1.7 +        *-*-osf*)
     1.8 +            if test x$ac_cv_prog_gcc = xyes; then
     1.9 +                pthread_cflags="-D_REENTRANT"
    1.10 +                pthread_lib="-lpthread -lrt"
    1.11 +            else
    1.12 +                pthread_cflags="-pthread"
    1.13 +                pthread_lib="-lpthread -lrt"
    1.14 +            fi
    1.15 +            ;;
    1.16          *)
    1.17              pthread_cflags="-D_REENTRANT"
    1.18              pthread_lib="-lpthread"
    1.19 @@ -2268,7 +2277,6 @@
    1.20          CheckOpenGL
    1.21          CheckPTHREAD
    1.22          CheckSIGACTION
    1.23 -        SDL_LIBS="$SDL_LIBS -lrt"
    1.24          # Set up files for the audio library
    1.25          if test x$enable_audio = xyes; then
    1.26              CFLAGS="$CFLAGS -I/usr/include/mme -DMMEAUDIO_SUPPORT"
     2.1 --- a/src/cdrom/osf/SDL_syscdrom.c	Sat Mar 06 02:58:06 2004 +0000
     2.2 +++ b/src/cdrom/osf/SDL_syscdrom.c	Sun Mar 07 16:40:15 2004 +0000
     2.3 @@ -59,46 +59,45 @@
     2.4  static int         SDL_SYS_CDEject(SDL_CD *cdrom);
     2.5  static void        SDL_SYS_CDClose(SDL_CD *cdrom);
     2.6  
     2.7 -/* Some ioctl() errno values which occur when the tray is empty */
     2.8 -#define ERRNO_TRAYEMPTY(errno)	\
     2.9 -    ((errno == EIO) || (errno == ENOENT) || (errno == EINVAL))
    2.10 -
    2.11  /* Check a drive to see if it is a CD-ROM */
    2.12  /* Caution!! Not tested. */ 
    2.13  static int CheckDrive(char *drive, struct stat *stbuf)
    2.14  {
    2.15 -    int is_cd, cdfd;
    2.16 -    struct cd_sub_channel info;
    2.17 +    int cdfd, is_cd = 0;
    2.18 +    struct mode_sel_sns_params msp;
    2.19 +    struct inquiry_info inq;
    2.20 +
    2.21 +#ifdef DEBUG_CDROM
    2.22 +    char *devtype[] = {"Disk", "Tape", "Printer", "Processor", "WORM",
    2.23 +	"CD-ROM", "Scanner", "Optical", "Changer", "Comm", "Unknown"};
    2.24 +#endif
    2.25 +
    2.26 +    bzero(&msp, sizeof(msp));
    2.27 +    bzero(&inq, sizeof(inq));
    2.28  
    2.29      /* If it doesn't exist, return -1 */
    2.30      if ( stat(drive, stbuf) < 0 ) {
    2.31  	return(-1);
    2.32      }
    2.33  
    2.34 -    /* If it does exist, verify that it's an available CD-ROM */
    2.35 -    is_cd = 0;
    2.36 -    if ( S_ISCHR(stbuf->st_mode) || S_ISBLK(stbuf->st_mode) ) {
    2.37 -	cdfd = open(drive, (O_RDWR|O_NDELAY), 0);
    2.38 -	if ( cdfd >= 0 ) {
    2.39 -	    info.sch_address_format = CDROM_MSF_FORMAT;
    2.40 -	    info.sch_data_format = CDROM_CURRENT_POSITION;
    2.41 -	    info.sch_alloc_length = 0;
    2.42 -	    info.sch_track_number = 0;
    2.43 -	    info.sch_buffer = NULL;
    2.44 -	    /*
    2.45 -	     *
    2.46 -	     * Under Linux, EIO occurs when a disk is not present.
    2.47 -	     * This isn't 100% reliable, so we use the USE_MNTENT
    2.48 -	     * code above instead.
    2.49 -	     *
    2.50 -	     */
    2.51 -	    if ( (ioctl(cdfd, CDROM_READ_SUBCHANNEL, &info) == 0) ||
    2.52 -		    ERRNO_TRAYEMPTY(errno) ) {
    2.53 -		is_cd = 1;
    2.54 -	    }
    2.55 +    if ( (cdfd = open(drive, (O_RDWR|O_NDELAY), 0)) >= 0 ) {
    2.56 +	msp.msp_addr   =   (caddr_t) &inq;
    2.57 +	msp.msp_pgcode =                0;
    2.58 +	msp.msp_pgctrl =                0;
    2.59 +	msp.msp_length =      sizeof(inq);
    2.60 +	msp.msp_setps  =                0;
    2.61  
    2.62 -	    close(cdfd);
    2.63 -	}
    2.64 +	if ( ioctl(cdfd, SCSI_GET_INQUIRY_DATA, &msp) )
    2.65 +	    return (0);
    2.66 +
    2.67 +#ifdef DEBUG_CDROM
    2.68 +	fprintf(stderr, "Device Type: %s\n", devtype[inq.perfdt]);
    2.69 +	fprintf(stderr, "Vendor: %.8s\n", inq.vndrid);
    2.70 +	fprintf(stderr, "Product: %.8s\n", inq.prodid);
    2.71 +	fprintf(stderr, "Revision: %.8s\n", inq.revlvl);
    2.72 +#endif
    2.73 +	if ( inq.perfdt == DTYPE_RODIRECT )
    2.74 +	    is_cd = 1;
    2.75      }
    2.76  
    2.77      return(is_cd);
    2.78 @@ -113,7 +112,7 @@
    2.79  	/* Check to make sure it's not already in our list.
    2.80  	 * This can happen when we see a drive via symbolic link.
    2.81  	 *
    2.82 -	 * /
    2.83 +	 */
    2.84  	for ( i=0; i<SDL_numcds; ++i ) {
    2.85  	    if ( stbuf->st_rdev == SDL_cdmode[i] ) {
    2.86  #ifdef DEBUG_CDROM
    2.87 @@ -142,8 +141,7 @@
    2.88  
    2.89  int  SDL_SYS_CDInit(void)
    2.90  {
    2.91 -    /* checklist: /dev/cdrom,/dev/cd?c /dev/acd?c
    2.92 -     * /dev/matcd?c /dev/mcd?c /dev/scd?c
    2.93 +    /* checklist: /dev/rdisk/cdrom?c
    2.94       *
    2.95       */
    2.96      static char *checklist[] = {
    2.97 @@ -287,28 +285,28 @@
    2.98  	return -1;
    2.99      }
   2.100  
   2.101 -    (char *)cdte = toc.toc_buffer + sizeof(hdr);
   2.102 -	for (i=0; i <= cdrom->numtracks; ++i) {
   2.103 -	    if (i == cdrom->numtracks ) {
   2.104 -		cdrom->track[i].id = 0xAA;;
   2.105 -	    } else {
   2.106 -		cdrom->track[i].id = hdr.th_starting_track + i;
   2.107 -	    }
   2.108 +    cdte =(struct cd_toc_entry *) ((char *) toc.toc_buffer + sizeof(hdr));
   2.109 +    for (i=0; i <= cdrom->numtracks; ++i) {
   2.110 +	if (i == cdrom->numtracks ) {
   2.111 +	    cdrom->track[i].id = 0xAA;;
   2.112 +	} else {
   2.113 +	    cdrom->track[i].id = hdr.th_starting_track + i;
   2.114 +	}
   2.115  
   2.116 -	    cdrom->track[i].type =
   2.117 -		cdte[i].te_control & CDROM_DATA_TRACK;
   2.118 -	    cdrom->track[i].offset =
   2.119 -		cdte[i].te_absaddr.lba.addr3 << 24 |
   2.120 -		cdte[i].te_absaddr.lba.addr2 << 16 |
   2.121 -		cdte[i].te_absaddr.lba.addr1 << 8  |
   2.122 -		cdte[i].te_absaddr.lba.addr0;
   2.123 -	    cdrom->track[i].length = 0;
   2.124 -	    if ( i > 0 ) {
   2.125 -		cdrom->track[i - 1].length =
   2.126 -		    cdrom->track[i].offset -
   2.127 -		    cdrom->track[i - 1].offset;
   2.128 -	    }
   2.129 +	cdrom->track[i].type =
   2.130 +	    cdte[i].te_control & CDROM_DATA_TRACK;
   2.131 +	cdrom->track[i].offset =
   2.132 +	    cdte[i].te_absaddr.lba.addr3 << 24 |
   2.133 +	    cdte[i].te_absaddr.lba.addr2 << 16 |
   2.134 +	    cdte[i].te_absaddr.lba.addr1 << 8  |
   2.135 +	    cdte[i].te_absaddr.lba.addr0;
   2.136 +	cdrom->track[i].length = 0;
   2.137 +	if ( i > 0 ) {
   2.138 +	    cdrom->track[i - 1].length =
   2.139 +		cdrom->track[i].offset -
   2.140 +		cdrom->track[i - 1].offset;
   2.141  	}
   2.142 +    }
   2.143  #ifdef DEBUG_CDROM
   2.144    for (i = 0; i <= cdrom->numtracks; i++) {
   2.145      fprintf(stderr,"toc_entry[%d].te_track_number = %d\n",
   2.146 @@ -388,13 +386,14 @@
   2.147  /* Start play */
   2.148  static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
   2.149  {
   2.150 -/* Play MSF
   2.151 - *
   2.152 +/*
   2.153 + * Play MSF
   2.154   */
   2.155      struct cd_play_audio_msf msf;
   2.156      int end;
   2.157  
   2.158      bzero(&msf, sizeof(msf));
   2.159 +    start += 150; /* Some CD-ROM drives cannot play the first 150 frames. */
   2.160      end = start +length;
   2.161      FRAMES_TO_MSF(start,
   2.162  		  &msf.msf_starting_M_unit,
   2.163 @@ -450,4 +449,3 @@
   2.164      }
   2.165  }
   2.166  
   2.167 -