annotate vcd_read.h @ 2074:478563b334e3

iosteram included for cout/cerr
author arpi
date Thu, 04 Oct 2001 15:37:13 +0000
parents 5216f108cb4f
children d7920c8257e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 //=================== VideoCD ==========================
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
2 #if defined(linux) || defined(sun)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
3
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
4 #if defined(linux)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
5 #include <linux/cdrom.h>
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
6 #elif defined(sun)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
7 #include <sys/cdio.h>
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
8 static int sun_vcd_read(int, int*);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
9 #endif
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
10
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
11
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 static struct cdrom_tocentry vcd_entry;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 1
diff changeset
14 static inline void vcd_set_msf(unsigned int sect){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 vcd_entry.cdte_addr.msf.frame=sect%75;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 sect=sect/75;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 vcd_entry.cdte_addr.msf.second=sect%60;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 sect=sect/60;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 vcd_entry.cdte_addr.msf.minute=sect;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 1
diff changeset
22 static inline unsigned int vcd_get_msf(){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23 return vcd_entry.cdte_addr.msf.frame +
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24 (vcd_entry.cdte_addr.msf.second+
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25 vcd_entry.cdte_addr.msf.minute*60)*75;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 int vcd_seek_to_track(int fd,int track){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 vcd_entry.cdte_format = CDROM_MSF;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 vcd_entry.cdte_track = track;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31 if (ioctl(fd, CDROMREADTOCENTRY, &vcd_entry)) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 perror("ioctl dif1");
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 1
diff changeset
33 return -1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 }
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 1
diff changeset
35 return VCD_SECTOR_DATA*vcd_get_msf();
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37
598
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
38 int vcd_get_track_end(int fd,int track){
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
39 struct cdrom_tochdr tochdr;
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
40 if (ioctl(fd,CDROMREADTOCHDR,&tochdr)==-1)
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
41 { perror("read CDROM toc header: "); return -1; }
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
42 vcd_entry.cdte_format = CDROM_MSF;
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
43 vcd_entry.cdte_track = track<tochdr.cdth_trk1?(track+1):CDROM_LEADOUT;
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
44 if (ioctl(fd, CDROMREADTOCENTRY, &vcd_entry)) {
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
45 perror("ioctl dif2");
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
46 return -1;
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
47 }
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
48 return VCD_SECTOR_DATA*vcd_get_msf();
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
49 }
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
50
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 void vcd_read_toc(int fd){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 struct cdrom_tochdr tochdr;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 if (ioctl(fd,CDROMREADTOCHDR,&tochdr)==-1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 { perror("read CDROM toc header: "); return; }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 for (i=tochdr.cdth_trk0 ; i<=tochdr.cdth_trk1 ; i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 struct cdrom_tocentry tocentry;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 tocentry.cdte_track = i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 tocentry.cdte_format = CDROM_MSF;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 if (ioctl(fd,CDROMREADTOCENTRY,&tocentry)==-1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 { perror("read CDROM toc entry: "); return; }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1105
diff changeset
65 mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d mode: %d\n",
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 (int)tocentry.cdte_track,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 (int)tocentry.cdte_adr,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 (int)tocentry.cdte_ctrl,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 (int)tocentry.cdte_format,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 (int)tocentry.cdte_addr.msf.minute,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 (int)tocentry.cdte_addr.msf.second,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 (int)tocentry.cdte_addr.msf.frame,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 (int)tocentry.cdte_datamode
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
78
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 static char vcd_buf[VCD_SECTOR_SIZE];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 1
diff changeset
81 static int vcd_read(int fd,char *mem){
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
82 #if defined(linux)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
83 memcpy(vcd_buf,&vcd_entry.cdte_addr.msf,sizeof(struct cdrom_msf));
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
84 if(ioctl(fd,CDROMREADRAW,vcd_buf)==-1) return 0; // EOF?
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
85 memcpy(mem,&vcd_buf[VCD_SECTOR_OFFS],VCD_SECTOR_DATA);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
86 #elif defined(sun)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
87 {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
88 int offset;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
89 if (sun_vcd_read(fd, &offset) <= 0) return 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
90 memcpy(mem,&vcd_buf[offset],VCD_SECTOR_DATA);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
91 }
1020
72cacd3b8f30 Solaris 8 support - patch by Marcus Comstedt <marcus@idonex.se>
arpi_esp
parents: 598
diff changeset
92 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
94 vcd_entry.cdte_addr.msf.frame++;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
95 if (vcd_entry.cdte_addr.msf.frame==75){
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
96 vcd_entry.cdte_addr.msf.frame=0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
97 vcd_entry.cdte_addr.msf.second++;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
98 if (vcd_entry.cdte_addr.msf.second==60){
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
99 vcd_entry.cdte_addr.msf.second=0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
100 vcd_entry.cdte_addr.msf.minute++;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
101 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
102 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
103
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
104 return VCD_SECTOR_DATA;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
105 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
106
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
107
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
108 #ifdef sun
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
109 #include <sys/scsi/generic/commands.h>
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
110 #include <sys/scsi/impl/uscsi.h>
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
111
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
112 #define SUN_XAREAD 1 /*fails on atapi drives*/
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
113 #define SUN_MODE2READ 2 /*fails on atapi drives*/
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
114 #define SUN_SCSIREAD 3
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
115 #define SUN_VCDREAD SUN_SCSIREAD
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
116
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
117 static int sun_vcd_read(int fd, int *offset)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
118 {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
119 #if SUN_VCDREAD == SUN_XAREAD
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
120 struct cdrom_cdxa cdxa;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
121 cdxa.cdxa_addr = vcd_get_msf();
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
122 cdxa.cdxa_length = 1;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
123 cdxa.cdxa_data = vcd_buf;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
124 cdxa.cdxa_format = CDROM_XA_SECTOR_DATA;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
125
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
126 if(ioctl(fd,CDROMCDXA,&cdxa)==-1) {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
127 perror("CDROMCDXA");
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
128 return 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
129 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
130 *offset = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
131 #elif SUN_VCDREAD == SUN_MODE2READ
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
132 struct cdrom_read cdread;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
133 cdread.cdread_lba = 4*vcd_get_msf();
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
134 cdread.cdread_bufaddr = vcd_buf;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
135 cdread.cdread_buflen = 2336;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
137 if(ioctl(fd,CDROMREADMODE2,&cdread)==-1) {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
138 perror("CDROMREADMODE2");
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
139 return 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
140 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
141 *offset = 8;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
142 #elif SUN_VCDREAD == SUN_SCSIREAD
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
143 struct uscsi_cmd sc;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
144 union scsi_cdb cdb;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
145 int lba = vcd_get_msf();
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
146 int blocks = 1;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
147 int sector_type;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
148 int sync, header_code, user_data, edc_ecc, error_field;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
149 int sub_channel;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
150
1105
6121410e667f Remove compiler warning.
atmosfear
parents: 1061
diff changeset
151 /* sector_type = 3; *//* mode2 */
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
152 sector_type = 5; /* mode2/form2 */
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
153 sync = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
154 header_code = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
155 user_data = 1;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
156 edc_ecc = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
157 error_field = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
158 sub_channel = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
159
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
160 memset(&cdb, 0, sizeof(cdb));
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
161 memset(&sc, 0, sizeof(sc));
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
162 cdb.scc_cmd = 0xBE;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
163 cdb.cdb_opaque[1] = (sector_type) << 2;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
164 cdb.cdb_opaque[2] = (lba >> 24) & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
165 cdb.cdb_opaque[3] = (lba >> 16) & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
166 cdb.cdb_opaque[4] = (lba >> 8) & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
167 cdb.cdb_opaque[5] = lba & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
168 cdb.cdb_opaque[6] = (blocks >> 16) & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
169 cdb.cdb_opaque[7] = (blocks >> 8) & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
170 cdb.cdb_opaque[8] = blocks & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
171 cdb.cdb_opaque[9] = (sync << 7) |
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
172 (header_code << 5) |
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
173 (user_data << 4) |
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
174 (edc_ecc << 3) |
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
175 (error_field << 1);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
176 cdb.cdb_opaque[10] = sub_channel;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
177
1061
0f7be115a4db patch by J¸«ärgen Keil
arpi_esp
parents: 1038
diff changeset
178 sc.uscsi_cdb = (caddr_t)&cdb;
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
179 sc.uscsi_cdblen = 12;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
180 sc.uscsi_bufaddr = vcd_buf;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
181 sc.uscsi_buflen = 2336;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
182 sc.uscsi_flags = USCSI_ISOLATE | USCSI_READ;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
183 sc.uscsi_timeout = 20;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
184 if (ioctl(fd, USCSICMD, &sc)) {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
185 perror("USCSICMD: READ CD");
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
186 return -1;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
187 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
188 if (sc.uscsi_status) {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
189 fprintf(stderr, "scsi command failed with status %d\n", sc.uscsi_status);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
190 return -1;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
191 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
192 *offset = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
193 return 1;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
194 #else
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
195 #error SUN_VCDREAD
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
196 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 }
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
198 #endif /*sun*/
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
199
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201 //================== VCD CACHE =======================
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 #ifdef VCD_CACHE
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 static int vcd_cache_size=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 static char *vcd_cache_data=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206 static int *vcd_cache_sectors=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 static int vcd_cache_index=0; // index to first free (or oldest) cache sector
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 static int vcd_cache_current=-1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210 void vcd_cache_init(int s){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211 vcd_cache_size=s;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212 vcd_cache_sectors=malloc(s*sizeof(int));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 vcd_cache_data=malloc(s*VCD_SECTOR_SIZE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214 memset(vcd_cache_sectors,255,s*sizeof(int));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 1
diff changeset
217 static inline void vcd_cache_seek(int sect){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
218 vcd_cache_current=sect;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221 int vcd_cache_read(int fd,char* mem){
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
222 int i;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
223 char* vcd_buf;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
224
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225 for(i=0;i<vcd_cache_size;i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 if(vcd_cache_sectors[i]==vcd_cache_current){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 // found in the cache! :)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228 vcd_buf=&vcd_cache_data[i*VCD_SECTOR_SIZE];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 ++vcd_cache_current;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 memcpy(mem,&vcd_buf[VCD_SECTOR_OFFS],VCD_SECTOR_DATA);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231 return VCD_SECTOR_DATA;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 // NEW cache entry:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 vcd_buf=&vcd_cache_data[vcd_cache_index*VCD_SECTOR_SIZE];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 vcd_cache_sectors[vcd_cache_index]=vcd_cache_current;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 ++vcd_cache_index;if(vcd_cache_index>=vcd_cache_size)vcd_cache_index=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 // read data!
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 vcd_set_msf(vcd_cache_current);
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
239 #if defined(linux)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 memcpy(vcd_buf,&vcd_entry.cdte_addr.msf,sizeof(struct cdrom_msf));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241 if(ioctl(fd,CDROMREADRAW,vcd_buf)==-1) return 0; // EOF?
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
242 memcpy(mem,&vcd_buf[VCD_SECTOR_OFFS],VCD_SECTOR_DATA);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
243 #elif defined(sun)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
244 {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
245 int offset;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
246 if (sun_vcd_read(fd, &offset) <= 0) return 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
247 memcpy(mem,&vcd_buf[offset],VCD_SECTOR_DATA);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
248 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
249 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250 ++vcd_cache_current;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251 return VCD_SECTOR_DATA;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252 }
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
253 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
255 #else /* linux || sun */
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
256
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
257 int vcd_seek_to_track(int fd,int track)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
258 {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
259 return -1;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
260 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
261
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
262 int vcd_get_track_end(int fd,int track)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
263 {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
264 return -1;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
265 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
266
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
267 void vcd_read_toc(int fd)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
268 {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
269 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
270
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
271 static char vcd_buf[VCD_SECTOR_SIZE];
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
272
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
273 static int vcd_read(int fd,char *mem)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
274 {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
275 return -1;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
276 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
277
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
278 #endif /* !linux && !sun */