Mercurial > mplayer.hg
annotate stream/vcd_read.h @ 22291:5191a9a9f636
Declarations must be before code
author | reimar |
---|---|
date | Thu, 22 Feb 2007 14:00:21 +0000 |
parents | 64d82a45a05d |
children | 440d23a28592 |
rev | line source |
---|---|
1 | 1 //=================== VideoCD ========================== |
2089 | 2 #if defined(linux) || defined(sun) || defined(__bsdi__) |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
3 |
9887 | 4 typedef struct mp_vcd_priv_st mp_vcd_priv_t; |
5 | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
6 #if defined(linux) |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
7 #include <linux/cdrom.h> |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
8 #elif defined(sun) |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
9 #include <sys/cdio.h> |
9887 | 10 static int sun_vcd_read(mp_vcd_priv_t*, int*); |
2089 | 11 #elif defined(__bsdi__) |
12 #include <dvd.h> | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
13 #endif |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
14 |
9887 | 15 struct mp_vcd_priv_st { |
16 int fd; | |
17 struct cdrom_tocentry entry; | |
18 char buf[VCD_SECTOR_SIZE]; | |
19 }; | |
1 | 20 |
9887 | 21 static inline void vcd_set_msf(mp_vcd_priv_t* vcd, unsigned int sect){ |
22 vcd->entry.cdte_addr.msf.frame=sect%75; | |
1 | 23 sect=sect/75; |
9887 | 24 vcd->entry.cdte_addr.msf.second=sect%60; |
1 | 25 sect=sect/60; |
9887 | 26 vcd->entry.cdte_addr.msf.minute=sect; |
1 | 27 } |
28 | |
9887 | 29 static inline unsigned int vcd_get_msf(mp_vcd_priv_t* vcd){ |
30 return vcd->entry.cdte_addr.msf.frame + | |
31 (vcd->entry.cdte_addr.msf.second+ | |
32 vcd->entry.cdte_addr.msf.minute*60)*75; | |
1 | 33 } |
34 | |
9887 | 35 int vcd_seek_to_track(mp_vcd_priv_t* vcd,int track){ |
36 vcd->entry.cdte_format = CDROM_MSF; | |
37 vcd->entry.cdte_track = track; | |
38 if (ioctl(vcd->fd, CDROMREADTOCENTRY, &vcd->entry)) { | |
39 mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif1: %s\n",strerror(errno)); | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
1
diff
changeset
|
40 return -1; |
1 | 41 } |
9887 | 42 return VCD_SECTOR_DATA*vcd_get_msf(vcd); |
1 | 43 } |
44 | |
9887 | 45 int vcd_get_track_end(mp_vcd_priv_t* vcd,int track){ |
598 | 46 struct cdrom_tochdr tochdr; |
9887 | 47 if (ioctl(vcd->fd,CDROMREADTOCHDR,&tochdr)==-1) { |
48 mp_msg(MSGT_STREAM,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno)); | |
49 return -1; | |
50 } | |
51 vcd->entry.cdte_format = CDROM_MSF; | |
52 vcd->entry.cdte_track = track<tochdr.cdth_trk1?(track+1):CDROM_LEADOUT; | |
53 if (ioctl(vcd->fd, CDROMREADTOCENTRY, &vcd->entry)) { | |
54 mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif2: %s\n",strerror(errno)); | |
598 | 55 return -1; |
56 } | |
9887 | 57 return VCD_SECTOR_DATA*vcd_get_msf(vcd); |
598 | 58 } |
59 | |
9887 | 60 mp_vcd_priv_t* vcd_read_toc(int fd){ |
1 | 61 struct cdrom_tochdr tochdr; |
9887 | 62 mp_vcd_priv_t* vcd; |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
63 int i, min = 0, sec = 0, frame = 0; |
9887 | 64 if (ioctl(fd,CDROMREADTOCHDR,&tochdr)==-1) { |
65 mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno)); | |
66 return NULL; | |
67 } | |
18237
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
16547
diff
changeset
|
68 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_START_TRACK=%d\n", tochdr.cdth_trk0); |
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
16547
diff
changeset
|
69 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_END_TRACK=%d\n", tochdr.cdth_trk1); |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
70 for (i=tochdr.cdth_trk0 ; i<=tochdr.cdth_trk1 + 1; i++){ |
1 | 71 struct cdrom_tocentry tocentry; |
72 | |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
73 tocentry.cdte_track = i<=tochdr.cdth_trk1 ? i : CDROM_LEADOUT; |
1 | 74 tocentry.cdte_format = CDROM_MSF; |
75 | |
9887 | 76 if (ioctl(fd,CDROMREADTOCENTRY,&tocentry)==-1) { |
77 mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc entry: %s\n",strerror(errno)); | |
78 return NULL; | |
79 } | |
1 | 80 |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
81 if (i<=tochdr.cdth_trk1) |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1105
diff
changeset
|
82 mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d mode: %d\n", |
1 | 83 (int)tocentry.cdte_track, |
84 (int)tocentry.cdte_adr, | |
85 (int)tocentry.cdte_ctrl, | |
86 (int)tocentry.cdte_format, | |
87 (int)tocentry.cdte_addr.msf.minute, | |
88 (int)tocentry.cdte_addr.msf.second, | |
89 (int)tocentry.cdte_addr.msf.frame, | |
90 (int)tocentry.cdte_datamode | |
91 ); | |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
92 |
18237
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
16547
diff
changeset
|
93 if (mp_msg_test(MSGT_IDENTIFY, MSGL_INFO)) |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
94 { |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
95 if (i > tochdr.cdth_trk0) |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
96 { |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
97 min = tocentry.cdte_addr.msf.minute - min; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
98 sec = tocentry.cdte_addr.msf.second - sec; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
99 frame = tocentry.cdte_addr.msf.frame - frame; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
100 if ( frame < 0 ) |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
101 { |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
102 frame += 75; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
103 sec --; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
104 } |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
105 if ( sec < 0 ) |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
106 { |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
107 sec += 60; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
108 min --; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
109 } |
18237
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
16547
diff
changeset
|
110 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_TRACK_%d_MSF=%02d:%02d:%02d\n", i - 1, min, sec, frame); |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
111 } |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
112 min = tocentry.cdte_addr.msf.minute; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
113 sec = tocentry.cdte_addr.msf.second; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
114 frame = tocentry.cdte_addr.msf.frame; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
10300
diff
changeset
|
115 } |
1 | 116 } |
9887 | 117 vcd = malloc(sizeof(mp_vcd_priv_t)); |
118 vcd->fd = fd; | |
119 return vcd; | |
1 | 120 } |
121 | |
9887 | 122 static int vcd_read(mp_vcd_priv_t* vcd,char *mem){ |
2089 | 123 #if defined(linux) || defined(__bsdi__) |
9887 | 124 memcpy(vcd->buf,&vcd->entry.cdte_addr.msf,sizeof(struct cdrom_msf)); |
125 if(ioctl(vcd->fd,CDROMREADRAW,vcd->buf)==-1) return 0; // EOF? | |
126 memcpy(mem,&vcd->buf[VCD_SECTOR_OFFS],VCD_SECTOR_DATA); | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
127 #elif defined(sun) |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
128 { |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
129 int offset; |
9887 | 130 if (sun_vcd_read(vcd->fd, &offset) <= 0) return 0; |
131 memcpy(mem,&vcd->buf[offset],VCD_SECTOR_DATA); | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
132 } |
1020
72cacd3b8f30
Solaris 8 support - patch by Marcus Comstedt <marcus@idonex.se>
arpi_esp
parents:
598
diff
changeset
|
133 #endif |
1 | 134 |
9887 | 135 vcd->entry.cdte_addr.msf.frame++; |
136 if (vcd->entry.cdte_addr.msf.frame==75){ | |
137 vcd->entry.cdte_addr.msf.frame=0; | |
138 vcd->entry.cdte_addr.msf.second++; | |
139 if (vcd->entry.cdte_addr.msf.second==60){ | |
140 vcd->entry.cdte_addr.msf.second=0; | |
141 vcd->entry.cdte_addr.msf.minute++; | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
142 } |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
143 } |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
144 |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
145 return VCD_SECTOR_DATA; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
146 } |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
147 |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
148 |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
149 #ifdef sun |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
150 #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
|
151 #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
|
152 |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
153 #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
|
154 #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
|
155 #define SUN_SCSIREAD 3 |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
156 #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
|
157 |
9887 | 158 static int sun_vcd_read(mp_vcd_priv_t* vcd, int *offset) |
1038
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 #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
|
161 struct cdrom_cdxa cdxa; |
9887 | 162 cdxa.cdxa_addr = vcd_get_msf(vcd); |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
163 cdxa.cdxa_length = 1; |
9887 | 164 cdxa.cdxa_data = vcd->buf; |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
165 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
|
166 |
10300
134e4332f550
solaris fix by Gtz Waschk <waschk@informatik.uni-rostock.de>
alex
parents:
9887
diff
changeset
|
167 if(ioctl(vcd->fd,CDROMCDXA,&cdxa)==-1) { |
9887 | 168 mp_msg(MSGT_STREAM,MSGL_ERR,"CDROMCDXA: %s\n",strerror(errno)); |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
169 return 0; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
170 } |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
171 *offset = 0; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
172 #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
|
173 struct cdrom_read cdread; |
9887 | 174 cdread.cdread_lba = 4*vcd_get_msf(vcd); |
175 cdread.cdread_bufaddr = vcd->buf; | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
176 cdread.cdread_buflen = 2336; |
1 | 177 |
10300
134e4332f550
solaris fix by Gtz Waschk <waschk@informatik.uni-rostock.de>
alex
parents:
9887
diff
changeset
|
178 if(ioctl(vcd->fd,CDROMREADMODE2,&cdread)==-1) { |
9887 | 179 mp_msg(MSGT_STREAM,MSGL_ERR,"CDROMREADMODE2: %s\n",strerror(errno)); |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
180 return 0; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
181 } |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
182 *offset = 8; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
183 #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
|
184 struct uscsi_cmd sc; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
185 union scsi_cdb cdb; |
9887 | 186 int lba = vcd_get_msf(vcd); |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
187 int blocks = 1; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
188 int sector_type; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
189 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
|
190 int sub_channel; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
191 |
1105 | 192 /* 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
|
193 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
|
194 sync = 0; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
195 header_code = 0; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
196 user_data = 1; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
197 edc_ecc = 0; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
198 error_field = 0; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
199 sub_channel = 0; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
200 |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
201 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
|
202 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
|
203 cdb.scc_cmd = 0xBE; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
204 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
|
205 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
|
206 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
|
207 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
|
208 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
|
209 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
|
210 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
|
211 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
|
212 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
|
213 (header_code << 5) | |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
214 (user_data << 4) | |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
215 (edc_ecc << 3) | |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
216 (error_field << 1); |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
217 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
|
218 |
1061 | 219 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
|
220 sc.uscsi_cdblen = 12; |
9887 | 221 sc.uscsi_bufaddr = vcd->buf; |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
222 sc.uscsi_buflen = 2336; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
223 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
|
224 sc.uscsi_timeout = 20; |
10300
134e4332f550
solaris fix by Gtz Waschk <waschk@informatik.uni-rostock.de>
alex
parents:
9887
diff
changeset
|
225 if (ioctl(vcd->fd, USCSICMD, &sc)) { |
9887 | 226 mp_msg(MSGT_STREAM,MSGL_ERR,"USCSICMD: READ CD: %s\n",strerror(errno)); |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
227 return -1; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
228 } |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
229 if (sc.uscsi_status) { |
9887 | 230 mp_msg(MSGT_STREAM,MSGL_ERR,"scsi command failed with status %d\n", sc.uscsi_status); |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
231 return -1; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
232 } |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
233 *offset = 0; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
234 return 1; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
235 #else |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
236 #error SUN_VCDREAD |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
237 #endif |
1 | 238 } |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
239 #endif /*sun*/ |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
240 |
3261 | 241 #else /* linux || sun || __bsdi__ */ |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
242 |
3261 | 243 #error vcd is not yet supported on this arch... |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
244 |
3261 | 245 #endif |