1 /* 2 * Copyright (C) 1990 Regents of the University of California. 3 * 4 * Permission to use, copy, modify, distribute, and sell this software and 5 * its documentation for any purpose is hereby granted without fee, 6 * provided that the above copyright notice appear in all copies and that 7 * both that copyright notice and this permission notice appear in 8 * supporting documentation, and that the name of the University of 9 * California not be used in advertising or publicity pertaining to 10 * distribution of the software without specific, written prior 11 * permission. the University of California makes no representations 12 * about the suitability of this software for any purpose. It is provided 13 * "as is" without express or implied warranty. 14 */ 15 16 # include <X11/Intrinsic.h> 17 # include <cdaudio.h> 18 # include <audio.h> 19 20 # define NOTITLESTR "No Title" 21 # define NODISCSTR "No Disc" 22 23 # define VAL2PCT(a) (double)(1.0 - 1.0 * (exp((-7.0/255.0) * a))) 24 # define PCT2VAL(a) (int)((-255.0/7.0) * log(1.0 * (1.0 - a))) 25 26 # define bit(n) (1 << (n)) 27 28 /* bits for cdrom_state */ 29 # define CDROM_STATE_PLAY bit(0) 30 # define CDROM_STATE_PAUSE bit(1) 31 # define CDROM_STATE_STOP bit(2) 32 # define CDROM_STATE_EJECTED bit(3) 33 # define CDROM_STATE_CYCLE bit(4) 34 # define CDROM_STATE_SHUFFLE bit(5) 35 # define CDROM_STATE_PROGRAM bit(6) 36 37 /* return codes from cdrom_status() */ 38 # define CDROM_INVALID CD_STILL 39 # define CDROM_PLAYING CD_PLAYING 40 # define CDROM_PAUSED CD_PAUSED 41 # define CDROM_COMPLETED CD_READY 42 # define CDROM_ERROR CD_ERROR 43 # define CDROM_NO_STATUS CD_NODISC 44 # define CD_ABORT 0xfe 45 46 #define CDROM_LEADOUT 0xAA 47 #define CDROM_MSF 0x02 48 #define STILL_MOUNTED 1 49 #define UNMOUNTED 0 50 #define SAMPLES_PER_FRAME (CDDA_DATASIZE/2) 51 52 struct cdrom_tocentry { 53 unsigned char cdte_track; 54 unsigned char cdte_adr :4; 55 unsigned char cdte_ctrl :4; 56 unsigned char cdte_format; 57 union { 58 struct { 59 int minute; 60 int second; 61 int frame; 62 } msf; 63 int lba; 64 } cdte_addr; 65 unsigned char cdte_datamode; 66 }; 67 68 struct msf { 69 int minute; 70 int second; 71 int frame; 72 }; 73 74 struct prognode { 75 unsigned char track; 76 Widget button; 77 struct prognode *next; 78 struct prognode *prev; 79 }; 80 81 typedef struct _cdrom_info { 82 unsigned char curtrack; /* current track playing */ 83 unsigned char mintrack; /* first audio track */ 84 unsigned char maxtrack; /* last audio track */ 85 unsigned char ntracks; /* size of random track list */ 86 int duration; /* seconds played so far */ 87 int state; /* state of cd-rom drive */ 88 short currand; /* index into random track list */ 89 short lastprog; /* number of selections in prog.*/ 90 unsigned short *times; /* duration of each track */ 91 struct msf *addrs; /* starting minute/second/frames*/ 92 struct prognode *selection; /* currently selected prog. trk */ 93 struct prognode *program; /* list of programmed tracks */ 94 int scsi_audio; /* true if scsi audio is avail. */ 95 } cdrom_info; 96 97 /* The below is a repeat of the above for SGIs using scsi_audio (the */ 98 /* CD* calls don't return the info anymore). */ 99 typedef struct _cdrom_audio_info { 100 unsigned char curtrack; 101 int duration; 102 int state; 103 int start_track; /* Start track for play */ 104 int end_track; /* End track for play */ 105 int child_pid; /* PID of child process */ 106 } cdrom_audio_info; 107 108 struct _cdrom_shmem { 109 cdrom_audio_info cdrom_audio_cdi; 110 struct msf cdrom_audio_msf; 111 }; 112 113 extern int cdrom_open(); 114 extern void cdrom_close(); 115 extern int cdrom_start(); 116 extern int cdrom_stop(); 117 extern int cdrom_eject(); 118 extern int cdrom_pause(); 119 extern int cdrom_resume(); 120 extern int cdrom_volume(); 121 extern int cdrom_get_times(); 122 extern int cdrom_get_curtrack(); 123 extern int cdrom_get_msf(); 124 extern int cdrom_get_curmsf(); 125 extern int cdrom_play_track(); 126 extern int cdrom_play_msf(); 127 extern int cdrom_read_tocentry(); 128 extern int cdrom_read_tochdr(); 129 extern int cdrom_status(); 130 131 extern cdrom_info cdi; 132 extern char *disc_title; 133 extern char program_str[]; 134 extern char *cdInfoDir; 135 136